Skip to content
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
8 changes: 5 additions & 3 deletions gradio/external_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,12 @@ def chat_fn(message, history):
history = []
history.append({"role": "user", "content": message})
try:
out = ""
out_chunks = []
for chunk in client.chat_completion(messages=history, stream=True):
out += chunk.choices[0].delta.content or "" if chunk.choices else ""
yield out
content = chunk.choices[0].delta.content or "" if chunk.choices else ""
if content:
out_chunks.append(content)
yield "".join(out_chunks)
except Exception as e:
handle_hf_error(e)

Expand Down