Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
import anthropic
|
| 2 |
import os
|
|
|
|
| 3 |
|
| 4 |
# Load the API key from environment variables
|
| 5 |
api_key = os.getenv("ANTHROPIC_API_KEY")
|
|
@@ -10,18 +11,7 @@ client = anthropic.Anthropic(api_key=api_key)
|
|
| 10 |
def meal_plan_generate(fasting_sugar_level, pre_meal_sugar, post_meal_sugar, dietary_preferences):
|
| 11 |
try:
|
| 12 |
# Construct the message prompt
|
| 13 |
-
|
| 14 |
-
{
|
| 15 |
-
"role": "system",
|
| 16 |
-
"content": "You are a helpful medical assistant that provides food recommendations based on sugar levels and dietary preferences."
|
| 17 |
-
},
|
| 18 |
-
{
|
| 19 |
-
"role": "user",
|
| 20 |
-
"content": "I am a diabetic patient. My fasting sugar level is {}, pre-meal sugar level is {}, and post-meal sugar level is {}. My dietary preferences are {}. Could you recommend some food recipes based on this information?".format(
|
| 21 |
-
fasting_sugar_level, pre_meal_sugar, post_meal_sugar, dietary_preferences
|
| 22 |
-
)
|
| 23 |
-
}
|
| 24 |
-
]
|
| 25 |
|
| 26 |
# API call to generate meal plan using Messages API
|
| 27 |
response = client.messages.create(
|
|
@@ -29,7 +19,7 @@ def meal_plan_generate(fasting_sugar_level, pre_meal_sugar, post_meal_sugar, die
|
|
| 29 |
max_tokens=400,
|
| 30 |
temperature=0,
|
| 31 |
system="You are a helpful medical assistant that provides food recommendations based on sugar levels and dietary preferences.",
|
| 32 |
-
|
| 33 |
)
|
| 34 |
|
| 35 |
# Process the response
|
|
@@ -42,7 +32,6 @@ def meal_plan_generate(fasting_sugar_level, pre_meal_sugar, post_meal_sugar, die
|
|
| 42 |
return f"An error occurred: {e}"
|
| 43 |
|
| 44 |
def main():
|
| 45 |
-
import streamlit as st
|
| 46 |
st.set_page_config(page_title="GlucoGuide", layout="wide")
|
| 47 |
st.title("🍎 GlucoGuide")
|
| 48 |
st.markdown("""
|
|
@@ -74,7 +63,7 @@ def main():
|
|
| 74 |
st.text(generated_meal_plan)
|
| 75 |
|
| 76 |
st.warning("""
|
| 77 |
-
**
|
| 78 |
""")
|
| 79 |
st.markdown("**Developed by Salman Maqbool ❤️**")
|
| 80 |
|
|
|
|
| 1 |
import anthropic
|
| 2 |
import os
|
| 3 |
+
import streamlit as st
|
| 4 |
|
| 5 |
# Load the API key from environment variables
|
| 6 |
api_key = os.getenv("ANTHROPIC_API_KEY")
|
|
|
|
| 11 |
def meal_plan_generate(fasting_sugar_level, pre_meal_sugar, post_meal_sugar, dietary_preferences):
|
| 12 |
try:
|
| 13 |
# Construct the message prompt
|
| 14 |
+
prompt = f"I am a diabetic patient. My fasting sugar level is {fasting_sugar_level}, pre-meal sugar level is {pre_meal_sugar}, and post-meal sugar level is {post_meal_sugar}. My dietary preferences are {dietary_preferences}. Could you recommend some food recipes based on this information?"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
# API call to generate meal plan using Messages API
|
| 17 |
response = client.messages.create(
|
|
|
|
| 19 |
max_tokens=400,
|
| 20 |
temperature=0,
|
| 21 |
system="You are a helpful medical assistant that provides food recommendations based on sugar levels and dietary preferences.",
|
| 22 |
+
prompt=prompt
|
| 23 |
)
|
| 24 |
|
| 25 |
# Process the response
|
|
|
|
| 32 |
return f"An error occurred: {e}"
|
| 33 |
|
| 34 |
def main():
|
|
|
|
| 35 |
st.set_page_config(page_title="GlucoGuide", layout="wide")
|
| 36 |
st.title("🍎 GlucoGuide")
|
| 37 |
st.markdown("""
|
|
|
|
| 63 |
st.text(generated_meal_plan)
|
| 64 |
|
| 65 |
st.warning("""
|
| 66 |
+
**Warning**: GlucoGuide'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.
|
| 67 |
""")
|
| 68 |
st.markdown("**Developed by Salman Maqbool ❤️**")
|
| 69 |
|