3mar-day2 / app.py
reddotapp25's picture
Upload 2 files
3780d29 verified
Raw
History Blame Contribute Delete
989 Bytes
# Install the necessary libraries
#!pip install -q groq gradio
import os
#from google.colab import userdata
from groq import Groq
# Fetch and set the API key securely
#os.environ["GROQ_API_KEY"] = userdata.get('GROQ_API_KEY')
client = Groq()
# Define the core AI function
# https://console.groq.com/docs/models
def chat_with_groq(user_input):
completion = client.chat.completions.create(
model="qwen/qwen3-32b",
messages=[
{"role": "system", "content": "You are a concise and professional AI Assistant."},
{"role": "user", "content": user_input}
]
)
return completion.choices[0].message.content
import gradio as gr
# Create and launch the UI
demo = gr.Interface(
fn=chat_with_groq,
inputs=gr.Textbox(label="Enter your prompt", lines=5),
outputs=gr.Textbox(label="AI Response", lines=5),
title="⚡ Instant AI Prototyper"
)
# Launch the interface
demo.launch(debug=True)