Spaces:
No application file
No application file
Update main.py
Browse files
main.py
CHANGED
|
@@ -1,19 +1,10 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
import os
|
| 3 |
import gradio as gr
|
| 4 |
-
import whisper
|
| 5 |
-
from gtts import gTTS
|
| 6 |
-
import io
|
| 7 |
-
from groq import Groq
|
| 8 |
-
|
| 9 |
-
|
| 10 |
import anthropic
|
| 11 |
-
|
| 12 |
-
api_key = st.secrets["my-key"]
|
| 13 |
|
| 14 |
# Function to call Claude AI API and get a personalized meal plan
|
| 15 |
-
def get_meal_plan(
|
| 16 |
-
|
| 17 |
client = anthropic.Anthropic(api_key=api_key)
|
| 18 |
|
| 19 |
# Define the prompt to send to Claude AI
|
|
@@ -40,30 +31,28 @@ def get_meal_plan(api_key, fasting_sugar, pre_meal_sugar, post_meal_sugar, dieta
|
|
| 40 |
)
|
| 41 |
|
| 42 |
raw_context = message.content
|
| 43 |
-
|
| 44 |
-
return
|
| 45 |
-
|
| 46 |
-
# Streamlit app
|
| 47 |
-
st.title("Glucose Guardian")
|
| 48 |
-
|
| 49 |
-
st.write("""
|
| 50 |
-
**Glucose Guardian** is a personalized meal planning tool designed specifically for diabetic patients.
|
| 51 |
-
By entering your sugar levels and dietary preferences, Glucose Guardian generates meal plans that are
|
| 52 |
-
tailored to help you manage your blood sugar levels effectively.
|
| 53 |
-
""")
|
| 54 |
|
| 55 |
-
#
|
| 56 |
-
|
|
|
|
|
|
|
| 57 |
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
import anthropic
|
| 3 |
+
import os
|
|
|
|
| 4 |
|
| 5 |
# Function to call Claude AI API and get a personalized meal plan
|
| 6 |
+
def get_meal_plan(fasting_sugar, pre_meal_sugar, post_meal_sugar, dietary_preferences):
|
| 7 |
+
api_key = os.getenv('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') # Replace with your actual API key or environment variable
|
| 8 |
client = anthropic.Anthropic(api_key=api_key)
|
| 9 |
|
| 10 |
# Define the prompt to send to Claude AI
|
|
|
|
| 31 |
)
|
| 32 |
|
| 33 |
raw_context = message.content
|
| 34 |
+
meal_plan = raw_context[0].text
|
| 35 |
+
return meal_plan
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
+
# Gradio interface
|
| 38 |
+
def generate_meal_plan(fasting_sugar, pre_meal_sugar, post_meal_sugar, dietary_preferences):
|
| 39 |
+
meal_plan = get_meal_plan(fasting_sugar, pre_meal_sugar, post_meal_sugar, dietary_preferences)
|
| 40 |
+
return meal_plan
|
| 41 |
|
| 42 |
+
with gr.Blocks() as demo:
|
| 43 |
+
gr.Markdown("# Glucose Guardian")
|
| 44 |
+
gr.Markdown("**Glucose Guardian** is a personalized meal planning tool designed specifically for diabetic patients. By entering your sugar levels and dietary preferences, Glucose Guardian generates meal plans that are tailored to help you manage your blood sugar levels effectively.")
|
| 45 |
+
|
| 46 |
+
with gr.Row():
|
| 47 |
+
fasting_sugar = gr.Number(label="Fasting Sugar Levels (mg/dL)", value=0, min=0, max=500, step=1)
|
| 48 |
+
pre_meal_sugar = gr.Number(label="Pre-Meal Sugar Levels (mg/dL)", value=0, min=0, max=500, step=1)
|
| 49 |
+
post_meal_sugar = gr.Number(label="Post-Meal Sugar Levels (mg/dL)", value=0, min=0, max=500, step=1)
|
| 50 |
+
|
| 51 |
+
dietary_preferences = gr.Textbox(label="Dietary Preferences (e.g., vegetarian, low-carb)")
|
| 52 |
+
|
| 53 |
+
meal_plan_output = gr.Markdown()
|
| 54 |
+
|
| 55 |
+
generate_button = gr.Button("Generate Meal Plan")
|
| 56 |
+
generate_button.click(fn=generate_meal_plan, inputs=[fasting_sugar, pre_meal_sugar, post_meal_sugar, dietary_preferences], outputs=meal_plan_output)
|
| 57 |
+
|
| 58 |
+
demo.launch()
|