Creating Plot Twists
    Preparing search index...

    Type Alias AITool<PARAMETERS, RESULT>

    AITool: {
        inputSchema: TSchema;
        parameters?: PARAMETERS;
        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

    • inputSchema: TSchema

      The schema of the input that the tool expects, expressed as a Typebox schema. The language model uses this to generate (and the runtime to validate) the tool input. Use field descriptions to make the input understandable for the model.

      This is the canonical field read by the runtime. parameters is an accepted alias for backwards compatibility.

    • Optionalparameters?: PARAMETERS

      Alias for inputSchema. Prefer inputSchema.

    • 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.