Creating Plot Twists
    Preparing search index...

    Type Alias AITool<PARAMETERS, RESULT>

    AITool: {
        parameters: PARAMETERS;
        inputSchema: TSchema;
        description?: string;
        execute?: (
            args: inferParameters<PARAMETERS>,
            options: ToolExecutionOptions,
        ) => PromiseLike<RESULT>;
    } & (
        | { type?: "function" }
        | {
            type: "provider-defined";
            id: `${string}.${string}`;
            args: Record<string, unknown>;
        }
    )

    A tool contains the description and the schema of the input that the tool expects. This enables the language model to generate the input.

    The tool can also contain an optional execute function for the actual execution function of the tool.

    Type Parameters

    • PARAMETERS extends ToolParameters = any
    • RESULT = any

    Type Declaration

    • parameters: PARAMETERS

      The schema of the input that the tool expects. The language model will use this to generate the input. It is also used to validate the output of the language model. Use descriptions to make the input understandable for the language model.

    • inputSchema: TSchema

      The schema of the input that the tool expects. The language model will use this to generate the input. It is also used to validate the output of the language model. Use descriptions to make the input understandable for the language model.

    • Optionaldescription?: string

      An optional description of what the tool does. Will be used by the language model to decide whether to use the tool. Not used for provider-defined tools.

    • Optionalexecute?: (
          args: inferParameters<PARAMETERS>,
          options: ToolExecutionOptions,
      ) => PromiseLike<RESULT>

      An async function that is called with the arguments from the tool call and produces a result. If not provided, the tool will not be executed automatically.

    • { type?: "function" }
      • Optionaltype?: "function"

        Function tool.

    • {
          type: "provider-defined";
          id: `${string}.${string}`;
          args: Record<string, unknown>;
      }
      • type: "provider-defined"

        Provider-defined tool.

      • id: `${string}.${string}`

        The ID of the tool. Should follow the format <provider-name>.<tool-name>.

      • args: Record<string, unknown>

        The arguments for configuring the tool. Must match the expected arguments defined by the provider for this tool.