Update space
Browse files
app.py
CHANGED
@@ -27,17 +27,20 @@ def respond(
|
|
27 |
|
28 |
response = ""
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
41 |
|
42 |
|
43 |
"""
|
|
|
27 |
|
28 |
response = ""
|
29 |
|
30 |
+
try:
|
31 |
+
for chunk in client.chat_completion(
|
32 |
+
messages,
|
33 |
+
max_tokens=max_tokens,
|
34 |
+
stream=True,
|
35 |
+
temperature=temperature,
|
36 |
+
top_p=top_p,
|
37 |
+
):
|
38 |
+
# The API returns the text directly in streaming mode
|
39 |
+
if chunk:
|
40 |
+
response += chunk
|
41 |
+
yield response
|
42 |
+
except Exception as e:
|
43 |
+
yield f"Error: {str(e)}"
|
44 |
|
45 |
|
46 |
"""
|