Spaces:
Sleeping
Sleeping
Update helper.py
Browse files
helper.py
CHANGED
@@ -41,8 +41,13 @@ def get_fn(model_name: str, **model_kwargs):
|
|
41 |
stream=True,
|
42 |
response_format={"type": "text"},
|
43 |
)
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
46 |
except Exception as e:
|
47 |
print(f"Error during generation: {str(e)}")
|
48 |
yield f"An error occurred: {str(e)}"
|
|
|
41 |
stream=True,
|
42 |
response_format={"type": "text"},
|
43 |
)
|
44 |
+
|
45 |
+
response_text = ""
|
46 |
+
for chunk in response:
|
47 |
+
chunk_message = chunk.choices[0].delta.content
|
48 |
+
if chunk_message:
|
49 |
+
response_text += chunk_message
|
50 |
+
yield assistant_message.strip()
|
51 |
except Exception as e:
|
52 |
print(f"Error during generation: {str(e)}")
|
53 |
yield f"An error occurred: {str(e)}"
|