Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
import os
|
2 |
import openai
|
3 |
-
from openai.error import InternalServerError # Import the error class
|
4 |
import torch
|
5 |
from transformers import pipeline
|
6 |
|
@@ -48,7 +47,6 @@ client = OpenAI(
|
|
48 |
|
49 |
# return "".join(full_response)
|
50 |
|
51 |
-
|
52 |
def generate_llm_response(text, model_id="ccibeekeoc42/Llama3.1-8b-base-SFT-2024-11-09"):
|
53 |
full_response = []
|
54 |
try:
|
@@ -71,9 +69,12 @@ def generate_llm_response(text, model_id="ccibeekeoc42/Llama3.1-8b-base-SFT-2024
|
|
71 |
if chunk.choices[0].delta.content:
|
72 |
full_response.append(chunk.choices[0].delta.content)
|
73 |
return "".join(full_response)
|
74 |
-
except
|
75 |
-
#
|
76 |
-
|
|
|
|
|
|
|
77 |
|
78 |
generate_llm_response("Explain Deep Learning in Igbo")
|
79 |
|
|
|
1 |
import os
|
2 |
import openai
|
|
|
3 |
import torch
|
4 |
from transformers import pipeline
|
5 |
|
|
|
47 |
|
48 |
# return "".join(full_response)
|
49 |
|
|
|
50 |
def generate_llm_response(text, model_id="ccibeekeoc42/Llama3.1-8b-base-SFT-2024-11-09"):
|
51 |
full_response = []
|
52 |
try:
|
|
|
69 |
if chunk.choices[0].delta.content:
|
70 |
full_response.append(chunk.choices[0].delta.content)
|
71 |
return "".join(full_response)
|
72 |
+
except Exception as e:
|
73 |
+
# If the error has a response with status code 503, assume the GPU is booting up.
|
74 |
+
if hasattr(e, 'response') and e.response is not None and e.response.status_code == 503:
|
75 |
+
return "The GPU is currently booting up. Please wait about 10 minutes and try again."
|
76 |
+
else:
|
77 |
+
raise e
|
78 |
|
79 |
generate_llm_response("Explain Deep Learning in Igbo")
|
80 |
|