Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import os | |
| from groq import Groq | |
| from dotenv import load_dotenv | |
| # Load environment variables | |
| load_dotenv() | |
| # Initialize Groq client | |
| client = Groq(api_key=os.getenv("GROQ_API_KEY")) | |
| # Streamlit UI Configuration | |
| st.set_page_config(page_title="🥦 Vegetable Preparation Guide", layout="wide") | |
| st.title("🥦 Vegetable Preparation Guide") | |
| st.write("Learn how to clean, cut, cook, and store vegetables properly.") | |
| # User input | |
| query = st.text_input("Enter a vegetable name:", "") | |
| if st.button("Get Preparation Guide"): | |
| if query: | |
| with st.spinner("Fetching vegetable preparation guide..."): | |
| chat_completion = client.chat.completions.create( | |
| messages=[ | |
| { | |
| "role": "user", | |
| "content": f"Provide a detailed preparation guide for {query}. " | |
| f"Include cleaning, cutting, cooking methods (boiling, steaming, roasting, stir-frying, raw), " | |
| f"nutritional benefits, and storage tips." | |
| } | |
| ], | |
| model="llama-3.3-70b-versatile", | |
| ) | |
| response = chat_completion.choices[0].message.content | |
| st.subheader(f"Preparation Guide for {query.capitalize()}:") | |
| st.write(response) | |
| else: | |
| st.warning("Please enter a vegetable name to get the guide.") |