diff --git a/chat_command.py b/chat_command.py new file mode 100644 index 0000000..de13a81 --- /dev/null +++ b/chat_command.py @@ -0,0 +1,39 @@ +import openai +import re + +# 定义用于与API交互的OpenAI API密钥 +openai.api_key = str(input('请输入你的API key:')) + +# 定义所需模型,这里使用Davinci,是GPT-3.5中的最大模型 +model_engine = "davinci" + +# 定义对话处理函数 +def chat(prompt): + # 调用GPT-3.5 API生成对话回复 + response = openai.Completion.create( + engine=model_engine, + prompt=prompt, + temperature=0.7, # 控制对话生成的创造力 + max_tokens=4000, # 控制最多可输出的token数 + n=1, + stop=None, + timeout=30, + ) + + # 获取生成回复文本 + answer = response.choices[0].text + + # 对回复进行处理,去除一些特殊字符和回车符 + answer = re.sub('[^0-9a-zA-Z.,!?/:;\"\'\s]|(\r?\n)+', '', answer).strip() + + return answer + +# 测试代码 +while True: + prompt = input("You: ") + if prompt.lower() in ['bye', 'goodbye']: + print("chatGPT: Goodbye!") + break + else: + answer = chat(prompt) + print("chatGPT:", answer) diff --git a/client.pyw b/client.pyw index 1cec042..62c768f 100644 --- a/client.pyw +++ b/client.pyw @@ -31,9 +31,12 @@ def update(): open_exe("update") def quit_exe(): - os.system('taskkill -f -t -im aiyunos.exe') + os.system('taskkill -f -t -im qdymys.exe') os.system('taskkill -f -t -im wuguokai.exe') os.system('taskkill -f -t -im extkj.exe') + os.system('taskkill -f -t -im bnu120.exe') + os.system('taskkill -f -t -im lbbai.exe') + os.system('taskkill -f -t -im chat_command.exe') os.system('taskkill -f -t -im python.exe') sys.exit()