Spaces:
Build error
Build error
Create app.py
Browse files12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152# app.py
import osimport streamlit as stfrom groq import Groq
# Set your GROQ API Key here directly (since in Colab it's easier)GROQ_API_KEY = "your-groq-api-key-here" # <-- Replace with your key
# Create the GROQ clientclient = Groq( api_key=GROQ_API_KEY,)
# Streamlit appst.title("🤖 Chatbot using GROQ API")
# Store the conversationif "messages" not in st.session_state: st.session_state.messages = []
# Display old messagesfor message in st.session_state.messages: if message["role"] == "user": with st.chat_message("user"): st.write(message["content"]) else: with st.chat_message("assistant"): st.write(message["content"])
# Input from useruser_input = st.chat_input("Type your message...")
if user_input: # Save user message st.session_state.messages.append({"role": "user", "content": user_input})
# Send all messages to model chat_completion = client.chat.completions.create( messages=st.session_state.messages, model="llama-3-3-70b-versatile", )
# Get model's reply reply = chat_completion.choices[0].message.content
# Save assistant reply st.session_state.messages.append({"role": "assistant", "content": reply})
# Display assistant reply with st.chat_message("assistant"): st.write(reply)app.pyAdded+52