Downloads · 30 days
0
Jonnathan20202/AURRA
AURRA is a machine learning model from Jonnathan20202. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as afl-3.0.
import os import asyncio import gradio as gr from groq import AsyncGroq Changed to the asynchronous client
Downloads · 30 days
0
Access
Public
Updated Aug 19, 2026
Repo size
—
Likes
0
Public
Click a slice to open those files.
.md2.6 KB · 63%
From the Hugging Face model README
import os import asyncio import gradio as gr from groq import AsyncGroq # Changed to the asynchronous client
API_KEY = os.environ.get("GROQ_API_KEY", "YOUR_FALLBACK_KEY_HERE") client = AsyncGroq(api_key=API_KEY) # Initialized as AsyncGroq
MODELS = [ "llama-3.3-70b-versatile", "llama-3.1-8b-instant", "deepseek-r1-distill-llama-70b", "qwen/qwen3.6-27b" ]
async def chat_groq(message, history, model_name, system_prompt, temperature): messages = [{"role": "system", "content": system_prompt}]
# Add conversation history
for user_msg, assistant_msg in history:
messages.append({"role": "user", "content": user_msg})
messages.append({"role": "assistant", "content": assistant_msg})
# Add current user prompt
messages.append({"role": "user", "content": message})
try:
# Await the async streaming completion creation
response_stream = await client.chat.completions.create(
model=model_name,
messages=messages,
temperature=temperature,
max_tokens=2048,
stream=True
)
partial_response = ""
# Use async for to safely iterate over the asynchronous stream chunks
async for chunk in response_stream:
if chunk.choices and len(chunk.choices) > 0:
token = chunk.choices[0].delta.content or ""
partial_response += token
yield partial_response
except Exception as e:
yield f"An error occurred: {str(e)}"
with gr.Blocks(title="Groq AI Chatbot") as demo: gr.Markdown("## ⚡ Groq Ultra-Fast AI Assistant")
with gr.Row():
with gr.Column(scale=1):
model_selector = gr.Dropdown(
choices=MODELS,
value="llama-3.3-70b-versatile",
label="Select Groq Model"
)
temp_slider = gr.Slider(
minimum=0.0, maximum=1.0, value=0.7, step=0.1, label="Temperature"
)
system_box = gr.Textbox(
value="You are a helpful and concise AI assistant.",
label="System Prompt",
lines=3
)
with gr.Column(scale=3):
chatbot = gr.ChatInterface(
fn=chat_groq,
additional_inputs=[model_selector, system_box, temp_slider]
)
demo.launch(debug=True)