Spaces:
Running
Running
bugfix catching errors
Browse files
app.py
CHANGED
@@ -60,19 +60,19 @@ def generate(
|
|
60 |
|
61 |
try:
|
62 |
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
except Exception as e:
|
64 |
raise gr.Error(f"Error while generating: {e}")
|
65 |
-
output = ""
|
66 |
-
|
67 |
-
for response in stream:
|
68 |
-
output += response.token.text
|
69 |
-
|
70 |
-
for stop_str in STOP_SEQUENCES:
|
71 |
-
if output.endswith(stop_str):
|
72 |
-
output = output[:-len(stop_str)]
|
73 |
-
output = output.rstrip()
|
74 |
-
yield output
|
75 |
-
yield output
|
76 |
return output
|
77 |
|
78 |
|
|
|
60 |
|
61 |
try:
|
62 |
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
63 |
+
output = ""
|
64 |
+
|
65 |
+
for response in stream:
|
66 |
+
output += response.token.text
|
67 |
+
|
68 |
+
for stop_str in STOP_SEQUENCES:
|
69 |
+
if output.endswith(stop_str):
|
70 |
+
output = output[:-len(stop_str)]
|
71 |
+
output = output.rstrip()
|
72 |
+
yield output
|
73 |
+
yield output
|
74 |
except Exception as e:
|
75 |
raise gr.Error(f"Error while generating: {e}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
return output
|
77 |
|
78 |
|