Tanseer45203's picture
Create app.py
c8aef16 verified
Raw
History Blame Contribute Delete
1.12 kB
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!")