Spaces:
Build error
Build error
File size: 1,118 Bytes
0e580c4 c8aef16 0e580c4 c8aef16 0e580c4 c8aef16 0e580c4 c8aef16 | 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 35 | import os
import streamlit as st
from groq import Groq
# Load API key from environment variables
api_key = os.environ.get("GROQ_API_KEY")
# Initialize Groq client
client = Groq(api_key=api_key)
# Streamlit app setup
st.title("AI-powered Routine Assistant")
# Function to get response from the Groq model
def get_groq_response(user_message):
try:
chat_completion = client.chat.completions.create(
messages=[{"role": "user", "content": user_message}],
model="llama-3.3-70b-versatile",
)
return chat_completion.choices[0].message.content
except Exception as e:
return f"Error: {str(e)}"
# Display the chatbot's response based on the user's input
user_input = st.text_input("Ask me about your routine:")
if user_input:
# Make sure the question is routine-related, otherwise guide the user
if "routine" in user_input.lower() or "schedule" in user_input.lower():
response = get_groq_response(user_input)
st.write(response)
else:
st.write("I'm here to help with your study routine. Please ask me about your schedule!")
|