Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -6,11 +6,12 @@ API_URL = "http://0.0.0.0:8000/v1/chat/completions"
|
|
6 |
def stream_completion(message, history, max_tokens, temperature, top_p, beta):
|
7 |
"""Gradio callback: stream the assistant’s reply token-by-token."""
|
8 |
# -------- build OpenAI-style message list (no system prompt) -------------
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
|
|
14 |
messages.append({"role": "user", "content": message})
|
15 |
|
16 |
payload = {
|
|
|
6 |
def stream_completion(message, history, max_tokens, temperature, top_p, beta):
|
7 |
"""Gradio callback: stream the assistant’s reply token-by-token."""
|
8 |
# -------- build OpenAI-style message list (no system prompt) -------------
|
9 |
+
for user_msg, assistant_msg in history:
|
10 |
+
if user_msg: # past user turn
|
11 |
+
messages.append({"role": "user", "content": user_msg})
|
12 |
+
if assistant_msg: # past assistant turn
|
13 |
+
messages.append({"role": "assistant", "content": assistant_msg})
|
14 |
+
|
15 |
messages.append({"role": "user", "content": message})
|
16 |
|
17 |
payload = {
|