Arjun Singh commited on
Commit ·
20d3b15
1
Parent(s): 4968d52
Added a condition to do nothing if no error
Browse files
app.py
CHANGED
|
@@ -17,10 +17,12 @@ def chat_with_Mixtral(prompt, hugging_face_api_key):
|
|
| 17 |
tokens += token
|
| 18 |
yield tokens
|
| 19 |
except HfHubHTTPError as e:
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
| 24 |
|
| 25 |
def clear_fields():
|
| 26 |
return "", "" # Clear prompt and output, but not the API key
|
|
|
|
| 17 |
tokens += token
|
| 18 |
yield tokens
|
| 19 |
except HfHubHTTPError as e:
|
| 20 |
+
error_message = str(e).strip()
|
| 21 |
+
if error_message:
|
| 22 |
+
if "Authorization header is correct, but the token seems invalid" in error_message:
|
| 23 |
+
yield "Error: Invalid API token. Please check your Hugging Face API key."
|
| 24 |
+
else:
|
| 25 |
+
yield f"Error: An API error occurred - {error_message}"
|
| 26 |
|
| 27 |
def clear_fields():
|
| 28 |
return "", "" # Clear prompt and output, but not the API key
|