Spaces:
Build error
Build error
Create app.py
Browse files
app.py
CHANGED
|
@@ -1,35 +1,17 @@
|
|
| 1 |
import os
|
| 2 |
-
import streamlit as st
|
| 3 |
from groq import Groq
|
| 4 |
-
from dotenv import load_dotenv
|
| 5 |
|
| 6 |
-
#
|
| 7 |
-
|
| 8 |
-
GROQ_API_KEY = os.getenv("GROQ_API_KEY")
|
| 9 |
|
| 10 |
-
|
| 11 |
-
client = Groq(api_key=GROQ_API_KEY)
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
| 15 |
chat_completion = client.chat.completions.create(
|
| 16 |
-
messages=[{"role": "user", "content":
|
| 17 |
model="llama-3.3-70b-versatile",
|
| 18 |
)
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 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!")
|
|
|
|
| 1 |
import os
|
|
|
|
| 2 |
from groq import Groq
|
|
|
|
| 3 |
|
| 4 |
+
# Set API key directly for testing (remove this after testing)
|
| 5 |
+
os.environ["GROQ_API_KEY"] = "your_actual_api_key_here"
|
|
|
|
| 6 |
|
| 7 |
+
client = Groq(api_key=os.getenv("GROQ_API_KEY"))
|
|
|
|
| 8 |
|
| 9 |
+
# Test API authentication
|
| 10 |
+
try:
|
| 11 |
chat_completion = client.chat.completions.create(
|
| 12 |
+
messages=[{"role": "user", "content": "Test message"}],
|
| 13 |
model="llama-3.3-70b-versatile",
|
| 14 |
)
|
| 15 |
+
print(chat_completion.choices[0].message.content)
|
| 16 |
+
except Exception as e:
|
| 17 |
+
print("Error:", e)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|