Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import streamlit as st
|
| 3 |
+
from groq import Groq
|
| 4 |
+
from dotenv import load_dotenv
|
| 5 |
+
|
| 6 |
+
# Load environment variables
|
| 7 |
+
load_dotenv()
|
| 8 |
+
GROQ_API_KEY = os.getenv("GROQ_API_KEY")
|
| 9 |
+
|
| 10 |
+
# Initialize Groq Client
|
| 11 |
+
client = Groq(api_key=GROQ_API_KEY)
|
| 12 |
+
|
| 13 |
+
def get_routine_response(user_input):
|
| 14 |
+
"""Fetches response from Groq's LLaMA model."""
|
| 15 |
+
chat_completion = client.chat.completions.create(
|
| 16 |
+
messages=[{"role": "user", "content": user_input}],
|
| 17 |
+
model="llama-3.3-70b-versatile",
|
| 18 |
+
)
|
| 19 |
+
return chat_completion.choices[0].message.content
|
| 20 |
+
|
| 21 |
+
# Streamlit UI
|
| 22 |
+
st.title("📅 Routine Assistant Chatbot")
|
| 23 |
+
st.write("Ask me about your study schedule, time management, and educational routines!")
|
| 24 |
+
|
| 25 |
+
# User input
|
| 26 |
+
user_input = st.text_input("Enter your question:")
|
| 27 |
+
|
| 28 |
+
if user_input:
|
| 29 |
+
response = get_routine_response(user_input)
|
| 30 |
+
st.write("🧠 AI Response:")
|
| 31 |
+
st.write(response)
|
| 32 |
+
st.code(response, language='text') # Add copy option
|
| 33 |
+
|
| 34 |
+
# Disclaimer for unrelated queries
|
| 35 |
+
st.write("⚠️ This chatbot only provides educational routine assistance. Please keep questions relevant!")
|