Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -27,23 +27,23 @@ def respond(
|
|
27 |
system_message,
|
28 |
):
|
29 |
try:
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
except Exception as e:
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
|
48 |
def clear_conversation():
|
49 |
return []
|
|
|
27 |
system_message,
|
28 |
):
|
29 |
try:
|
30 |
+
stream = client.chat_completion(
|
31 |
+
messages,
|
32 |
+
max_tokens=max_tokens,
|
33 |
+
temperature=temperature,
|
34 |
+
top_p=top_p,
|
35 |
+
stream=True,
|
36 |
+
)
|
37 |
+
partial_message = ""
|
38 |
+
for response in stream:
|
39 |
+
if response.choices[0].delta.content is not None:
|
40 |
+
partial_message += response.choices[0].delta.content
|
41 |
+
chat_history = chat_history[:-1] + [(message, partial_message)]
|
42 |
+
yield chat_history
|
43 |
+
except Exception as e:
|
44 |
+
error_message = f"An error occurred: {str(e)}"
|
45 |
+
chat_history.append((message, error_message))
|
46 |
+
yield chat_history
|
47 |
|
48 |
def clear_conversation():
|
49 |
return []
|