File size: 1,232 Bytes
73b3250
6bd0088
73b3250
e867839
73b3250
 
e867839
73b3250
 
e867839
73b3250
 
 
 
e867839
73b3250
e867839
73b3250
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6bd0088
 
73b3250
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
33
34
35
36
37
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()