Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,7 +3,6 @@ from huggingface_hub import InferenceClient
|
|
| 3 |
from transformers import pipeline
|
| 4 |
import random
|
| 5 |
import re
|
| 6 |
-
import os # <-- Added this to read your secret key
|
| 7 |
|
| 8 |
# ==========================================
|
| 9 |
# 1. LOAD LOCAL DIAGNOSIS MODEL
|
|
@@ -35,7 +34,7 @@ def respond(
|
|
| 35 |
max_tokens,
|
| 36 |
temperature,
|
| 37 |
top_p,
|
| 38 |
-
request: gr.Request,
|
| 39 |
):
|
| 40 |
user_name = "User"
|
| 41 |
if request:
|
|
@@ -45,13 +44,8 @@ def respond(
|
|
| 45 |
yield f"Hello {user_name}, I'm here to support your emotional well-being. How can I help you today?"
|
| 46 |
return
|
| 47 |
|
| 48 |
-
# <--
|
| 49 |
-
|
| 50 |
-
if not hf_api_key:
|
| 51 |
-
yield "System Error: The developer needs to set the HF_TOKEN secret in their Space settings."
|
| 52 |
-
return
|
| 53 |
-
|
| 54 |
-
client = InferenceClient(token=hf_api_key, model="HuggingFaceH4/zephyr-7b-beta")
|
| 55 |
|
| 56 |
mental_state = "Neutral"
|
| 57 |
if state_classifier:
|
|
@@ -99,7 +93,7 @@ def respond(
|
|
| 99 |
response += token
|
| 100 |
yield response
|
| 101 |
except Exception as e:
|
| 102 |
-
yield f"
|
| 103 |
|
| 104 |
# ==========================================
|
| 105 |
# 3. GRADIO UI DESIGN
|
|
@@ -107,7 +101,6 @@ def respond(
|
|
| 107 |
with gr.Blocks() as demo:
|
| 108 |
with gr.Sidebar():
|
| 109 |
gr.Markdown("## 🌿 Therapy Assistant")
|
| 110 |
-
# <-- REMOVED gr.LoginButton() completely!
|
| 111 |
gr.Markdown("---")
|
| 112 |
sys_msg = gr.Textbox(
|
| 113 |
value=(
|
|
|
|
| 3 |
from transformers import pipeline
|
| 4 |
import random
|
| 5 |
import re
|
|
|
|
| 6 |
|
| 7 |
# ==========================================
|
| 8 |
# 1. LOAD LOCAL DIAGNOSIS MODEL
|
|
|
|
| 34 |
max_tokens,
|
| 35 |
temperature,
|
| 36 |
top_p,
|
| 37 |
+
request: gr.Request,
|
| 38 |
):
|
| 39 |
user_name = "User"
|
| 40 |
if request:
|
|
|
|
| 44 |
yield f"Hello {user_name}, I'm here to support your emotional well-being. How can I help you today?"
|
| 45 |
return
|
| 46 |
|
| 47 |
+
# <-- COMPLETELY ANONYMOUS CALL! No token required.
|
| 48 |
+
client = InferenceClient(model="HuggingFaceH4/zephyr-7b-beta")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
mental_state = "Neutral"
|
| 51 |
if state_classifier:
|
|
|
|
| 93 |
response += token
|
| 94 |
yield response
|
| 95 |
except Exception as e:
|
| 96 |
+
yield f"Server is busy: {str(e)}. Please wait a few seconds and try again!"
|
| 97 |
|
| 98 |
# ==========================================
|
| 99 |
# 3. GRADIO UI DESIGN
|
|
|
|
| 101 |
with gr.Blocks() as demo:
|
| 102 |
with gr.Sidebar():
|
| 103 |
gr.Markdown("## 🌿 Therapy Assistant")
|
|
|
|
| 104 |
gr.Markdown("---")
|
| 105 |
sys_msg = gr.Textbox(
|
| 106 |
value=(
|