theboulder123 commited on
Commit
2dcdb31
·
verified ·
1 Parent(s): 4c0f9f9

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -0
app.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import requests
3
+
4
+ # 🛰️ Your active live Kaggle backend URL
5
+ KAGGLE_BACKEND_URL = "https://gauchely-nonreconcilable-miracle.ngrok-free.dev"
6
+
7
+ def chat_with_buddy(message, history):
8
+ # Prepare the payload for your Kaggle FastAPI server
9
+ payload = {"prompt": message}
10
+
11
+ try:
12
+ # Fire the HTTP request directly over 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: No text payload received from backend.")
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"🚨 Failed to connect to Kaggle backend. Make sure your notebook is still running and the URL is correct!\nError: {str(e)}"
22
+
23
+ # 📱 Render a modern, mobile-friendly Chat Interface
24
+ demo = gr.ChatInterface(
25
+ fn=chat_with_buddy,
26
+ title="💙 Flutter & Dart Coding Buddy",
27
+ description="Your personal mobile engineering assistant. Powered by Gemma 4 31B running on distributed cloud GPUs.",
28
+ examples=[
29
+ "Write a clean, responsive layout grid in Flutter.",
30
+ "How do I handle state persistence safely across app restarts?",
31
+ "Show me a type-safe API service layout using standard Dart patterns."
32
+ ],
33
+ theme="soft"
34
+ )
35
+
36
+ if __name__ == "__main__":
37
+ demo.launch()