Spaces:
Sleeping
Sleeping
Convert to stream the response
Browse files
app.py
CHANGED
|
@@ -18,14 +18,19 @@ def analyze(project_data, question):
|
|
| 18 |
temperature=0.7,
|
| 19 |
top_p=0.95,
|
| 20 |
repetition_penalty=1.1,
|
| 21 |
-
do_sample=True
|
|
|
|
| 22 |
)
|
| 23 |
|
| 24 |
-
return response
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
except Exception as e:
|
| 27 |
print(f"Error details: {str(e)}")
|
| 28 |
-
|
| 29 |
|
| 30 |
iface = gr.Interface(
|
| 31 |
fn=analyze,
|
|
|
|
| 18 |
temperature=0.7,
|
| 19 |
top_p=0.95,
|
| 20 |
repetition_penalty=1.1,
|
| 21 |
+
do_sample=True,
|
| 22 |
+
stream=True
|
| 23 |
)
|
| 24 |
|
| 25 |
+
#return response
|
| 26 |
+
response_text = ""
|
| 27 |
+
for token in response_generator:
|
| 28 |
+
response_text += token.text
|
| 29 |
+
yeald response_text
|
| 30 |
|
| 31 |
except Exception as e:
|
| 32 |
print(f"Error details: {str(e)}")
|
| 33 |
+
yeald f"Error occurred: {str(e)}"
|
| 34 |
|
| 35 |
iface = gr.Interface(
|
| 36 |
fn=analyze,
|