From 010928171bda0a6a7a0a31d502fa2e4cc52cd97d Mon Sep 17 00:00:00 2001 From: rex <1073853456@qq.com> Date: Mon, 27 Nov 2023 11:49:59 +0800 Subject: [PATCH] fix environ err --- askchat/__init__.py | 2 +- askchat/askchat.py | 19 ++++++++++--------- setup.py | 4 ++-- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/askchat/__init__.py b/askchat/__init__.py index 411c040..9219f76 100644 --- a/askchat/__init__.py +++ b/askchat/__init__.py @@ -2,6 +2,6 @@ __author__ = """Rex Wang""" __email__ = '1073853456@qq.com' -__version__ = '0.3.2' +__version__ = '0.3.3' from .askchat import ask \ No newline at end of file diff --git a/askchat/askchat.py b/askchat/askchat.py index 2df0308..49995b0 100644 --- a/askchat/askchat.py +++ b/askchat/askchat.py @@ -3,20 +3,14 @@ from argparse import ArgumentParser from pprint import pprint from dotenv import load_dotenv, set_key -import asyncio, os, uuid, json, shutil +import asyncio, os, uuid, shutil +from chattool import Chat, debug_log, load_envs import askchat VERSION = askchat.__version__ CONFIG_PATH = os.path.expanduser("~/.askchat") CONFIG_FILE = os.path.expanduser("~/.askchat/.env") LAST_CHAT_FILE = os.path.expanduser("~/.askchat/_last_chat.json") -os.makedirs(CONFIG_PATH, exist_ok=True) -## read para from config file -if os.path.exists(CONFIG_FILE): - load_dotenv(CONFIG_FILE, override=True) - -# load chattool after update the config -from chattool import Chat, debug_log # print the response in a typewriter way async def show_resp(chat, delay=0.01): @@ -66,14 +60,21 @@ def main(): parser.add_argument('--generate-config', action="store_true", help="Generate a configuration file by environment table") parser.add_argument('-v', '--version', action='version', version=VERSION) args = parser.parse_args() - + # set values + os.makedirs(CONFIG_PATH, exist_ok=True) + ## read para from config file + if os.path.exists(CONFIG_FILE): + load_dotenv(CONFIG_FILE, override=True) + ## set para from command line if args.api_key: os.environ['OPENAI_API_KEY'] = args.api_key if args.base_url: os.environ['OPENAI_API_BASE_URL'] = args.base_url if args.model: os.environ['OPENAI_API_MODEL'] = args.model + load_envs() + # show debug log if args.debug: debug_log() diff --git a/setup.py b/setup.py index 6729fb2..0ceb003 100644 --- a/setup.py +++ b/setup.py @@ -4,12 +4,12 @@ from setuptools import setup, find_packages -VERSION = '0.3.2' +VERSION = '0.3.3' with open('README.md') as readme_file: readme = readme_file.read() -requirements = ['chattool>=2.6.0', "python-dotenv>=0.17.0"] +requirements = ['chattool>=2.6.1', "python-dotenv>=0.17.0"] test_requirements = ['pytest>=3']