Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core[minor]: Allow for simple tool schema to be passed to bindTools #14

Open
wants to merge 2 commits into
base: cloned_main_12963
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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