Skip to content

Commit

Permalink
cr
Browse files Browse the repository at this point in the history
  • Loading branch information
bracesproul committed Jun 18, 2024
1 parent ca867ce commit d26925d
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 11 deletions.
4 changes: 2 additions & 2 deletions docs/core_docs/docs/how_to/custom_tools.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
":::\n",
"\n",
"\n",
"The [`tool`](https://v02.api.js.langchain.com/classes/langchain_core_tools.tool.html) function is used to wrap a generic JavaScript/TypeScript function, along with additional arguments that define your tool. The `tool` function will return an instance of the [`StructuredTool`](https://v02.api.js.langchain.com/classes/langchain_core_tools.StructuredTool.html) class, so it is compatible with all the existing tool calling infrastructure in the LangChain library."
"The [`tool`](https://api.js.langchain.com/classes/langchain_core_tools.tool.html) function is used to wrap a generic JavaScript/TypeScript function, along with additional arguments that define your tool. The `tool` function will return an instance of the [`StructuredTool`](https://api.js.langchain.com/classes/langchain_core_tools.StructuredTool.html) class, so it is compatible with all the existing tool calling infrastructure in the LangChain library."
]
},
{
Expand All @@ -63,7 +63,7 @@
" a: z.number(),\n",
" b: z.number(),\n",
"});\n",
"const adderTool = tool((input: z.infer<typeof adderSchema>): Promise<string> => {\n",
"const adderTool = tool((input): Promise<string> => {\n",
" const sum = input.a + input.b;\n",
" return Promise.resolve(`The sum of ${input.a} and ${input.b} is ${sum}`);\n",
"}, {\n",
Expand Down
2 changes: 1 addition & 1 deletion langchain-core/src/messages/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export type MessageContentComplex =
| MessageContentText
| MessageContentImageUrl
// eslint-disable-next-line @typescript-eslint/no-explicit-any
| (Record<string, any> & { type?: "text" | "image_url" | "tool" | string })
| (Record<string, any> & { type?: "text" | "image_url" | string })
// eslint-disable-next-line @typescript-eslint/no-explicit-any
| (Record<string, any> & { type?: never });

Expand Down
4 changes: 1 addition & 3 deletions langchain-core/src/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,6 @@ export function tool<RunInput extends ZodAny = ZodAny>(
name: fields.name,
description,
schema: schema as RunInput,
func: (input, _runManager, config) => {
return Promise.resolve(func(input, config));
},
func: async (input, _runManager, config) => func(input, config),
});
}
6 changes: 1 addition & 5 deletions langchain-core/src/tracers/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,11 +392,7 @@ export abstract class BaseTracer extends BaseCallbackHandler {
return run;
}

async handleToolEnd(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
output: string | Record<string, any>,
runId: string
): Promise<Run> {
async handleToolEnd(output: string, runId: string): Promise<Run> {
const run = this.runMap.get(runId);
if (!run || run?.run_type !== "tool") {
throw new Error("No tool run to end");
Expand Down

0 comments on commit d26925d

Please sign in to comment.