Skip to content

Commit

Permalink
remove optional base wso implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
bracesproul committed Jun 12, 2024
1 parent e00b73c commit b92a5f7
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 57 deletions.
6 changes: 3 additions & 3 deletions langchain-core/src/language_models/chat_models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ export abstract class BaseChatModel<
return result.content;
}

withStructuredOutput?<
withStructuredOutput<
// eslint-disable-next-line @typescript-eslint/no-explicit-any
RunOutput extends Record<string, any> = Record<string, any>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand All @@ -742,7 +742,7 @@ export abstract class BaseChatModel<
config?: StructuredOutputMethodOptions<false>
): Runnable<BaseLanguageModelInput, RunOutput>;

withStructuredOutput?<
withStructuredOutput<
// eslint-disable-next-line @typescript-eslint/no-explicit-any
RunOutput extends Record<string, any> = Record<string, any>
>(
Expand All @@ -753,7 +753,7 @@ export abstract class BaseChatModel<
config?: StructuredOutputMethodOptions<true>
): Runnable<BaseLanguageModelInput, { raw: BaseMessage; parsed: RunOutput }>;

withStructuredOutput?<
withStructuredOutput<
// eslint-disable-next-line @typescript-eslint/no-explicit-any
RunOutput extends Record<string, any> = Record<string, any>
>(
Expand Down
108 changes: 54 additions & 54 deletions libs/langchain-community/src/chat_models/bedrock/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -763,60 +763,60 @@ export class BedrockChat
return this;
}

withStructuredOutput<
// eslint-disable-next-line @typescript-eslint/no-explicit-any
RunOutput extends Record<string, any> = Record<string, any>
>(
outputSchema:
| z.ZodType<RunOutput>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
| Record<string, any>,
config?: StructuredOutputMethodOptions<false>
): Runnable<BaseLanguageModelInput, RunOutput>;

withStructuredOutput<
// eslint-disable-next-line @typescript-eslint/no-explicit-any
RunOutput extends Record<string, any> = Record<string, any>
>(
outputSchema:
| z.ZodType<RunOutput>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
| Record<string, any>,
config?: StructuredOutputMethodOptions<true>
): Runnable<BaseLanguageModelInput, { raw: BaseMessage; parsed: RunOutput }>;

withStructuredOutput<
// eslint-disable-next-line @typescript-eslint/no-explicit-any
RunOutput extends Record<string, any> = Record<string, any>
>(
outputSchema:
| z.ZodType<RunOutput>
// eslint-disable-next-line @typescript-eslint/no-explicit-any
| Record<string, any>,
config?: StructuredOutputMethodOptions<boolean>
):
| Runnable<BaseLanguageModelInput, RunOutput>
| Runnable<
BaseLanguageModelInput,
{ raw: BaseMessage; parsed: RunOutput }
> {
if (!super.withStructuredOutput) {
throw new Error(`withStructuredOutput is not implemented in the base class.
This is likely due to an outdated version of "@langchain/core".
Please upgrade to the latest version.`);
}
if (config?.includeRaw) {
return super.withStructuredOutput(outputSchema, {
...config,
includeRaw: true,
});
} else {
return super.withStructuredOutput(outputSchema, {
...config,
includeRaw: false,
});
}
}
// withStructuredOutput<
// // eslint-disable-next-line @typescript-eslint/no-explicit-any
// RunOutput extends Record<string, any> = Record<string, any>
// >(
// outputSchema:
// | z.ZodType<RunOutput>
// // eslint-disable-next-line @typescript-eslint/no-explicit-any
// | Record<string, any>,
// config?: StructuredOutputMethodOptions<false>
// ): Runnable<BaseLanguageModelInput, RunOutput>;

// withStructuredOutput<
// // eslint-disable-next-line @typescript-eslint/no-explicit-any
// RunOutput extends Record<string, any> = Record<string, any>
// >(
// outputSchema:
// | z.ZodType<RunOutput>
// // eslint-disable-next-line @typescript-eslint/no-explicit-any
// | Record<string, any>,
// config?: StructuredOutputMethodOptions<true>
// ): Runnable<BaseLanguageModelInput, { raw: BaseMessage; parsed: RunOutput }>;

// withStructuredOutput<
// // eslint-disable-next-line @typescript-eslint/no-explicit-any
// RunOutput extends Record<string, any> = Record<string, any>
// >(
// outputSchema:
// | z.ZodType<RunOutput>
// // eslint-disable-next-line @typescript-eslint/no-explicit-any
// | Record<string, any>,
// config?: StructuredOutputMethodOptions<boolean>
// ):
// | Runnable<BaseLanguageModelInput, RunOutput>
// | Runnable<
// BaseLanguageModelInput,
// { raw: BaseMessage; parsed: RunOutput }
// > {
// if (!super.withStructuredOutput) {
// throw new Error(`withStructuredOutput is not implemented in the base class.
// This is likely due to an outdated version of "@langchain/core".
// Please upgrade to the latest version.`);
// }
// if (config?.includeRaw) {
// return super.withStructuredOutput(outputSchema, {
// ...config,
// includeRaw: true,
// });
// } else {
// return super.withStructuredOutput(outputSchema, {
// ...config,
// includeRaw: false,
// });
// }
// }
}

function isChatGenerationChunk(
Expand Down

0 comments on commit b92a5f7

Please sign in to comment.