Mahiruoshi commited on
Commit
031ba98
1 Parent(s): 468b67d

Update inference_ork.py

Browse files
Files changed (1) hide show
  1. 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
- {"role": "system", "content": "你是超级ai,名字叫巴珠绪。接下来我们将进行一个克苏鲁跑团游戏,你负责扮演守密人,我负责扮演调查员。接下来你会加载一个名叫《幽暗之门》的模组,作为守密人,你需要基于“克苏鲁神话角色扮演游戏规则第七版(Call of Cthulhu 7th Edition)”,我会给你剧本的开头部分,然后基于你对它的理解自由发挥。投掷骰子的环节将由你来模拟,用两个1d10的骰子来生成0-100的随机数。比如说我的某一项属性点是80,当骰子的数目小于80时就判定为成功,0-5为大成功,95-100为大失败等等。整个游戏过程将类似于你来描述故事,我来投骰子并且做出决定来推动剧情的走向。"},
81
- {'role': 'assistant', 'content': '我明白了,现在我将扮演守密人。'},
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.txt', 'w', encoding='utf-8') as f:
95
- for item in messages:
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")