neuralleap commited on
Commit
8a0ba03
Β·
verified Β·
1 Parent(s): 8cc3a3b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
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-GPT-v3 (Hosted Inference Endpoint)") as demo:
50
- gr.Markdown("## 🧠 Burmese GPT-3 Text Generator")
51
- gr.Markdown("This app connects to a Hugging Face Inference Endpoint to generate Burmese language text.\n\nJust enter a prompt in Burmese, adjust settings, and hit 'Generate Text'!")
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):