Skip to content

Commit 952026d

Browse files
fix: ValueError breaks Ui #629 (#630) #none
1 parent 8b04f84 commit 952026d

File tree

1 file changed

+36
-33
lines changed

1 file changed

+36
-33
lines changed

libs/ktem/ktem/pages/chat/__init__.py

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,39 +1317,42 @@ def chat_fn(
13171317
chat_state,
13181318
)
13191319

1320-
for response in pipeline.stream(chat_input, conversation_id, chat_history):
1321-
1322-
if not isinstance(response, Document):
1323-
continue
1324-
1325-
if response.channel is None:
1326-
continue
1327-
1328-
if response.channel == "chat":
1329-
if response.content is None:
1330-
text = ""
1331-
else:
1332-
text += response.content
1333-
1334-
if response.channel == "info":
1335-
if response.content is None:
1336-
refs = ""
1337-
else:
1338-
refs += response.content
1339-
1340-
if response.channel == "plot":
1341-
plot = response.content
1342-
plot_gr = self._json_to_plot(plot)
1343-
1344-
chat_state[pipeline.get_info()["id"]] = reasoning_state["pipeline"]
1345-
1346-
yield (
1347-
chat_history + [(chat_input, text or msg_placeholder)],
1348-
refs,
1349-
plot_gr,
1350-
plot,
1351-
chat_state,
1352-
)
1320+
try:
1321+
for response in pipeline.stream(chat_input, conversation_id, chat_history):
1322+
1323+
if not isinstance(response, Document):
1324+
continue
1325+
1326+
if response.channel is None:
1327+
continue
1328+
1329+
if response.channel == "chat":
1330+
if response.content is None:
1331+
text = ""
1332+
else:
1333+
text += response.content
1334+
1335+
if response.channel == "info":
1336+
if response.content is None:
1337+
refs = ""
1338+
else:
1339+
refs += response.content
1340+
1341+
if response.channel == "plot":
1342+
plot = response.content
1343+
plot_gr = self._json_to_plot(plot)
1344+
1345+
chat_state[pipeline.get_info()["id"]] = reasoning_state["pipeline"]
1346+
1347+
yield (
1348+
chat_history + [(chat_input, text or msg_placeholder)],
1349+
refs,
1350+
plot_gr,
1351+
plot,
1352+
chat_state,
1353+
)
1354+
except ValueError as e:
1355+
print(e)
13531356

13541357
if not text:
13551358
empty_msg = getattr(

0 commit comments

Comments
 (0)