Spaces:
Sleeping
Sleeping
Commit ·
5f0033b
1
Parent(s): 68d4a44
Update space
Browse files
app.py
CHANGED
|
@@ -15,28 +15,26 @@ def respond(
|
|
| 15 |
temperature,
|
| 16 |
top_p,
|
| 17 |
):
|
| 18 |
-
|
| 19 |
-
|
| 20 |
for val in history:
|
| 21 |
if val[0]:
|
| 22 |
-
|
| 23 |
if val[1]:
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
messages.append({"role": "user", "content": message})
|
| 27 |
|
| 28 |
response = ""
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
|
|
|
| 33 |
stream=True,
|
| 34 |
temperature=temperature,
|
| 35 |
top_p=top_p,
|
| 36 |
):
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
response += token
|
| 40 |
yield response
|
| 41 |
|
| 42 |
|
|
|
|
| 15 |
temperature,
|
| 16 |
top_p,
|
| 17 |
):
|
| 18 |
+
# Format the conversation history into a prompt
|
| 19 |
+
prompt = f"{system_message}\n\n"
|
| 20 |
for val in history:
|
| 21 |
if val[0]:
|
| 22 |
+
prompt += f"User: {val[0]}\n"
|
| 23 |
if val[1]:
|
| 24 |
+
prompt += f"Assistant: {val[1]}\n"
|
| 25 |
+
prompt += f"User: {message}\nAssistant:"
|
|
|
|
| 26 |
|
| 27 |
response = ""
|
| 28 |
+
|
| 29 |
+
# Use text generation instead of chat completion
|
| 30 |
+
for message in client.text_generation(
|
| 31 |
+
prompt,
|
| 32 |
+
max_new_tokens=max_tokens,
|
| 33 |
stream=True,
|
| 34 |
temperature=temperature,
|
| 35 |
top_p=top_p,
|
| 36 |
):
|
| 37 |
+
response += message
|
|
|
|
|
|
|
| 38 |
yield response
|
| 39 |
|
| 40 |
|