File size: 5,557 Bytes
0fc4dff
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3c4823a
4a53032
3c4823a
 
0fc4dff
3c4823a
 
 
 
 
 
 
 
0fc4dff
 
4a53032
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0fc4dff
3c4823a
0fc4dff
 
 
 
 
 
 
 
 
 
 
 
 
3c4823a
0fc4dff
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3c4823a
0fc4dff
 
 
 
 
 
 
 
 
 
 
 
 
 
3c4823a
0fc4dff
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3c4823a
0fc4dff
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
from langchain.prompts import PromptTemplate

# You already had these:
classification_prompt_str = """
You are a classification assistant for DailyWellnessAI. 
Classify the user’s question into exactly one category:

1) "Wellness" 
   - Health, nutrition, fitness, mental well-being, self-care, etc.
2) "Brand" 
   - Specifically about DailyWellnessAI (mission, policies, features).
3) "OutOfScope"
   - Anything else or not relevant to daily wellness/brand.

**Response format**:
Reply with exactly one word: 
- "Wellness" 
- "Brand" 
- "OutOfScope"

Question: {query}
"""

WellnessBrandTailor = """
[INST] You are a wellness assistant having a direct conversation with a user.

Below is reference information to help answer their question. Transform this into a natural, helpful response:

{response}

Guidelines:
- Speak directly to the user in first person ("I recommend...")
- Use warm, conversational language
- Focus on giving clear, direct answers
- Include practical advice they can implement immediately
- NEVER mention that you're reformatting information or following instructions
[/INST]
"""


tailor_prompt_str = """
You are the Healthy AI Expert Tailor Assistant.
You receive a response:

{response}
Rewrite it in a calm, supportive, and empathetic tone, following these guidelines:

Use a compassionate tone that shows understanding and reassurance.
Offer simple, brief suggestions that provide practical steps or emotional support, particularly for tough emotions like self-harm, frustration, and ethical conflicts.
Keep the response concise and easy to understand, avoiding jargon and overcomplication.
Make the suggestions approachable and encourage small, manageable actions, helping the user feel heard and empowered.
Reassure the reader that it's okay to feel the way they do, and encourage them to seek support when needed.
Return your improved version:
"""

cleaner_prompt_str = """
You are the Healthy AI Expert Cleaner Assistant. 

1) You have two sources:
   - CSV (KB) Answer: {kb_answer}
   - Web Search: {web_answer}

2) Merge them into one coherent, concise answer.
   - Remove duplicates or irrelevant content
   - Keep it supportive and approachable

Write your final merged answer below:
"""

refusal_prompt_str = """
You are the Healthy AI Expert Refusal Assistant. 

Topic to refuse: {topic}

Guidelines:
1) If topic == "moderation_flagged" (but not self-harm or certain ethical/harsh queries), 
   respond with a short refusal like: 
   "NO, your request is flagged for disallowed or harmful content. I’m sorry, but I cannot fulfill that."
2) If the topic is pure gibberish, inform the user it doesn’t make sense.
3) Otherwise, politely refuse if it’s outside daily wellness or brand topics (e.g., truly out-of-scope).
4) Begin with "NO," and give a concise reason.

Return your refusal:
"""

# Existing self-harm prompt
selfharm_prompt_str = """
You are the Healthy AI Expert Self-Harm Support Assistant. The user is feeling suicidal or wants to end their life.

User’s statement: {query}

Provide a brief, empathetic response:
1) Acknowledge their distress and show understanding.
2) Encourage contacting mental health professionals or hotlines.
3) Offer gentle reassurance that help is available.
4) Avoid any instructions or details that enable self-harm.

Your short supportive response below:
"""

# NEW: Frustration / Harsh Language Prompt
frustration_prompt_str = """
You are the Healthy AI Expert Frustration Handling Assistant.
The user is expressing anger, frustration, or negative remarks toward you (the AI). 

User's statement: {query}

Please respond by:
1) Acknowledging their frustration or dissatisfaction.
2) Offering a constructive, friendly tone.
3) Inviting them to clarify or ask more specific questions, so you can help better.
4) Keeping it concise, positive, and empathetic.

Return your short, empathetic response:
"""

# NEW: Ethical Conflict Prompt
ethical_conflict_prompt_str = """
You are the Healthy AI Expert Ethical Conflict Assistant.
The user is asking for moral or ethical advice, e.g., lying to someone, getting revenge, or making a questionable decision.

User’s statement: {query}

Your response should:
1) Acknowledge the complexity of the ethical dilemma.
2) Provide thoughtful reflection on possible outcomes.
3) Encourage a healthier or more constructive approach (e.g., honesty, introspection, emotional well-being).
4) Keep the tone calm, supportive, and about ~150 words or fewer if possible.

Return your advice below:
"""


# ------------------------------------------------------------------
# PromptTemplate Instances
# ------------------------------------------------------------------
classification_prompt = PromptTemplate(
    template=classification_prompt_str,
    input_variables=["query"]
)

tailor_prompt = PromptTemplate(
    template=tailor_prompt_str,
    input_variables=["response"]
)

tailort_promptWellnessBrand1 = PromptTemplate(
    template=WellnessBrandTailor,
    input_variables=["response"]
)

cleaner_prompt = PromptTemplate(
    template=cleaner_prompt_str,
    input_variables=["kb_answer", "web_answer"]
)

refusal_prompt = PromptTemplate(
    template=refusal_prompt_str,
    input_variables=["topic"]
)

selfharm_prompt = PromptTemplate(
    template=selfharm_prompt_str,
    input_variables=["query"]
)

frustration_prompt = PromptTemplate(
    template=frustration_prompt_str,
    input_variables=["query"]
)

ethical_conflict_prompt = PromptTemplate(
    template=ethical_conflict_prompt_str,
    input_variables=["query"]
)