Skip to content

Commit 4adc600

Browse files
authored
Add query error (hiyouga#32)
Refs: NOTICKET
1 parent b586449 commit 4adc600

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

code/rag/run_rag.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,13 @@ def clear_document_list():
7474
def add_message(history, message, thread_id):
7575
if message:
7676
history.append({"role": "user", "content": message})
77-
response = rag_pipeline.query(message, thread_id=thread_id)
78-
bot_message = response["messages"][-1].content
77+
try:
78+
response = rag_pipeline.query(message, thread_id=thread_id)
79+
bot_message = response["messages"][-1].content
80+
except Exception as e:
81+
bot_message = (
82+
f"<span style='color:red; font-weight:bold;'>Error: {e}</span>"
83+
)
7984
history.append({"role": "assistant", "content": bot_message})
8085

8186
return history, ""

0 commit comments

Comments
 (0)