Phoenix21 commited on
Commit
b3d8117
·
verified ·
1 Parent(s): eefbdd1

Create chain_recommendations.py

Browse files
Files changed (1) hide show
  1. chain_recommendations.py +25 -0
chain_recommendations.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # chain_recommendations.py
2
+ import json
3
+ from typing import Dict
4
+ from langchain import PromptTemplate, LLMChain
5
+ from models import chat_model
6
+
7
+ recommend_prompt_template = PromptTemplate(
8
+ input_variables=["problems"],
9
+ template=(
10
+ "Given the following problem severity percentages:\n"
11
+ "{problems}\n\n"
12
+ "Using these rules:\n"
13
+ "- If sleep_problem > 70: Recommend Sleep Improvement Package\n"
14
+ "- If stress_problem > 70: Recommend Stress Reduction Package\n"
15
+ "- If exercise_problem > 70: Recommend Exercise Enhancement Package\n"
16
+ "- If all problems are between 30 and 70: Recommend Balanced Wellness Package\n"
17
+ "- If no severe problems: Recommend General Wellness Package\n\n"
18
+ "What are the recommended wellness packages?"
19
+ )
20
+ )
21
+ recommend_chain = LLMChain(llm=chat_model, prompt=recommend_prompt_template)
22
+
23
+ def generate_recommendations(problems: Dict[str, float]) -> str:
24
+ recommendations = recommend_chain.run(problems=json.dumps(problems))
25
+ return recommendations.strip()