Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ValueError breaks Ui #630

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 36 additions & 33 deletions libs/ktem/ktem/pages/chat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1045,39 +1045,42 @@ def chat_fn(
chat_state,
)

for response in pipeline.stream(chat_input, conversation_id, chat_history):

if not isinstance(response, Document):
continue

if response.channel is None:
continue

if response.channel == "chat":
if response.content is None:
text = ""
else:
text += response.content

if response.channel == "info":
if response.content is None:
refs = ""
else:
refs += response.content

if response.channel == "plot":
plot = response.content
plot_gr = self._json_to_plot(plot)

chat_state[pipeline.get_info()["id"]] = reasoning_state["pipeline"]

yield (
chat_history + [(chat_input, text or msg_placeholder)],
refs,
plot_gr,
plot,
chat_state,
)
try:
for response in pipeline.stream(chat_input, conversation_id, chat_history):

if not isinstance(response, Document):
continue

if response.channel is None:
continue

if response.channel == "chat":
if response.content is None:
text = ""
else:
text += response.content

if response.channel == "info":
if response.content is None:
refs = ""
else:
refs += response.content

if response.channel == "plot":
plot = response.content
plot_gr = self._json_to_plot(plot)

chat_state[pipeline.get_info()["id"]] = reasoning_state["pipeline"]

yield (
chat_history + [(chat_input, text or msg_placeholder)],
refs,
plot_gr,
plot,
chat_state,
)
except ValueError as e:
print(e)

if not text:
empty_msg = getattr(
Expand Down
Loading