Spaces:
No application file
No application file
File size: 917 Bytes
26ce7c2 556ffec ca18edf 556ffec ca18edf 556ffec ca18edf 556ffec ca18edf 556ffec ca18edf |
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 |
import os
import streamlit as st
from groq import * # Import everything from groq, so you can access the chat functionality
# Ensure you have the correct API key set in the environment variable
api_key = "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"
# Streamlit interface
st.title("AI Chatbot with Groq")
user_input = st.text_input("Ask something:", "")
if user_input:
try:
# Create the Groq client using the API key
client = Groq(api_key=api_key)
# Create chat completion with user input
chat_completion = client.chat.completions.create(
messages=[{"role": "user", "content": user_input}],
model="llama-3.3-70b-versatile"
)
# Display the response
st.write("AI's response: ")
st.write(chat_completion.choices[0].message.content)
except Exception as e:
st.error(f"Error: {e}")
|