dwfefef commited on
Commit
fad95a0
Β·
verified Β·
1 Parent(s): 9917aa0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -28
app.py CHANGED
@@ -4,14 +4,14 @@ from gradio_client import Client
4
  client = Client("Shreyas094/WebSearchGPT")
5
 
6
  @cl.on_chat_start
7
- async def start():
8
- await cl.Message(content="Hello! I'm your mental health assistant. How can I support you today?").send()
9
 
10
  @cl.on_message
11
- async def main(message: str):
12
  # Send a thinking message
13
  thinking_msg = cl.Message(content="Thinking...")
14
- await thinking_msg.send()
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
- await thinking_msg.remove()
26
 
27
  # Send the response
28
- await cl.Message(content=response).send()
29
-
30
- @cl.set_starters
31
- async def set_starters():
32
- return [
33
- cl.Starter(
34
- label="Coping with stress",
35
- message="I'm feeling overwhelmed with stress lately. Can you suggest some coping strategies?",
36
  icon="πŸ§˜β€β™€οΈ",
 
 
 
37
  ),
38
- cl.Starter(
39
- label="Improving sleep",
40
- message="I've been having trouble sleeping. What are some tips for better sleep hygiene?",
41
  icon="😴",
 
 
 
42
  ),
43
- cl.Starter(
44
- label="Managing anxiety",
45
- message="I've been experiencing anxiety. What are some techniques to manage it?",
46
  icon="😰",
 
 
 
47
  ),
48
- cl.Starter(
49
- label="Boosting mood",
50
- message="I've been feeling down lately. Can you suggest some activities to boost my mood?",
51
  icon="😊",
 
 
 
52
  ),
53
- ]
54
 
55
  @cl.on_settings_update
56
- async def setup_agent(settings):
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)