bugfix: streaming & examples
Browse files
app.py
CHANGED
@@ -32,9 +32,13 @@ def slow_api_response(message, history, property_id="c0ced2220b87fc23762facf6171
|
|
32 |
response_length = len(api_response)
|
33 |
sleep_time = total_time / response_length if response_length > 0 else total_time
|
34 |
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
|
|
38 |
|
39 |
except requests.RequestException as e:
|
40 |
yield f"Error: {str(e)}"
|
|
|
32 |
response_length = len(api_response)
|
33 |
sleep_time = total_time / response_length if response_length > 0 else total_time
|
34 |
|
35 |
+
if response_length > 3000:
|
36 |
+
yield api_response
|
37 |
+
|
38 |
+
else:
|
39 |
+
for i in range(response_length):
|
40 |
+
time.sleep(sleep_time)
|
41 |
+
yield api_response[:i + 1]
|
42 |
|
43 |
except requests.RequestException as e:
|
44 |
yield f"Error: {str(e)}"
|