Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,17 +1,28 @@
|
|
| 1 |
-
import
|
| 2 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
-
def slow_echo(message, history):
|
| 5 |
-
for i in range(len(message)):
|
| 6 |
-
time.sleep(0.05)
|
| 7 |
-
yield "You typed: " + message[: i + 1]
|
| 8 |
|
| 9 |
demo = gr.ChatInterface(
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
save_history=True,
|
| 14 |
)
|
| 15 |
|
| 16 |
if __name__ == "__main__":
|
| 17 |
-
demo.launch()
|
|
|
|
| 1 |
+
import os
|
| 2 |
import gradio as gr
|
| 3 |
+
import requests
|
| 4 |
+
|
| 5 |
+
BACKEND_URL = os.environ.get("BACKEND_URL", "https://c7-mvp-95fi.onrender.com/diagnose")
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def diagnose(message, history):
|
| 9 |
+
try:
|
| 10 |
+
response = requests.post(
|
| 11 |
+
BACKEND_URL,
|
| 12 |
+
json={"workflow_description": message},
|
| 13 |
+
timeout=60,
|
| 14 |
+
)
|
| 15 |
+
response.raise_for_status()
|
| 16 |
+
return response.text
|
| 17 |
+
except requests.RequestException as e:
|
| 18 |
+
return f"Could not reach the backend.\n\n{e}"
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
demo = gr.ChatInterface(
|
| 22 |
+
diagnose,
|
| 23 |
+
title="Workflow Diagnoser",
|
| 24 |
+
description="Describe one repeated task you do at work.",
|
|
|
|
| 25 |
)
|
| 26 |
|
| 27 |
if __name__ == "__main__":
|
| 28 |
+
demo.launch()
|