Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,37 +1,37 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import requests
|
| 3 |
|
| 4 |
-
# 🛰️ Your active live Kaggle backend
|
| 5 |
KAGGLE_BACKEND_URL = "https://gauchely-nonreconcilable-miracle.ngrok-free.dev"
|
| 6 |
|
| 7 |
def chat_with_buddy(message, history):
|
| 8 |
-
#
|
| 9 |
payload = {"prompt": message}
|
| 10 |
|
| 11 |
try:
|
| 12 |
-
# Fire the HTTP request directly over to your Kaggle dual
|
| 13 |
response = requests.post(f"{KAGGLE_BACKEND_URL}/generate", json=payload)
|
| 14 |
|
| 15 |
if response.status_code == 200:
|
| 16 |
-
return response.json().get("response", "Error:
|
| 17 |
else:
|
| 18 |
return f"⚠️ Kaggle server responded with error status: {response.status_code}\nDetails: {response.text}"
|
| 19 |
|
| 20 |
except Exception as e:
|
| 21 |
-
return f"🚨
|
| 22 |
|
| 23 |
-
# 📱
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
)
|
| 35 |
|
| 36 |
if __name__ == "__main__":
|
| 37 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import requests
|
| 3 |
|
| 4 |
+
# 🛰️ Your active live Kaggle backend tunnel link
|
| 5 |
KAGGLE_BACKEND_URL = "https://gauchely-nonreconcilable-miracle.ngrok-free.dev"
|
| 6 |
|
| 7 |
def chat_with_buddy(message, history):
|
| 8 |
+
# Package your prompt for the Kaggle FastAPI architecture
|
| 9 |
payload = {"prompt": message}
|
| 10 |
|
| 11 |
try:
|
| 12 |
+
# Fire the HTTP request directly over the web to your Kaggle dual-T4 GPUs
|
| 13 |
response = requests.post(f"{KAGGLE_BACKEND_URL}/generate", json=payload)
|
| 14 |
|
| 15 |
if response.status_code == 200:
|
| 16 |
+
return response.json().get("response", "Error: Empty text data payload returned from server.")
|
| 17 |
else:
|
| 18 |
return f"⚠️ Kaggle server responded with error status: {response.status_code}\nDetails: {response.text}"
|
| 19 |
|
| 20 |
except Exception as e:
|
| 21 |
+
return f"🚨 Connection failed. Ensure your Kaggle notebook is running and active!\nError details: {str(e)}"
|
| 22 |
|
| 23 |
+
# 📱 Wrap the Chat Interface in Blocks to set themes flawlessly across all Gradio builds
|
| 24 |
+
with gr.Blocks(theme="soft") as demo:
|
| 25 |
+
gr.ChatInterface(
|
| 26 |
+
fn=chat_with_buddy,
|
| 27 |
+
title="💙 Flutter & Dart Coding Buddy",
|
| 28 |
+
description="Your personal mobile engineering assistant. Powered by Gemma 4 31B running on distributed cloud GPUs.",
|
| 29 |
+
examples=[
|
| 30 |
+
"Write a clean, responsive layout grid in Flutter.",
|
| 31 |
+
"How do I handle state persistence safely across app restarts?",
|
| 32 |
+
"Show me a type-safe API service layout using standard Dart patterns."
|
| 33 |
+
]
|
| 34 |
+
)
|
| 35 |
|
| 36 |
if __name__ == "__main__":
|
| 37 |
demo.launch()
|