Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
jacoblee93 committed Aug 1, 2024
1 parent 297a791 commit 87ece51
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions langchain-core/src/tools/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ export interface DynamicToolInput extends BaseDynamicToolInput {
* Interface for the input parameters of the DynamicStructuredTool class.
*/
export interface DynamicStructuredToolInput<
// eslint-disable-next-line @typescript-eslint/no-explicit-any
T extends ZodObjectAny | Record<string, any> = ZodObjectAny
> extends BaseDynamicToolInput {
func: (
Expand Down Expand Up @@ -387,6 +388,7 @@ export class DynamicTool extends Tool {
* provided function when the tool is called.
*/
export class DynamicStructuredTool<
// eslint-disable-next-line @typescript-eslint/no-explicit-any
T extends ZodObjectAny | Record<string, any> = ZodObjectAny
> extends StructuredTool<T extends ZodObjectAny ? T : ZodObjectAny> {
static lc_name() {
Expand Down Expand Up @@ -433,6 +435,7 @@ export class DynamicStructuredTool<
runManager?: CallbackManagerForToolRun,
parentConfig?: RunnableConfig
): Promise<ToolReturnType> {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return this.func(arg as any, runManager, parentConfig);
}
}
Expand All @@ -458,6 +461,7 @@ interface ToolWrapperParams<
RunInput extends
| ZodObjectAny
| z.ZodString
// eslint-disable-next-line @typescript-eslint/no-explicit-any
| Record<string, any> = ZodObjectAny
> extends ToolParams {
/**
Expand Down Expand Up @@ -512,12 +516,14 @@ export function tool<T extends ZodObjectAny>(
fields: ToolWrapperParams<T>
): DynamicStructuredTool<T>;

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function tool<T extends Record<string, any>>(
func: RunnableFunc<T, ToolReturnType>,
fields: ToolWrapperParams<T>
): DynamicStructuredTool<T>;

export function tool<
// eslint-disable-next-line @typescript-eslint/no-explicit-any
T extends ZodObjectAny | z.ZodString | Record<string, any> = ZodObjectAny
>(
func: RunnableFunc<T extends ZodObjectAny ? z.output<T> : T, ToolReturnType>,
Expand All @@ -533,6 +539,7 @@ export function tool<
fields.description ??
fields.schema?.description ??
`${fields.name} tool`,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
func: func as any,
});
}
Expand All @@ -543,6 +550,7 @@ export function tool<
return new DynamicStructuredTool<T extends ZodObjectAny ? T : ZodObjectAny>({
...fields,
description,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
schema: fields.schema as any,
// TODO: Consider moving into DynamicStructuredTool constructor
func: async (input, runManager, config) => {
Expand All @@ -554,6 +562,7 @@ export function tool<
childConfig,
async () => {
try {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
resolve(func(input as any, childConfig));
} catch (e) {
reject(e);
Expand Down

0 comments on commit 87ece51

Please sign in to comment.