Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -554,6 +554,7 @@ def chat_fn(message, history, temperature, top_k, top_p, max_tokens):
|
|
| 554 |
conversation += f"User: {message} Sam:"
|
| 555 |
|
| 556 |
# Stream response token by token
|
|
|
|
| 557 |
for response in model.generate_stream(
|
| 558 |
conversation,
|
| 559 |
max_new_tokens=max_tokens,
|
|
@@ -561,7 +562,9 @@ def chat_fn(message, history, temperature, top_k, top_p, max_tokens):
|
|
| 561 |
top_k=top_k,
|
| 562 |
top_p=top_p
|
| 563 |
):
|
| 564 |
-
|
|
|
|
|
|
|
| 565 |
|
| 566 |
# Create Gradio interface
|
| 567 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
|
|
| 554 |
conversation += f"User: {message} Sam:"
|
| 555 |
|
| 556 |
# Stream response token by token
|
| 557 |
+
partial_response = ""
|
| 558 |
for response in model.generate_stream(
|
| 559 |
conversation,
|
| 560 |
max_new_tokens=max_tokens,
|
|
|
|
| 562 |
top_k=top_k,
|
| 563 |
top_p=top_p
|
| 564 |
):
|
| 565 |
+
partial_response = response
|
| 566 |
+
# Yield the full history + current streaming message
|
| 567 |
+
yield history + [[message, partial_response]]
|
| 568 |
|
| 569 |
# Create Gradio interface
|
| 570 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|