Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,11 +5,7 @@ import requests
|
|
5 |
# --------------------------
|
6 |
# Configuration
|
7 |
# --------------------------
|
8 |
-
|
9 |
-
# β
Your actual Inference Endpoint URL
|
10 |
HF_ENDPOINT_URL = "https://dqptyla9qxd15452.us-east-1.aws.endpoints.huggingface.cloud"
|
11 |
-
|
12 |
-
# β
Your token securely accessed via Hugging Face Secrets
|
13 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
14 |
|
15 |
headers = {
|
@@ -38,6 +34,10 @@ def generate_text(prompt, max_length=150, temperature=0.7):
|
|
38 |
return response.json()[0]["generated_text"]
|
39 |
elif response.status_code == 404:
|
40 |
return "β Endpoint not found. Please check your HF_ENDPOINT_URL."
|
|
|
|
|
|
|
|
|
41 |
else:
|
42 |
return f"β Error {response.status_code}: {response.text}"
|
43 |
except Exception as e:
|
@@ -46,9 +46,9 @@ def generate_text(prompt, max_length=150, temperature=0.7):
|
|
46 |
# --------------------------
|
47 |
# Gradio UI
|
48 |
# --------------------------
|
49 |
-
with gr.Blocks(title="Burmese
|
50 |
-
gr.Markdown("## π§ Burmese
|
51 |
-
gr.Markdown("This app connects to a Hugging Face Inference Endpoint to generate Burmese language text.\n\
|
52 |
|
53 |
with gr.Row():
|
54 |
with gr.Column(scale=3):
|
|
|
5 |
# --------------------------
|
6 |
# Configuration
|
7 |
# --------------------------
|
|
|
|
|
8 |
HF_ENDPOINT_URL = "https://dqptyla9qxd15452.us-east-1.aws.endpoints.huggingface.cloud"
|
|
|
|
|
9 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
10 |
|
11 |
headers = {
|
|
|
34 |
return response.json()[0]["generated_text"]
|
35 |
elif response.status_code == 404:
|
36 |
return "β Endpoint not found. Please check your HF_ENDPOINT_URL."
|
37 |
+
elif response.status_code == 403:
|
38 |
+
return "β Forbidden: Check your HF_TOKEN permissions."
|
39 |
+
elif response.status_code == 503:
|
40 |
+
return "β Service Unavailable: The endpoint may be starting up. Please wait and try again."
|
41 |
else:
|
42 |
return f"β Error {response.status_code}: {response.text}"
|
43 |
except Exception as e:
|
|
|
46 |
# --------------------------
|
47 |
# Gradio UI
|
48 |
# --------------------------
|
49 |
+
with gr.Blocks(title="Healthelic Burmese LLM (Hosted Inference Endpoint)") as demo:
|
50 |
+
gr.Markdown("## π§ Healthelic Burmese LLM")
|
51 |
+
gr.Markdown("This app connects to a Hugging Face Inference Endpoint to generate Burmese language text.\n\nEnter a prompt in Burmese, adjust settings, and click 'Generate Text'.")
|
52 |
|
53 |
with gr.Row():
|
54 |
with gr.Column(scale=3):
|