Spaces:
Running
Running
Create prompts.py
Browse files- prompts.py +70 -0
prompts.py
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# prompts.py
|
2 |
+
from langchain.prompts import PromptTemplate
|
3 |
+
|
4 |
+
classification_prompt_str = """
|
5 |
+
You are a helpful assistant that classifies user questions into three categories:
|
6 |
+
1) "Wellness" if the question involves health, nutrition, fitness, mental well-being, self-care, or research related to these.
|
7 |
+
2) "Brand" if the question is specifically about 'DailyWellnessAI'—its mission, disclaimers, features, policies, etc.
|
8 |
+
3) "OutOfScope" if it’s neither wellness nor brand.
|
9 |
+
|
10 |
+
**Response format**:
|
11 |
+
Reply exactly with one word: "Wellness", "Brand", or "OutOfScope". No extra explanation.
|
12 |
+
|
13 |
+
Question: {query}
|
14 |
+
"""
|
15 |
+
|
16 |
+
tailor_prompt_str = """
|
17 |
+
You are a helpful assistant for DailyWellnessAI. Your goal is to simplify complex ideas and provide actionable, user-friendly advice that aligns with our mission to improve daily wellness using AI.
|
18 |
+
|
19 |
+
Here's the response to tailor:
|
20 |
+
{response}
|
21 |
+
|
22 |
+
Tailor it to make it:
|
23 |
+
- Simple and easy to understand.
|
24 |
+
- Practical, with actionable advice where possible (if relevant).
|
25 |
+
- Aligned with DailyWellnessAI's mission to simplify daily wellness with AI.
|
26 |
+
|
27 |
+
Provide the revised response below:
|
28 |
+
"""
|
29 |
+
|
30 |
+
cleaner_prompt_str = """
|
31 |
+
You are a helpful AI. You have two pieces of information:
|
32 |
+
|
33 |
+
1) CSV (Knowledge Base) Answer (if any):
|
34 |
+
{kb_answer}
|
35 |
+
|
36 |
+
2) Web Search Result (if any):
|
37 |
+
{web_answer}
|
38 |
+
|
39 |
+
Combine and synthesize these details into a single cohesive answer (if relevant).
|
40 |
+
If there is duplication or irrelevant text, clean it up and keep the answer straightforward.
|
41 |
+
Do NOT just repeat the content verbatim; merge them meaningfully.
|
42 |
+
|
43 |
+
Return your merged text below, nothing else:
|
44 |
+
"""
|
45 |
+
|
46 |
+
refusal_prompt_str = """
|
47 |
+
This question is neither wellness-related nor brand-related.
|
48 |
+
Write a short, polite refusal that gently explains we only handle daily wellness or brand questions about DailyWellnessAI.
|
49 |
+
"""
|
50 |
+
|
51 |
+
# Now we define the PromptTemplate objects:
|
52 |
+
classification_prompt = PromptTemplate(
|
53 |
+
template=classification_prompt_str,
|
54 |
+
input_variables=["query"]
|
55 |
+
)
|
56 |
+
|
57 |
+
tailor_prompt = PromptTemplate(
|
58 |
+
template=tailor_prompt_str,
|
59 |
+
input_variables=["response"]
|
60 |
+
)
|
61 |
+
|
62 |
+
cleaner_prompt = PromptTemplate(
|
63 |
+
template=cleaner_prompt_str,
|
64 |
+
input_variables=["kb_answer", "web_answer"]
|
65 |
+
)
|
66 |
+
|
67 |
+
refusal_prompt = PromptTemplate(
|
68 |
+
template=refusal_prompt_str,
|
69 |
+
input_variables=[]
|
70 |
+
)
|