gerasdf
commited on
Commit
·
7a05c53
1
Parent(s):
7a5649e
bugfix(on werid sequence of chat histories)
Browse files
query.py
CHANGED
@@ -256,11 +256,20 @@ def add_history(state, request, type, message, name:str = None):
|
|
256 |
def load_history(state, history_id):
|
257 |
state["history"] = History.load(history_id)
|
258 |
|
259 |
-
history = [
|
260 |
-
|
261 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
262 |
|
263 |
-
if
|
264 |
user_input = history[-1][0]
|
265 |
history = history[:-1]
|
266 |
else:
|
|
|
256 |
def load_history(state, history_id):
|
257 |
state["history"] = History.load(history_id)
|
258 |
|
259 |
+
history = []
|
260 |
+
for msg in state["history"].messages():
|
261 |
+
if type(msg) is HumanMessage:
|
262 |
+
history.append([msg.content, ''])
|
263 |
+
elif type(msg) is AIMessage:
|
264 |
+
if not history:
|
265 |
+
history.append(['',''])
|
266 |
+
last = history[-1]
|
267 |
+
if last[1]:
|
268 |
+
history.append(['', msg.content])
|
269 |
+
else:
|
270 |
+
last[1] = msg.content
|
271 |
|
272 |
+
if history and len(history[-1]) == 1:
|
273 |
user_input = history[-1][0]
|
274 |
history = history[:-1]
|
275 |
else:
|