File size: 831 Bytes
3af2c11
 
 
 
 
 
a833b59
3af2c11
e3d1d1e
 
3af2c11
 
e3d1d1e
3af2c11
 
 
 
e3d1d1e
3af2c11
 
e3d1d1e
3af2c11
e3d1d1e
 
 
 
 
 
 
 
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 Groq

st.set_page_config(page_title="Sample Chatbot", page_icon="🤖")

st.title("🤖 Jehan Zada Chatboot")

# Read API key
api_key = os.getenv("Samplechatboot")

if not api_key:
    st.error("API key not found. Please add Samplechatboot in Space secrets.")
    st.stop()

client = Groq(api_key=api_key)

user_input = st.text_input("Ask your question:")

if st.button("Send"):
    if user_input.strip():
        with st.spinner("Thinking..."):
            response = client.chat.completions.create(
                model="llama-3.3-70b-versatile",
                messages=[{"role": "user", "content": user_input}],
            )
            st.success("Response:")
            st.write(response.choices[0].message.content)
    else:
        st.warning("Please enter a message.")