diff --git a/ChatGPT_PyBot/chatgpt.py b/ChatGPT_PyBot/chatgpt.py index f0eef33..7527859 100644 --- a/ChatGPT_PyBot/chatgpt.py +++ b/ChatGPT_PyBot/chatgpt.py @@ -2,11 +2,13 @@ import cmd import requests import json +import os import uuid from rich.console import Console from rich.markdown import Markdown from OpenAIAuth.OpenAIAuth import OpenAIAuth, Debugger + console = Console() BASE_URL = "https://chat.openai.com/" @@ -316,6 +318,13 @@ def do_exit(self, _): def main(): + file_list = os.listdir(os.getcwd()) + if 'config.json' not in file_list: + print("config.json not found in current directory!") + print("Please read the configuration instructions at https://github.com/liuhuanshuo/ChatGPT_PyBot") + print("And make sure that config.json file is available in the current directory!") + exit() + with open("config.json", encoding="utf-8") as f: config = json.load(f) if "--debug" in sys.argv: @@ -329,11 +338,16 @@ def main(): print("To start ChatGPT, make sure to include the file config.json in the current directory!") exit() - print("To start ChatGPT, make sure to include the file config.json in the current directory!") + # print("To start ChatGPT, make sure to include the file config.json in the current directory!") print("Logging in...") print("") - chatbot = ChatBot(config, debug=debug) - + try: + chatbot = ChatBot(config, debug=debug) + except: + print("Error when logging in to OpenAI. Please check the configuration information in config.json is valid.") + print("If you are using an account password for verification, make sure your terminal can access OpenAI, otherwise, use session_token!") + print("More configuration instructions, please refer to https://github.com/liuhuanshuo/ChatGPT_PyBot!") + exit() if len(sys.argv) > 1 and not help_tips: response = chatbot.get_chat_response(" ".join(sys.argv[1:]))["message"] diff --git a/readme.md b/readme.md index 1e42f34..4e11475 100644 --- a/readme.md +++ b/readme.md @@ -125,3 +125,6 @@ If you need to call ChatGPT in Python, you can do something like this This project is inspired by [ChatGPT - A reverse engineering of OpenAI]( https://github.com/acheong08/ChatGPT) +### Disclaimer: + +***ChatGPT-PyBot is in no way associated with, endorsed by, or otherwise affiliated with OpenAI.*** diff --git a/setup.py b/setup.py index a10fcea..010b929 100644 --- a/setup.py +++ b/setup.py @@ -1,16 +1,16 @@ from setuptools import setup, find_packages -with open("readme.md", "r", encoding="utf-8") as fh: - long_description = fh.read() +# with open("readme.md", "r", encoding="utf-8") as fh: +# long_description = fh.read() setup( name="ChatGPT_PyBot", - version="0.2.1", + version="0.3", license="GNU General Public License v2.0", author="Liuhuanshuo", author_email="huanshuo080l@gmail.com", description="A Python based ChatGPT robot that can be used in the command line", - long_description=long_description, + long_description=open("readme.md", encoding="utf-8").read(), long_description_content_type="text/markdown", url="https://github.com/liuhuanshuo/ChatGPT_PyBot", packages=find_packages(),