mirror of
https://github.com/MODSetter/SurfSense.git
synced 2025-09-02 02:29:08 +00:00
fix: bad chat history logic
This commit is contained in:
parent
24587d796d
commit
a19a8af4ff
1 changed files with 8 additions and 4 deletions
|
@ -54,10 +54,14 @@ async def handle_chat_data(
|
||||||
if message['role'] == "user":
|
if message['role'] == "user":
|
||||||
langchain_chat_history.append(HumanMessage(content=message['content']))
|
langchain_chat_history.append(HumanMessage(content=message['content']))
|
||||||
elif message['role'] == "assistant":
|
elif message['role'] == "assistant":
|
||||||
# Last annotation type will always be "ANSWER" here
|
# Find the last "ANSWER" annotation specifically
|
||||||
answer_annotation = message['annotations'][-1]
|
answer_annotation = None
|
||||||
answer_text = ""
|
for annotation in reversed(message['annotations']):
|
||||||
if answer_annotation['type'] == "ANSWER":
|
if annotation['type'] == "ANSWER":
|
||||||
|
answer_annotation = annotation
|
||||||
|
break
|
||||||
|
|
||||||
|
if answer_annotation:
|
||||||
answer_text = answer_annotation['content']
|
answer_text = answer_annotation['content']
|
||||||
# If content is a list, join it into a single string
|
# If content is a list, join it into a single string
|
||||||
if isinstance(answer_text, list):
|
if isinstance(answer_text, list):
|
||||||
|
|
Loading…
Add table
Reference in a new issue