Spaces:
Runtime error
Runtime error
dwfefef commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,14 +4,14 @@ from gradio_client import Client
|
|
| 4 |
client = Client("Shreyas094/WebSearchGPT")
|
| 5 |
|
| 6 |
@cl.on_chat_start
|
| 7 |
-
|
| 8 |
-
|
| 9 |
|
| 10 |
@cl.on_message
|
| 11 |
-
|
| 12 |
# Send a thinking message
|
| 13 |
thinking_msg = cl.Message(content="Thinking...")
|
| 14 |
-
|
| 15 |
|
| 16 |
# Make the API call
|
| 17 |
response = client.predict(
|
|
@@ -22,39 +22,48 @@ async def main(message: str):
|
|
| 22 |
)
|
| 23 |
|
| 24 |
# Remove the thinking message
|
| 25 |
-
|
| 26 |
|
| 27 |
# Send the response
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
@cl.
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
cl.
|
| 34 |
-
|
| 35 |
-
|
| 36 |
icon="π§ββοΈ",
|
|
|
|
|
|
|
|
|
|
| 37 |
),
|
| 38 |
-
cl.
|
| 39 |
-
|
| 40 |
-
|
| 41 |
icon="π΄",
|
|
|
|
|
|
|
|
|
|
| 42 |
),
|
| 43 |
-
cl.
|
| 44 |
-
|
| 45 |
-
|
| 46 |
icon="π°",
|
|
|
|
|
|
|
|
|
|
| 47 |
),
|
| 48 |
-
cl.
|
| 49 |
-
|
| 50 |
-
|
| 51 |
icon="π",
|
|
|
|
|
|
|
|
|
|
| 52 |
),
|
| 53 |
-
]
|
| 54 |
|
| 55 |
@cl.on_settings_update
|
| 56 |
-
|
| 57 |
-
print("Settings updated:", settings)
|
| 58 |
-
|
| 59 |
-
if __name__ == "__main__":
|
| 60 |
-
cl.run()
|
|
|
|
| 4 |
client = Client("Shreyas094/WebSearchGPT")
|
| 5 |
|
| 6 |
@cl.on_chat_start
|
| 7 |
+
def start():
|
| 8 |
+
cl.Message(content="Hello! I'm your mental health assistant. How can I support you today?").send()
|
| 9 |
|
| 10 |
@cl.on_message
|
| 11 |
+
def main(message: str):
|
| 12 |
# Send a thinking message
|
| 13 |
thinking_msg = cl.Message(content="Thinking...")
|
| 14 |
+
thinking_msg.send()
|
| 15 |
|
| 16 |
# Make the API call
|
| 17 |
response = client.predict(
|
|
|
|
| 22 |
)
|
| 23 |
|
| 24 |
# Remove the thinking message
|
| 25 |
+
thinking_msg.remove()
|
| 26 |
|
| 27 |
# Send the response
|
| 28 |
+
cl.Message(content=response).send()
|
| 29 |
+
|
| 30 |
+
@cl.on_chat_start
|
| 31 |
+
def set_starters():
|
| 32 |
+
cl.set_chat_profiles([
|
| 33 |
+
cl.ChatProfile(
|
| 34 |
+
name="Coping with stress",
|
| 35 |
+
description="Get strategies for dealing with stress",
|
| 36 |
icon="π§ββοΈ",
|
| 37 |
+
suggested_messages=[
|
| 38 |
+
"I'm feeling overwhelmed with stress lately. Can you suggest some coping strategies?"
|
| 39 |
+
],
|
| 40 |
),
|
| 41 |
+
cl.ChatProfile(
|
| 42 |
+
name="Improving sleep",
|
| 43 |
+
description="Tips for better sleep hygiene",
|
| 44 |
icon="π΄",
|
| 45 |
+
suggested_messages=[
|
| 46 |
+
"I've been having trouble sleeping. What are some tips for better sleep hygiene?"
|
| 47 |
+
],
|
| 48 |
),
|
| 49 |
+
cl.ChatProfile(
|
| 50 |
+
name="Managing anxiety",
|
| 51 |
+
description="Techniques to manage anxiety",
|
| 52 |
icon="π°",
|
| 53 |
+
suggested_messages=[
|
| 54 |
+
"I've been experiencing anxiety. What are some techniques to manage it?"
|
| 55 |
+
],
|
| 56 |
),
|
| 57 |
+
cl.ChatProfile(
|
| 58 |
+
name="Boosting mood",
|
| 59 |
+
description="Activities to improve your mood",
|
| 60 |
icon="π",
|
| 61 |
+
suggested_messages=[
|
| 62 |
+
"I've been feeling down lately. Can you suggest some activities to boost my mood?"
|
| 63 |
+
],
|
| 64 |
),
|
| 65 |
+
])
|
| 66 |
|
| 67 |
@cl.on_settings_update
|
| 68 |
+
def setup_agent(settings):
|
| 69 |
+
print("Settings updated:", settings)
|
|
|
|
|
|
|
|
|