File size: 927 Bytes
d5b5f42 8d3757d d5b5f42 8d3757d d5b5f42 37e00cc 8d3757d d5b5f42 |
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 29 30 31 32 |
# 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 |