Skip to content

Commit

Permalink
core[minor]: Allow for simple tool schema to be passed to bindTools
Browse files Browse the repository at this point in the history
  • Loading branch information
bracesproul committed Jul 29, 2024
1 parent c374a01 commit a56b661
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion langchain-core/src/language_models/chat_models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
} from "../callbacks/manager.js";
import type { RunnableConfig } from "../runnables/config.js";
import type { BaseCache } from "../caches/base.js";
import { StructuredToolInterface } from "../tools/index.js";
import { StructuredToolInterface, ToolSchema } from "../tools/index.js";
import {
Runnable,
RunnableLambda,
Expand Down Expand Up @@ -184,6 +184,7 @@ export abstract class BaseChatModel<
| Record<string, unknown>
| ToolDefinition
| RunnableToolLike
| ToolSchema
)[],
kwargs?: Partial<CallOptions>
): Runnable<BaseLanguageModelInput, OutputMessageType, CallOptions>;
Expand Down
15 changes: 15 additions & 0 deletions langchain-core/src/tools/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,21 @@ export interface ToolParams extends BaseLangChainParams {
responseFormat?: ResponseFormat;
}

export interface ToolSchema {
/**
* The name of the tool to pass to the model.
*/
name: string;
/**
* An optional description of the tool to pass to the model.
*/
description?: string;
/**
* A Zod schema representing the parameters of the tool.
*/
schema: ZodObjectAny;
}

export interface StructuredToolInterface<T extends ZodObjectAny = ZodObjectAny>
extends RunnableInterface<
(z.output<T> extends string ? string : never) | z.input<T> | ToolCall,
Expand Down

0 comments on commit a56b661

Please sign in to comment.