|
@@ -3,14 +3,15 @@
|
|
|
|
|
|
import configparser
|
|
|
import tkinter as tk
|
|
|
-import openai
|
|
|
+from openai import OpenAI
|
|
|
+
|
|
|
+client = OpenAI(api_key="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")
|
|
|
import threading
|
|
|
#
|
|
|
# config = configparser.ConfigParser()
|
|
|
# config.read("config.txt")
|
|
|
|
|
|
# supply your API key however you choose
|
|
|
-openai.api_key = "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"
|
|
|
# print(config['example']["key"])
|
|
|
|
|
|
|
|
@@ -19,8 +20,7 @@ def submit_text():
|
|
|
# Get text without the newline character
|
|
|
text = text_input.get("1.0", "end-1c")
|
|
|
text_doing.insert(tk.END, "莫着急,正在等待网页响应中。。。")
|
|
|
- completion = openai.ChatCompletion.create(
|
|
|
- model="gpt-3.5-turbo", messages=[{"role": "user", "content": text}])
|
|
|
+ completion = client.chat.completions.create(model="gpt-3.5-turbo", messages=[{"role": "user", "content": text}])
|
|
|
print(completion.choices[0].message.content)
|
|
|
text_doing.delete("1.0", 'end')
|
|
|
text_output.insert(tk.END, completion.choices[0].message.content + '\n')
|