Spaces:
Runtime error
Runtime error
File size: 1,000 Bytes
98f352e f723ebc 98f352e f723ebc 98f352e f723ebc 98f352e f15b022 98f352e f723ebc 98f352e dcb85b5 98f352e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | 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}")
|