Jiana commited on
Commit
3a987fa
·
1 Parent(s): 0249628

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -4
app.py CHANGED
@@ -57,6 +57,7 @@ def init_user_info(uid):
57
  count_i_dict[uid] = dict()
58
  count_i_dict[uid]["count_i"] = 1
59
  count_i_dict[uid]["user_response"] = _user_response
 
60
 
61
 
62
  def get_count_i(uid):
@@ -160,14 +161,24 @@ def chat(p, qid, uid):
160
 
161
 
162
  # 找出该 uid 对应的历史对话
163
- global history
164
- if uid in history:
165
- msgs = history[uid]
 
 
 
 
 
 
166
  else:
 
167
  msgs = []
 
168
 
169
  response = callapi(p, msgs)
170
- history[uid] = msgs + [[p, response]]
 
 
171
  logger.info(f"history for user={uid}: {msgs}, uid={uid}, count_i={get_count_i(uid)}, qid={qid}")
172
  logger.info(f"current p for user={uid}: {p}, count_i={get_count_i(uid)}, qid={qid}")
173
  logger.info(f"response for user={uid}: {response}, count_i={get_count_i(uid)}, qid={qid}")
 
57
  count_i_dict[uid] = dict()
58
  count_i_dict[uid]["count_i"] = 1
59
  count_i_dict[uid]["user_response"] = _user_response
60
+ count_i_dict[uid]["history"] = []
61
 
62
 
63
  def get_count_i(uid):
 
161
 
162
 
163
  # 找出该 uid 对应的历史对话
164
+ # global history
165
+ # if uid in history:
166
+ # msgs = history[uid]
167
+ # else:
168
+ # msgs = []
169
+
170
+ if uid in count_i_dict:
171
+ history = count_i_dict[uid]["history"]
172
+ msgs = history
173
  else:
174
+ init_user_info(uid)
175
  msgs = []
176
+
177
 
178
  response = callapi(p, msgs)
179
+ # history[uid] = msgs + [[p, response]]
180
+ count_i_dict[uid]["history"] = msgs + [[p, response]]
181
+
182
  logger.info(f"history for user={uid}: {msgs}, uid={uid}, count_i={get_count_i(uid)}, qid={qid}")
183
  logger.info(f"current p for user={uid}: {p}, count_i={get_count_i(uid)}, qid={qid}")
184
  logger.info(f"response for user={uid}: {response}, count_i={get_count_i(uid)}, qid={qid}")