Safwanahmad619 commited on
Commit
30b4c50
·
verified ·
1 Parent(s): aafbd05

Upload 3 files

Browse files
Files changed (3) hide show
  1. How to create.txt +8 -0
  2. main.py +121 -0
  3. requirements.txt +3 -0
How to create.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ make an virtual environment
2
+ install:
3
+ navigate the folder which is being to used->by cd drive/folder
4
+ python -m venv env
5
+ activate:
6
+ env\Scripts\activate
7
+
8
+ custom meal suggestion
main.py ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import anthropic
3
+
4
+ api_key = st.secrets["my-key"]
5
+
6
+ # Function to call Claude AI API and get a personalized meal plan
7
+ def get_meal_plan(api_key, fasting_sugar, pre_meal_sugar, post_meal_sugar, dietary_preferences):
8
+ # Initialize the Claude AI client with the provided API key
9
+ client = anthropic.Anthropic(api_key=api_key)
10
+
11
+ # Define the prompt to send to Claude AI
12
+ prompt = (
13
+ f"My fasting sugar level is {fasting_sugar} mg/dL, "
14
+ f"my pre-meal sugar level is {pre_meal_sugar} mg/dL, "
15
+ f"and my post-meal sugar level is {post_meal_sugar} mg/dL. "
16
+ f"My dietary preferences are {dietary_preferences}. "
17
+ "Please provide a personalized meal plan that can help me manage my blood sugar levels effectively."
18
+ )
19
+
20
+ # Call Claude AI API
21
+ message = client.messages.create(
22
+ model="claude-3-5-sonnet-20240620",
23
+ max_tokens=250,
24
+ temperature=0.7,
25
+ system="You are a world-class nutritionist who specializes in diabetes management.",
26
+ messages=[
27
+ {
28
+ "role": "user",
29
+ "content": prompt
30
+ }
31
+ ]
32
+ )
33
+
34
+ raw_context = message.content
35
+ itinerary = raw_context[0].text
36
+ return itinerary
37
+
38
+ # Streamlit app
39
+ st.title("Glucose Guardian")
40
+
41
+ st.write("""
42
+ **Glucose Guardian** is a personalized meal planning tool designed specifically for diabetic patients.
43
+ By entering your sugar levels and dietary preferences, Glucose Guardian generates meal plans that are
44
+ tailored to help you manage your blood sugar levels effectively.
45
+ """)
46
+
47
+ # Sidebar inputs for sugar levels and dietary preferences
48
+ st.sidebar.header("Enter Your Details")
49
+
50
+ fasting_sugar = st.sidebar.number_input("Fasting Sugar Levels (mg/dL)", min_value=0, max_value=500, step=1)
51
+ pre_meal_sugar = st.sidebar.number_input("Pre-Meal Sugar Levels (mg/dL)", min_value=0, max_value=500, step=1)
52
+ post_meal_sugar = st.sidebar.number_input("Post-Meal Sugar Levels (mg/dL)", min_value=0, max_value=500, step=1)
53
+
54
+ dietary_preferences = st.sidebar.text_input("Dietary Preferences (e.g., vegetarian, low-carb)")
55
+
56
+ # Generate meal plan button
57
+ if st.sidebar.button("Generate Meal Plan"):
58
+ meal_plan = get_meal_plan(api_key, fasting_sugar, pre_meal_sugar, post_meal_sugar, dietary_preferences)
59
+ st.write("Based on your sugar levels and dietary preferences, here is a personalized meal plan:")
60
+ st.markdown(meal_plan)
61
+
62
+ # import streamlit as st
63
+ # import anthropic
64
+ # import os
65
+
66
+ # # Load the API key from Hugging Face secrets
67
+
68
+ # # client = anthropic.Anthropic(api_key=api_key)
69
+ # api_key="key"
70
+ # def meal_plan_generate(fasting_sugar_level, pre_meal_sugar, post_meal_sugar, dietary_preferences):
71
+ # message = client.messages.create(
72
+ # model="claude-3-opus-20240229",
73
+ # max_tokens=250,
74
+ # temperature=0.2,
75
+ # system=f"You are a helpful medical assistant that takes the sugar levels of diabetic patient as input and recommends them food and recipes to eat in that day according to their sugar levels. Based on the users {fasting_sugar_level} and {pre_meal_sugar} and {post_meal_sugar}. Also take in accordance the dietary preferences which are {dietary_preferences}",
76
+ # messages=[
77
+ # {
78
+ # "role": "user",
79
+ # "content": [
80
+ # {
81
+ # "type": "text",
82
+ # "text": f"Task: recommend me to eat some food recipes based on my {fasting_sugar_level}, {pre_meal_sugar}, and {post_meal_sugar}. Also take into consideration my dietary preferences which are {dietary_preferences}\n\nConsiderations:\nConsider the user's fasting, pre-meal, and post-meal sugar levels.\nTake into account the user's dietary preferences.\nIncorporate the user's health goals into the recommendations.\nEnsure nutritional balance in the suggested food options.\nConsider portion sizes and provide personalized recommendations.\n"
83
+ # }
84
+ # ]
85
+ # }
86
+ # ]
87
+ # )
88
+
89
+ # raw_context = message.content
90
+ # itinerary = raw_context[0].text
91
+ # return itinerary
92
+
93
+ # def main():
94
+ # st.set_page_config(page_title="Glucose Guardian", layout="wide")
95
+ # st.title("Glucose Guardian")
96
+ # st.markdown("*Glucose Guardian* is an innovative app designed to help you maintain a healthy lifestyle by providing personalized meal suggestions based on your sugar levels. Whether you are managing diabetes or simply aiming to improve your overall well-being, Gluco Guide is here to support you on your journey.")
97
+
98
+ # with st.container():
99
+ # st.subheader("How to Use")
100
+ # st.write("To get started with Gluco Guide, simply input your sugar levels using a glucose monitoring device or manually enter the readings. You can specify whether your sugar levels are fasting, pre-meal, or post-meal measurements. Additionally, the app allows you to provide information about your dietary preferences, such as vegetarian, vegan, or specific dietary restrictions.")
101
+ # st.write("Based on this information, Gluco Guide will generate meal recommendations that align with your dietary preferences, ensuring a balanced and enjoyable eating experience. Experience the convenience of having a personal health coach in your pocket with Gluco Guide. Take control of your health and make informed choices to achieve your wellness goals.")
102
+ # st.warning(":warning: Disclaimer: Gluco Guide's AI-generated meal suggestions are intended to support your health journey, but always consult with healthcare professionals for personalized medical advice and guidance regarding your specific condition and dietary needs.")
103
+
104
+ # with st.sidebar:
105
+ # st.header("Controls")
106
+ # st.write("Please provide your sugar levels and dietary preferences below to receive personalized meal suggestions tailored to your needs")
107
+ # sugar_level_before_fasting = st.text_area("Fasting: Measure your sugar level before having any food or drinks in the morning, typically after an overnight fast.", height=20)
108
+ # sugar_level_after_fasting = st.text_area("Pre-Meal: Measure your sugar level before a meal, ideally around 1-2 hours prior to eating.", height=20)
109
+ # sugar_level_post_meal = st.text_area("Post-Meal: Measure your sugar level after a meal, typically around 1-2 hours after finishing your meal.", height=20)
110
+ # dietary_preferences = st.text_area("Provide information about your dietary preferences, such as vegetarian, vegan, or specific dietary restrictions.", height=20)
111
+
112
+ # generate_plan_btn = st.button("Generate Meal Plan")
113
+
114
+ # if generate_plan_btn and sugar_level_after_fasting and sugar_level_before_fasting and dietary_preferences:
115
+ # with st.spinner("Creating a Meal Plan..."):
116
+ # generated_mealplan = meal_plan_generate(sugar_level_before_fasting, sugar_level_after_fasting, sugar_level_post_meal, dietary_preferences)
117
+ # st.subheader("Meal Plan:")
118
+ # st.markdown(generated_mealplan)
119
+
120
+ # if __name__ == "__main__":
121
+ # main()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ streamlit
2
+ anthropic
3
+ python-dotenv