TDAgentTools / README.md
pedrobento988's picture
Update README.md
481cde4 verified
|
raw
history blame
2.27 kB
metadata
title: TDAgentTools
emoji: 💬
colorFrom: yellow
colorTo: purple
sdk: gradio
sdk_version: 5.32.1
app_file: app.py
pinned: false
license: apache-2.0
short_description: tdb

TDA Agent Tools

Development setup

To start developing you need the following tools:

To start, sync all the dependencies with uv sync --all-groups. Then, install the pre-commit hooks (uv run pre-commit install) to ensure that future commits comply with the bare minimum to keep code readable.

Once uv has installed all the dependencies, install the pre-commit hooks to run linting and requirement files update, etc., before creating new commits:

uv run pre-commit install

Adding new tools

For the sake of clarity, we organize tools under the directory tdagent/tools/, and then add them to the app.py list of interfaces.

As an example, let's create a tool that adds up two numbers. First, we create a new file tdagent/tools/calc_tool.py with the following content:

import gradio as gr


def add_numbers(num1: float, num2: str) -> float:
    """Compute the addition of two numbers `num1 + num2`.

    Args:
        num1: First number to add.
        num2: Second number to add.

    Returns:
        The result of computing `num1 + num2`.
    """
    return num1 + num2


gr_add_numbers = gr.Interface(
    fn=add_numbers,
    inputs=["number", "number"],
    outputs="number",
    title="Add two numbers",
    description="Compute the addition of two numbers",
)

Naming the file calc_tool.py is convenient as it let us add additional tools to calculate operations inside the same Python module.

Then, we modify the app.py file to include our new tool.

import gradio as gr

from tdagent.tools.get_url_content import gr_get_url_http_content
...  # Other tools already present before
from tdagent.tools.calc_tool import gr_add_numbers


gr_app = gr.TabbedInterface(
    [
        gr_get_url_http_content,
        ...,  # Other tools already present before
        gr_add_numbers
    ],
)

if __name__ == "__main__":
    gr_app.launch(mcp_server=True)

In future updates we might change the app.py to automatically include any gr.Interface, but for now this works just fine.