@langchain/core
Version:
Core LangChain.js abstractions and schemas
1 lines • 3.83 kB
Source Map (JSON)
{"version":3,"file":"tools.cjs","names":[],"sources":["../../../src/messages/content/tools.ts"],"sourcesContent":["import { BaseContentBlock } from \"./base.js\";\n\nexport type Tools = never;\n\nexport const KNOWN_BLOCK_TYPES = [\n \"tool_call\",\n \"tool_call_chunk\",\n \"invalid_tool_call\",\n \"server_tool_call\",\n \"server_tool_call_chunk\",\n \"server_tool_call_result\",\n];\n\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport declare namespace Tools {\n /**\n * Represents a request to call a tool.\n *\n * @example\n * ```ts\n * const toolCall: ToolCall = {\n * type: \"tool_call\",\n * name: \"foo\",\n * args: { a: 1 },\n * callId: \"123\"\n * };\n * ```\n * This represents a request to call the tool named \"foo\" with arguments {\"a\": 1}\n * and an identifier of \"123\".\n */\n export interface ToolCall<TName extends string = string, TArgs = unknown>\n extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"tool_call\";\n /**\n * The name of the tool being called\n */\n name: TName;\n /**\n * The arguments to the tool call\n */\n args: TArgs;\n }\n\n /** Content block to represent partial data of a tool call */\n export interface ToolCallChunk<TName extends string = string>\n extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"tool_call_chunk\";\n /**\n * The name of the tool being called\n */\n name?: TName;\n /**\n * The arguments to the tool call\n */\n args?: string;\n /**\n * The index of the tool call chunk\n */\n index?: number;\n }\n\n /** Content block to represent an invalid tool call */\n export interface InvalidToolCall<TName extends string = string>\n extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"invalid_tool_call\";\n /**\n * The name of the tool being called\n */\n name?: TName;\n /**\n * The arguments to the tool call\n */\n args?: string;\n /**\n * An error message associated with the tool call\n */\n error?: string;\n /**\n * Index of block in aggregate response\n */\n index?: string | number;\n }\n\n export interface ServerToolCall<\n TName extends string = string,\n TArgs = unknown\n > extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"server_tool_call\";\n /**\n * The name of the tool being called\n */\n name: TName;\n /**\n * The arguments to the tool call\n */\n args: TArgs;\n }\n\n export interface ServerToolCallChunk<TName extends string = string>\n extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"server_tool_call_chunk\";\n /**\n * The name of the tool being called\n */\n name?: TName;\n /**\n * The arguments to the tool call\n */\n args?: string;\n }\n\n export interface ServerToolCallResult<TOutput = Record<string, unknown>>\n extends BaseContentBlock {\n /**\n * Type of the content block\n */\n readonly type: \"server_tool_call_result\";\n /**\n * The unique identifier of the tool call that this result corresponds to\n */\n toolCallId: string;\n /**\n * The status of the server tool call\n */\n status: \"success\" | \"error\";\n /**\n * The output of the server tool call\n */\n output: TOutput;\n }\n\n export type Standard =\n | ToolCall\n | ToolCallChunk\n | InvalidToolCall\n | ServerToolCall\n | ServerToolCallChunk\n | ServerToolCallResult;\n}\n"],"mappings":";;AAIA,MAAa,oBAAoB;CAC/B;CACA;CACA;CACA;CACA;CACA;AACD"}