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}")