Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,14 +1,27 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from agent import agent #
|
| 3 |
-
from Gradio_UI import GradioUI
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
#
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
if __name__ == "__main__":
|
| 14 |
-
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
import gradio as gr
|
| 3 |
+
from agent import agent # your CodeAgent
|
|
|
|
| 4 |
|
| 5 |
+
def run_agent(question: str) -> str:
|
| 6 |
+
"""
|
| 7 |
+
A simple shim that takes one input string and returns
|
| 8 |
+
the agent's final text answer as a plain string.
|
| 9 |
+
"""
|
| 10 |
+
# If you want stateless calls, you can reset agent memory here.
|
| 11 |
+
response = agent(question)
|
| 12 |
+
return str(response).strip()
|
| 13 |
+
|
| 14 |
+
iface = gr.Interface(
|
| 15 |
+
fn=run_agent,
|
| 16 |
+
inputs=gr.Textbox(lines=2, label="Question"),
|
| 17 |
+
outputs=gr.Textbox(label="Answer"),
|
| 18 |
+
title="My Agent — Single-Question API",
|
| 19 |
+
description=(
|
| 20 |
+
"POST to /run/predict with JSON {\"data\": [\"<your question>\"]},\n"
|
| 21 |
+
"and you’ll get back {\"data\": [\"<answer>\"]}."
|
| 22 |
+
)
|
| 23 |
+
)
|
| 24 |
|
| 25 |
if __name__ == "__main__":
|
| 26 |
+
# Gradio will automatically spin up the /run/predict endpoint for this Interface
|
| 27 |
+
iface.launch(server_name="0.0.0.0", server_port=7860, debug=True, share=False)
|