Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,34 +1,18 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import base64
|
| 3 |
-
from PIL import Image
|
| 4 |
-
import io
|
| 5 |
-
import json
|
| 6 |
|
| 7 |
-
# The
|
| 8 |
-
def
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
response = {
|
| 17 |
-
"received": True,
|
| 18 |
-
"robot_id": data.get("robot_id", "unknown"),
|
| 19 |
-
"image_size": img.size
|
| 20 |
-
}
|
| 21 |
-
return response
|
| 22 |
-
|
| 23 |
-
except Exception as e:
|
| 24 |
-
# Return error as a JSON dictionary which Gradio handles
|
| 25 |
-
return {"error": str(e)}
|
| 26 |
|
| 27 |
demo = gr.Interface(
|
| 28 |
-
fn=
|
| 29 |
-
#
|
| 30 |
-
|
| 31 |
-
outputs=gr.JSON(label="Reply to Jetson"),
|
| 32 |
)
|
| 33 |
|
| 34 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
+
# The function now accepts a simple string (plain text)
|
| 4 |
+
def process_text(input_text):
|
| 5 |
+
response = {
|
| 6 |
+
"received": True,
|
| 7 |
+
"message": f"Received: {input_text}",
|
| 8 |
+
"status": "Success"
|
| 9 |
+
}
|
| 10 |
+
return response
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
demo = gr.Interface(
|
| 13 |
+
fn=process_text,
|
| 14 |
+
inputs=gr.Textbox(label="Input Text"), # Changed input type
|
| 15 |
+
outputs=gr.JSON(label="Reply"),
|
|
|
|
| 16 |
)
|
| 17 |
|
| 18 |
demo.launch()
|