Sentinel02 / app.py
Shreyas94's picture
Update app.py
73b3250 verified
raw
history blame
1.23 kB
import os
import gradio as gr
from groq import Groq
# Set up Groq client
client = Groq(api_key=os.environ.get("GROQ_API_KEY"))
# Function to handle user input
def chat_inference(message, history):
try:
# Call compound-beta model
response = client.chat.completions.create(
messages=[{"role": "user", "content": message}],
model="compound-beta"
)
reply = response.choices[0].message.content
except Exception as e:
reply = f"⚠️ Error: {str(e)}"
return reply
# Optional configuration inputs (can be expanded)
additional_inputs = [
gr.Textbox(label="🔍 Example Prompt", value="What were the main highlights from the latest Apple keynote?")
]
# Gradio ChatInterface
chat_interface = gr.ChatInterface(
fn=chat_inference,
additional_inputs=additional_inputs,
additional_inputs_accordion=gr.Accordion("⚙️ Configuration & Advanced Parameters", open=True),
title="🔍 AI-Powered Real-Time Search with Groq",
description="Ask anything that requires real-time info — powered by Groq’s blazing fast `compound-beta` model with built-in web search.",
theme="default",
)
if __name__ == "__main__":
chat_interface.launch()