To_Do_List / app.py
Ahmad-01's picture
Update app.py
98f352e verified
import streamlit as st
import os
from groq import Groq
# --- Setup Groq client using environment variable ---
api_key = os.environ.get("GROQ_API_KEY")
if not api_key:
st.error("Error: GROQ_API_KEY not set in environment variables.")
else:
client = Groq(api_key=api_key)
st.title("Habit & To-Do Tracker with Groq AI")
st.markdown("""
Welcome! Enter a prompt and get insights from the Groq API.
""")
# --- User input ---
user_prompt = st.text_area("Enter your prompt:", "")
if st.button("Submit"):
if not user_prompt.strip():
st.warning("Please enter a prompt!")
else:
try:
with st.spinner("Processing..."):
response = client.chat.completions.create(
messages=[{"role": "user", "content": user_prompt}]
)
st.subheader("Groq AI Response:")
st.write(response.choices[0].message.content)
except Exception as e:
st.error(f"Error calling Groq API: {e}")