File size: 937 Bytes
d06a9da
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
31
32
import streamlit as st
from groq import Groq

# API Key (replace with yours)
API_KEY = "YOUR_GROQ_API_KEY"

# Function to interact with the model
def get_model_response(prompt):
  try:
    client = Groq(api_key=API_KEY)
    chat_completion = client.chat.completions.create(
        messages=[
            {
                "role": "user",
                "content": prompt,
            }
        ],
        model="llama3-8b-8192",  # Update with your desired model
    )
    response = chat_completion.choices[0].message.content
    return response
  except Exception as e:
    return f"An error occurred: {str(e)}"

# Streamlit App
st.title("AI Chat Interface")
st.write("This app allows you to interact with a Groq-powered AI model.")

user_input = st.text_input("Your Prompt", placeholder="Type your question here...")
if st.button("Get Response"):
  response = get_model_response(user_input)
  st.write(f"Model Response: {response}")