Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -16,27 +16,34 @@ client = InferenceClient(
|
|
16 |
|
17 |
# Define System Prompts
|
18 |
SYSTEM_PROMPT_GENERAL = """
|
19 |
-
You are Ashley,
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
-
|
|
|
49 |
<style>
|
50 |
[data-testid="stAppViewContainer"] {
|
51 |
-
background-image: url(
|
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.
|
63 |
pointer-events: none;
|
64 |
}
|
65 |
|
@@ -67,37 +77,23 @@ page_bg_img="""
|
|
67 |
right: 2rem;
|
68 |
}
|
69 |
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
}
|
75 |
|
76 |
-
|
77 |
-
|
78 |
-
|
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.
|
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())
|