Spaces:
Sleeping
Sleeping
Update lifestyle_agent.py
Browse files- lifestyle_agent.py +11 -18
lifestyle_agent.py
CHANGED
@@ -1,18 +1,11 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
return "Ensure you get at least 7-8 hours of sleep each night. Avoid caffeine and screen time before bedtime."
|
13 |
-
|
14 |
-
def get_diet_tips():
|
15 |
-
return "Eat a balanced diet with plenty of vegetables, fruits, and whole grains. Avoid high-sugar and high-fat foods."
|
16 |
-
|
17 |
-
def get_general_suggestions():
|
18 |
-
return "It is important to maintain a balanced lifestyle: Eat healthy, stay active, and manage stress effectively."
|
|
|
1 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
2 |
+
import torch
|
3 |
+
|
4 |
+
def get_lifestyle_tips(lifestyle_query):
|
5 |
+
model_name = "m42-health/med42-70b"
|
6 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
7 |
+
model = AutoModelForCausalLM.from_pretrained(model_name)
|
8 |
+
prompt = f"Give healthy lifestyle tips based on the query: {lifestyle_query}."
|
9 |
+
inputs = tokenizer(prompt, return_tensors="pt")
|
10 |
+
outputs = model.generate(**inputs, max_new_tokens=150)
|
11 |
+
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|