Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -58,6 +58,9 @@ def generate(
|
|
58 |
)
|
59 |
seed = seed + 1
|
60 |
formatted_prompt = format_prompt(prompt, history, system_prompt)
|
|
|
|
|
|
|
61 |
|
62 |
try:
|
63 |
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
@@ -73,22 +76,7 @@ def generate(
|
|
73 |
yield output
|
74 |
yield output
|
75 |
except Exception as e:
|
76 |
-
raise gr.Error(f"Client
|
77 |
-
try:
|
78 |
-
stream = client2.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
79 |
-
output = ""
|
80 |
-
|
81 |
-
for response in stream:
|
82 |
-
output += response.token.text
|
83 |
-
|
84 |
-
for stop_str in STOP_SEQUENCES:
|
85 |
-
if output.endswith(stop_str):
|
86 |
-
output = output[:-len(stop_str)]
|
87 |
-
# output = output.rstrip()
|
88 |
-
yield output
|
89 |
-
yield output
|
90 |
-
except Exception as e:
|
91 |
-
raise gr.Error(f"Client 2 error while generating: {e}")
|
92 |
return output
|
93 |
|
94 |
additional_inputs=[
|
|
|
58 |
)
|
59 |
seed = seed + 1
|
60 |
formatted_prompt = format_prompt(prompt, history, system_prompt)
|
61 |
+
status = client.get_model_status()
|
62 |
+
if not status.loaded:
|
63 |
+
client = client2
|
64 |
|
65 |
try:
|
66 |
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
|
|
76 |
yield output
|
77 |
yield output
|
78 |
except Exception as e:
|
79 |
+
raise gr.Error(f"Client error while generating: {e}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
return output
|
81 |
|
82 |
additional_inputs=[
|