Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -143,4 +143,36 @@ Respond in STRICT JSON ONLY.
|
|
| 143 |
"robot_id": robot_id,
|
| 144 |
"file_size_bytes": size_bytes,
|
| 145 |
"image_url": hf_url,
|
| 146 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
"robot_id": robot_id,
|
| 144 |
"file_size_bytes": size_bytes,
|
| 145 |
"image_url": hf_url,
|
| 146 |
+
"description": parsed.get("description"),
|
| 147 |
+
"human": parsed.get("human"),
|
| 148 |
+
"environment": parsed.get("environment"),
|
| 149 |
+
"vlm_raw": vlm_output
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
# -------------------------------
|
| 154 |
+
# GRADIO WRAPPER
|
| 155 |
+
# -------------------------------
|
| 156 |
+
def process_json(payload):
|
| 157 |
+
"""
|
| 158 |
+
Gradio wrapper: directly calls the MCP tool inside the same process.
|
| 159 |
+
"""
|
| 160 |
+
return robot_watch(payload)
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
app = gr.Interface(
|
| 164 |
+
fn=process_json,
|
| 165 |
+
inputs=gr.JSON(label="Input JSON (hf_token, image_b64, robot_id)"),
|
| 166 |
+
outputs=gr.JSON(label="Result JSON"),
|
| 167 |
+
title="Robot MCP Server",
|
| 168 |
+
description="This is only a JSON wrapper. The real logic lives in the MCP tool.",
|
| 169 |
+
api_name="predict"
|
| 170 |
+
)
|
| 171 |
+
|
| 172 |
+
|
| 173 |
+
# -------------------------------
|
| 174 |
+
# ENTRY
|
| 175 |
+
# -------------------------------
|
| 176 |
+
if __name__ == "__main__":
|
| 177 |
+
# Launch MCP server + Gradio together
|
| 178 |
+
app.launch(mcp_server=True)
|