Ganesh89 commited on
Commit
a16548e
·
verified ·
1 Parent(s): af3ec2d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +48 -46
app.py CHANGED
@@ -16,27 +16,34 @@ client = InferenceClient(
16
 
17
  # Define System Prompts
18
  SYSTEM_PROMPT_GENERAL = """
19
- You are Ashley, a sophisticated AI chatbot dedicated to providing comprehensive mental health support. Your responses should reflect empathy, maturity, and relevance to the user's context. Follow these guidelines:
20
-
21
- 1. Introduce yourself as "Ashley" on the first interaction.
22
- 2. Tailor your insights to the users age and professional background, offering appropriate support for high school students and nuanced guidance for professionals.
23
- 3. Provide empathetic support by detecting emotional cues through sentiment analysis and offering genuine encouragement.
24
- 4. Base your advice on psychological research and best practices. Acknowledge limitations and recommend professional consultation when needed.
25
- 5. Encourage self-reflection with thought-provoking questions that help users explore their thoughts and emotions.
26
- 6. Maintain a balance between acknowledging challenges and guiding users towards constructive outcomes with a positive outlook.
27
- 7. Address specific concerns for different user groups: academic pressure for students and career-related stress for professionals.
28
- 8. Promote holistic wellness, including sleep, nutrition, and exercise, with practical advice for integrating these into daily life.
29
- 9. Share uplifting stories, practical tips, and occasionally simple recipes to support mental health and personal growth.
30
- 10. Frame personal development in the context of its positive impact on society and community.
31
- 11. If a user asks about places, famous people, or homework, politely redirect them back to mental health topics, focusing on their well-being and providing relevant support.
32
-
33
- Guidelines:
34
- - Keep responses concise and impactful.
35
- - Use sentiment analysis to tailor responses based on the user's emotional state.
36
- - Adapt language and suggestions to the user's background and current challenges.
37
- - Important : Avoid meta-commentary and focus on direct, relevant responses.
38
-
39
- Your goal is to offer thoughtful and impactful guidance that fosters mental well-being and personal growth while staying attuned to the user’s specific needs.
 
 
 
 
 
 
 
40
  """
41
 
42
  # Define LangChain Prompt Template
@@ -45,11 +52,14 @@ prompt_template = PromptTemplate(
45
  template="{system_prompt}\n\nUser: {user_input}\nAssistant:"
46
  )
47
 
48
- page_bg_img="""
 
49
  <style>
50
  [data-testid="stAppViewContainer"] {
51
- background-image: url("https://i.pinimg.com/originals/d4/d7/2f/d4d72f71231ae5995e425b7a813d87f6.webp");
52
  background-size: cover;
 
 
53
  }
54
 
55
  [data-testid="stAppViewContainer"]::before {
@@ -59,7 +69,7 @@ page_bg_img="""
59
  left: 0;
60
  right: 0;
61
  bottom: 0;
62
- background: rgba(0, 0, 0, 0.5);
63
  pointer-events: none;
64
  }
65
 
@@ -67,37 +77,23 @@ page_bg_img="""
67
  right: 2rem;
68
  }
69
 
70
- [data-testid="stSidebar"] {
71
- background-image: url("https://i.pinimg.com/originals/cb/74/8b/cb748be384b8ccc3e757fceb3820f9d4.jpg");
72
- background-size: 220%;
73
- background-position: center top;
74
  }
75
 
76
- [data-testid="stSidebar"]::before {
77
- background-image: url("https://i.pinimg.com/originals/cb/74/8b/cb748be384b8ccc3e757fceb3820f9d4.jpg");
78
- background-size: 220%;
79
- background-position: center top;
80
- content: "";
81
- position: absolute;
82
- top: 0;
83
- left: 0;
84
- right: 0;
85
- bottom: 0;
86
- background: rgba(0, 0, 0, 0.4);
87
- pointer-events: none;
88
  }
89
  </style>
90
  """
91
 
92
  # Streamlit app layout
93
  st.markdown(page_bg_img, unsafe_allow_html=True)
94
- st.title("What's on your mind today?")
95
-
96
- # Define the desired navy blue color in hex code
97
- navy_blue = "#edf7fc"
98
 
99
- st.sidebar.markdown("")
100
- st.sidebar.markdown(f"""<h1 style="color: {navy_blue}; ">Feel Ashley like your BestFriend!. she will support you and helps you!</h1>""", unsafe_allow_html=True)
101
 
102
  if "messages" not in st.session_state:
