Tools

This guide will get you all set up and ready to use Superagent Tools. Superagent allows users to configure their Agents using tools. A tool is a Api or piece of code that helps the LLM to validate its response. It can be an api that Superagent calls to get real time information or a Zapier integration. Tools are helpfull to give LLMs access to real time and real world data while also reducing haluzination

The Tool Model

The Superagent Swift SDK comes with publicly available models. This makes it easy for you to configure your requests correctly. Tools in superagent allow the following properties in the request.

  • Name
    name
    Type
    String
    Description

    The name of the tool.

  • Name
    type
    Type
    Strings
    Description

    The type of tool, valid options SEARCH, WOLFRAM_ALPHA, REPLICATE, ZAPIER_NLA, AGENT, OPENAPI

  • Name
    description
    Type
    String
    Description

    The tool template.

  • Name
    authorization
    Type
    Any?
    Description

    Optional authentification detail for a tool.

  • Name
    metadata
    Type
    Any?
    Description

    Any other configuration needed for the tool as an JSON object.


GET/v1/tools

List all tools

This endpoint allows you to retrieve a list of all your tools

mytools.swift

do {
  let mytools = try await superagent.listTools()
  print("tool: \(mytools)")
  } catch {
    print("Error when creating agent: \(error)")
    throw error
}

To access the response key value pair just specific a key. For example mytools["id"] for the tool Id

Response

{[
    {
      "id": "cli28c2vd00016itbrlhekwql",
      "name": "My tool",
      "template": "...",
      "input_variables": [
        "question",
        "history"
      ],
    }
  ]
}

GET/v1/tools{toolId}

Get tool

This endpoint allows you to retrieve a single tool

Require attributes

  • Name
    id
    Type
    string
    Description

    The id of the tool.

mytools.swift

do {
  let mytools = try await superagent.getTool(id: "mytoolId")
  print("tool: \(mytools)")
  } catch {
    print("Error when creating agent: \(error)")
    throw error
}

You can access the response key value pairs by requesting a specific key. For example mytools["id"] for the tool Id

Response

{
    "id": "cli28c2vd00016itbrlhekwql",
    "name": "My tool",
    "template": "...",
    "input_variables": [
      "question",
      "history"
    ],
}

PAT/v1/tools{toolId}

Update a tool

This endpoint allows you to update a single tool

Require attributes

  • Name
    id
    Type
    string
    Description

    The id of the tool.

  • Name
    Tool(name: "My Zapier tool", ...)
    Type
    Description

    The updated tool as a Tool model

mytools.swift


let newTool = Tool(name: "My Zapier tool", type: "ZAPIER_NLA", metadata: {"zapier_nla_api_key": ""})

do {
  let mytools = try await superagent.updateTool(id: "mytoolId", newTool: newTool)
  print("tool: \(mytools)")
  } catch {
    print("Error when creating agent: \(error)")
    throw error
}

You can access the response key value pairs by requesting a specific key. For example mytools["id"] for the tool Id

Response

{
  "id": "cli28c2vd00016itbrlhekwql",
  "name": "My Zapier tool",
  "type": "ZAPIER_NLA"
}

POST/v1/tools

Create tool

This endpoint allows you to update a single tool

Require attributes

  • Name
    Tool(name: "My Zapier tool", ...)
    Type
    Tool Model
    Description

    The updated tool as a Tool model

mytools.swift


let newTool = Tool(name: "My Zapier tool", type: "ZAPIER_NLA", metadata: {"zapier_nla_api_key": ""})

do {
  let mytools = try await superagent.createTool(tool: newTool)
  print("tool: \(mytools)")
  } catch {
    print("Error when creating agent: \(error)")
    throw error
}

You can access the response key value pairs by requesting a specific key. For example mytools["id"] for the tool Id

Response

{ 
  "id": "cli28c2vd00016itbrlhekwql",
  "name": "My Zapier tool",
  "type": "ZAPIER_NLA"
}

DEL/v1/tools{toolId}

Delete tool

This endpoint allows you to delete a Tool. The delet function returns a simple true or false boolean value which represents the success.

Require attributes

  • Name
    id
    Type
    string
    Description

    The id of the tool.

mytools.swift

do {
  let mytools = try await superagent.deleteTool(id: "mytoolId")
  print("tool: \(mytools)")
  } catch {
    print("Error when creating agent: \(error)")
    throw error
}