mcp_ / tools /echo_text.py
eienmojiki's picture
x
8d3757d
raw
history blame contribute delete
927 Bytes
# tools/echo_text.py
import gradio as gr
from utils.tool_manager import tool
def echo_ui():
"""
Builds the Gradio UI components for the Echo Text tool.
Returns a tuple: (ui_group, input_components, output_components, button_component)
"""
with gr.Group(visible=False) as ui_group: # Initially hidden
input_text = gr.Textbox(label="Enter text to echo", placeholder="Type something...")
output_text = gr.Textbox(label="Echoed Text", interactive=False)
run_button = gr.Button("Echo")
# Return the group, input(s), output(s), and the button
return ui_group, input_text, output_text, run_button
@tool(
name="Echo Text",
control_components=echo_ui # Pass the UI builder function
)
def echo_function(text: str) -> str:
"""
Echoes the input text.
Args:
text (str): The input text.
**Returns:**
str: The input text.
"""
return text