Spaces:
Sleeping
Sleeping
fixes
Browse files
app.py
CHANGED
|
@@ -25,20 +25,20 @@ def respond(
|
|
| 25 |
"top_p": top_p
|
| 26 |
}
|
| 27 |
)
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
else:
|
| 40 |
return f"Error: {output['error']['message']}. Refresh the page and try again later, post the error on OLAT forum if your issue persists."
|
| 41 |
-
|
|
|
|
| 42 |
|
| 43 |
demo = gr.Interface(
|
| 44 |
fn=respond,
|
|
|
|
| 25 |
"top_p": top_p
|
| 26 |
}
|
| 27 |
)
|
| 28 |
+
if response.status_code == 200:
|
| 29 |
+
return response.json()["choices"][0]["text"]
|
| 30 |
+
elif response.status_code == 429:
|
| 31 |
+
try:
|
| 32 |
+
output = response.json()
|
| 33 |
+
return f"Error: {output['error']['code']}. Try submit your request again in a few seconds."
|
| 34 |
+
except requests.exceptions.JSONDecodeError as e:
|
| 35 |
+
return f"Error: {response}. Refresh the page and try again later, post the error on OLAT forum if your issue persists."
|
| 36 |
+
else:
|
| 37 |
+
try:
|
| 38 |
+
output = response.json()
|
|
|
|
| 39 |
return f"Error: {output['error']['message']}. Refresh the page and try again later, post the error on OLAT forum if your issue persists."
|
| 40 |
+
except requests.exceptions.JSONDecodeError as e:
|
| 41 |
+
return f"Error: {response}. Refresh the page and try again later, post the error on OLAT forum if your issue persists."
|
| 42 |
|
| 43 |
demo = gr.Interface(
|
| 44 |
fn=respond,
|
te.ipynb
ADDED
|
File without changes
|