Skip to content

Agentic tools

Agentic (GitHub) is a standard library of AI functions / tools which are optimized for both normal TS-usage as well as LLM-based usage. You can register any agentic tool in your script using defTool.

The full list of agentic tools can be found at https://agentic.so/tools/. Among others, you will find tools for:

Using a tool

We will use the calculator tool as it does not require any secret.

  1. Find the tool documentation page (https://agentic.so/tools/calculator) and install the dependencies.

    Terminal window
    npm install @agentic/core @agentic/calculator
  2. Configure the required environment variables in your .env file. In this case, the calculator tool does not require any secret but most do.

  3. Import the tool function and register it with defTool.

    import { calculator } from "@agentic/calculator"
    defTool(calculator)
    $`...`

    or in a subrompt

    import { calculator } from "@agentic/calculator"
    await runPrompt((_) => {
    _.defTool(calculator)
    _.$`...`
    })

That’s it! The agentic function have all the necessary metadata to register the function with the LLM and execute it.

Weather example

The weather tool uses the https://www.weatherapi.com/ APIs.

  1. Install the @agentic/weather package.

    Terminal window
    npm install @agentic/core @agentic/weather
  2. Configure the WEATHER_API_KEY environment variables in your .env file.

  3. Import the client type, create an instance and register it with defTool.

    import { WeatherClient } from "@agentic/weather"
    const weather = new WeatherClient()
    defTool(weather)
    $`...`