Skip to content

Commit

Permalink
fix environ err
Browse files Browse the repository at this point in the history
  • Loading branch information
RexWzh committed Nov 27, 2023
1 parent e9910e3 commit 0109281
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion askchat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

__author__ = """Rex Wang"""
__email__ = '[email protected]'
__version__ = '0.3.2'
__version__ = '0.3.3'

from .askchat import ask
19 changes: 10 additions & 9 deletions askchat/askchat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']

Expand Down

0 comments on commit 0109281

Please sign in to comment.