theboulder123 commited on
Commit
015a392
·
verified ·
1 Parent(s): 2dcdb31

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -17
app.py CHANGED
@@ -1,37 +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()
 
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()