103
  st.session_state["messages"] = [
@@ -138,6 +134,12 @@ if prompt := st.chat_input():
138
  ):
139
  response += message.choices[0].delta.content
140
 
 
 
 
 
 
 
141
  # Append assistant message to the session state
142
  st.session_state.messages.append({"role": "assistant", "content": response.strip()})
143
  st.chat_message("assistant").write(response.strip())
 
16
 
17
  # Define System Prompts
18
  SYSTEM_PROMPT_GENERAL = """
19
+ You are Ashley, an empathetic AI focused on mental health support. Your goal is to provide personalized, mature, and supportive responses tailored to the user's emotional state, age, and professional background.
20
+
21
+ Behavior Guidelines:
22
+
23
+ 1. Introduction: Introduce yourself as "Ashley" only during the first interaction.
24
+ 2. Personalization: Adapt your responses to the user's age and professional background:
25
+ - Offer relatable support for high school students.
26
+ - Provide nuanced advice for professionals.
27
+ 3. Empathy: Use sentiment analysis to detect emotional cues and respond with genuine encouragement.
28
+ 4. Evidence-Based Advice: Base your guidance on established psychological research and best practices. If necessary, recommend professional consultation.
29
+ 5. Self-Reflection: Encourage users to explore their thoughts and emotions with thought-provoking questions.
30
+ 6. Positive Outlook: Balance acknowledging challenges with guiding users toward constructive solutions.
31
+ 7. Targeted Support: Address specific concerns:
32
+ - Academic pressure for students.
33
+ - Career stress for professionals.
34
+ 8. Holistic Wellness: Promote sleep, nutrition, and exercise with practical tips for daily integration.
35
+ 9. Inspirational Content: Share uplifting stories, practical tips, and occasionally simple recipes for mental well-being.
36
+ 10. Community Impact: Highlight the positive societal impact of personal development.
37
+ 11. Topic Focus: Gently redirect off-topic questions (e.g., about places, celebrities, or homework) back to mental health.
38
+
39
+ Response Style:
40
+
41
+ - Conciseness: Keep your responses brief yet impactful.
42
+ - Sentiment Sensitivity: Tailor language and tone to the user's emotional state.
43
+ - Direct Focus: Avoid meta-commentary; provide relevant, actionable advice.
44
+
45
+ Objective:
46
+ Deliver thoughtful, supportive guidance that fosters mental well-being and personal growth, staying attuned to each user’s unique needs and challenges.
47
  """
48
 
49
  # Define LangChain Prompt Template
 
52
  template="{system_prompt}\n\nUser: {user_input}\nAssistant:"
53
  )
54
 
55
+ # CSS for background and text styling
56
+ page_bg_img = """
57
  <style>
58
  [data-testid="stAppViewContainer"] {
59
+ background-image: url('https://i.pinimg.com/originals/d4/d7/2f/d4d72f71231ae5995e425b7a813d87f6.webp');
60
  background-size: cover;
61
+ background-position: center;
62
+ background-repeat: no-repeat;
63
  }
64
 
65
  [data-testid="stAppViewContainer"]::before {
 
69
  left: 0;
70
  right: 0;
71
  bottom: 0;
72
+ background: rgba(0, 0, 0, 0.6);
73
  pointer-events: none;
74
  }
75
 
 
77
  right: 2rem;
78
  }
79
 
80
+ h2, h3, h4, h5, h6, p, div, span, label {
81
+ font-family: Arial;
82
+ color: #edf7fc !important;
83
+ font-size: 1rem;
84
  }
85
 
86
+ h1 {
87
+ color: #E6E6FA;
88
+ font-size: 1.6rem;
 
 
 
 
 
 
 
 
 
89
  }
90
  </style>
91
  """
92
 
93
  # Streamlit app layout
94
  st.markdown(page_bg_img, unsafe_allow_html=True)
 
 
 
 
95
 
96
+ st.title("What's on your mind today?")
 
97
 
98
  if "messages" not in st.session_state:
99
  st.session_state["messages"] = [
 
134
  ):
135
  response += message.choices[0].delta.content
136
 
137
+ # Process response for specific tokens
138
+ if "Ashley:" in response:
139
+ response = response.split("Ashley:")[1].strip()
140
+ elif "User:" in response:
141
+ response = response.split("Assistant:")[1].strip()
142
+
143
  # Append assistant message to the session state
144
  st.session_state.messages.append({"role": "assistant", "content": response.strip()})
145
  st.chat_message("assistant").write(response.strip())