Mahiruoshi
commited on
Commit
•
031ba98
1
Parent(s):
468b67d
Update inference_ork.py
Browse files- inference_ork.py +13 -11
inference_ork.py
CHANGED
@@ -76,12 +76,15 @@ def ttv(text):
|
|
76 |
print("推理耗时:",(t2 - t1),"s")
|
77 |
openai.api_key = args.key
|
78 |
result_list = []
|
79 |
-
messages = [
|
80 |
-
|
81 |
-
|
82 |
-
]
|
|
|
|
|
|
|
83 |
def send_message():
|
84 |
-
text = input_box.get("1.0", "end-1c")
|
85 |
messages.append({"role": "user", "content": text},)
|
86 |
chat = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=messages)
|
87 |
reply = chat.choices[0].message.content
|
@@ -91,14 +94,13 @@ def send_message():
|
|
91 |
if len(messages) == 12:
|
92 |
messages[6:10] = messages[8:]
|
93 |
del messages[-2:]
|
94 |
-
with open('log.
|
95 |
-
|
96 |
-
f.write(str(item) + "\n")
|
97 |
chat_box.configure(state='normal')
|
98 |
-
chat_box.insert(tk.END, "You: " + text + "\n")
|
99 |
chat_box.insert(tk.END, "Tamao: " + reply + "\n")
|
100 |
-
chat_box.configure(state='disabled')
|
101 |
-
input_box.delete("1.0", tk.END)
|
102 |
|
103 |
root = tk.Tk()
|
104 |
root.title("Tamao")
|
|
|
76 |
print("推理耗时:",(t2 - t1),"s")
|
77 |
openai.api_key = args.key
|
78 |
result_list = []
|
79 |
+
messages = []
|
80 |
+
read_log = input('Loading log?(y/n)')
|
81 |
+
if read_log == 'y':
|
82 |
+
messages = []
|
83 |
+
with open('log.pickle', 'rb') as f:
|
84 |
+
messages = pickle.load(f)
|
85 |
+
print('Most recently log:\n'+str(messages[-1]))
|
86 |
def send_message():
|
87 |
+
text = input_box.get("1.0", "end-1c") # 获取用户输入的文本
|
88 |
messages.append({"role": "user", "content": text},)
|
89 |
chat = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=messages)
|
90 |
reply = chat.choices[0].message.content
|
|
|
94 |
if len(messages) == 12:
|
95 |
messages[6:10] = messages[8:]
|
96 |
del messages[-2:]
|
97 |
+
with open('log.pickle', 'wb') as f:
|
98 |
+
pickle.dump(messages, f)
|
|
|
99 |
chat_box.configure(state='normal')
|
100 |
+
chat_box.insert(tk.END, "You: " + text + "\n")
|
101 |
chat_box.insert(tk.END, "Tamao: " + reply + "\n")
|
102 |
+
chat_box.configure(state='disabled')
|
103 |
+
input_box.delete("1.0", tk.END)
|
104 |
|
105 |
root = tk.Tk()
|
106 |
root.title("Tamao")
|