Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from model_service import ask_ai
|
| 3 |
+
|
| 4 |
+
def respond(user_input):
|
| 5 |
+
if not user_input or not user_input.strip():
|
| 6 |
+
return ""
|
| 7 |
+
return ask_ai(user_input)
|
| 8 |
+
|
| 9 |
+
with gr.Blocks() as demo:
|
| 10 |
+
gr.Markdown(
|
| 11 |
+
"""
|
| 12 |
+
# 🤖 Groq AI App
|
| 13 |
+
**Powered by LLaMA 3.3 via Groq**
|
| 14 |
+
Ask anything below 👇
|
| 15 |
+
"""
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
user_input = gr.Textbox(
|
| 19 |
+
label="Your Question",
|
| 20 |
+
placeholder="Type your question here...",
|
| 21 |
+
lines=2
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
output = gr.Textbox(
|
| 25 |
+
label="AI Response",
|
| 26 |
+
lines=6,
|
| 27 |
+
interactive=False
|
| 28 |
+
)
|
| 29 |
+
|
| 30 |
+
ask_btn = gr.Button("Ask", variant="primary")
|
| 31 |
+
|
| 32 |
+
ask_btn.click(
|
| 33 |
+
fn=respond,
|
| 34 |
+
inputs=user_input,
|
| 35 |
+
outputs=output
|
| 36 |
+
)
|
| 37 |
+
|
| 38 |
+
demo.launch()
|