File size: 906 Bytes
c59c3ec
21eddb8
c59c3ec
cd8644c
c59c3ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cd8644c
 
c59c3ec
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import os
import gradio as gr
from agent import agent  # your CodeAgent

def run_agent(question: str) -> str:
    """
    A simple shim that takes one input string and returns
    the agent's final text answer as a plain string.
    """
    # If you want stateless calls, you can reset agent memory here.
    response = agent(question)
    return str(response).strip()

iface = gr.Interface(
    fn=run_agent,
    inputs=gr.Textbox(lines=2, label="Question"),
    outputs=gr.Textbox(label="Answer"),
    title="My Agent — Single-Question API",
    description=(
        "POST to /run/predict with JSON {\"data\": [\"<your question>\"]},\n"
        "and you’ll get back {\"data\": [\"<answer>\"]}."
    )
)

if __name__ == "__main__":
    # Gradio will automatically spin up the /run/predict endpoint for this Interface
    iface.launch(server_name="0.0.0.0", server_port=7860, debug=True, share=False)