Skip to content

Commit

Permalink
fix generics for tools
Browse files Browse the repository at this point in the history
  • Loading branch information
bracesproul committed Jun 17, 2024
1 parent c15a318 commit 7627de8
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions langchain-core/src/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ export class ToolInputParsingException extends Error {

export interface StructuredToolInterface<
// eslint-disable-next-line @typescript-eslint/no-explicit-any
T extends z.ZodObject<any, any, any, any> = z.ZodObject<any, any, any, any>,
T extends ZodAny = ZodAny,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
RunOutput = any
RunOutput extends string | Record<string, any> = string
> extends RunnableInterface<
(z.output<T> extends string ? string : never) | z.input<T>,
string
Expand Down Expand Up @@ -79,7 +79,7 @@ export abstract class StructuredTool<
// eslint-disable-next-line @typescript-eslint/no-explicit-any
T extends ZodAny = ZodAny,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
RunOutput = any
RunOutput extends string | Record<string, any> = string
> extends BaseLangChain<
(z.output<T> extends string ? string : never) | z.input<T>,
RunOutput
Expand Down Expand Up @@ -202,7 +202,7 @@ export interface ToolInterface extends StructuredToolInterface {
*/
export abstract class Tool<
// eslint-disable-next-line @typescript-eslint/no-explicit-any
RunOutput = any
RunOutput extends string | Record<string, any> = string
// eslint-disable-next-line @typescript-eslint/no-explicit-any
> extends StructuredTool<any, RunOutput> {
schema = z
Expand Down Expand Up @@ -244,7 +244,7 @@ export interface BaseDynamicToolInput extends ToolParams {
*/
export interface DynamicToolInput<
// eslint-disable-next-line @typescript-eslint/no-explicit-any
RunOutput = any
RunOutput extends string | Record<string, any> = string
> extends BaseDynamicToolInput {
func: (
input: string,
Expand All @@ -260,7 +260,7 @@ export interface DynamicStructuredToolInput<
// eslint-disable-next-line @typescript-eslint/no-explicit-any
T extends ZodAny = ZodAny,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
RunOutput = any
RunOutput extends string | Record<string, any> = string
> extends BaseDynamicToolInput {
func: (
input: z.infer<T>,
Expand All @@ -275,7 +275,7 @@ export interface DynamicStructuredToolInput<
*/
export class DynamicTool<
// eslint-disable-next-line @typescript-eslint/no-explicit-any
RunOutput = any
RunOutput extends string | Record<string, any> = string
> extends Tool<RunOutput> {
static lc_name() {
return "DynamicTool";
Expand Down Expand Up @@ -329,7 +329,7 @@ export class DynamicStructuredTool<
// eslint-disable-next-line @typescript-eslint/no-explicit-any
T extends ZodAny = ZodAny,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
RunOutput = any
RunOutput extends string | Record<string, any> = string
> extends StructuredTool<T, RunOutput> {
static lc_name() {
return "DynamicStructuredTool";
Expand Down Expand Up @@ -396,8 +396,8 @@ export abstract class BaseToolkit {
class _Tool<
RunInput extends ZodAny = ZodAny,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
RunOutput = any
> extends StructuredTool {
RunOutput extends string | Record<string, any> = string
> extends StructuredTool<RunInput, RunOutput> {
name: string;

description: string;
Expand Down Expand Up @@ -444,7 +444,7 @@ class _Tool<
*/
export function tool<
RunInput extends ZodAny, // eslint-disable-next-line @typescript-eslint/no-explicit-any
RunOutput = any
RunOutput extends string | Record<string, any> = string
>(
func: RunnableFunc<RunInput, RunOutput>,
fields: {
Expand Down

0 comments on commit 7627de8

Please sign in to comment.