Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
jacoblee93 committed Jan 21, 2025
1 parent bd9ca1a commit f7f7944
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
5 changes: 3 additions & 2 deletions langchain-core/src/language_models/chat_models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import {
coerceMessageLikeToMessage,
AIMessageChunk,
isAIMessageChunk,
isBaseMessage,
isAIMessage,
} from "../messages/index.js";
import type { BasePromptValueInterface } from "../prompt_values.js";
import {
Expand Down Expand Up @@ -48,7 +50,6 @@ import { concat } from "../utils/stream.js";
import { RunnablePassthrough } from "../runnables/passthrough.js";
import { isZodSchema } from "../utils/types/is_zod_schema.js";
import { callbackHandlerPrefersStreaming } from "../callbacks/base.js";
import { isAIMessage, isBaseMessage } from "../../messages.js";

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type ToolChoice = string | Record<string, any> | "auto" | "any";
Expand Down Expand Up @@ -351,7 +352,7 @@ export abstract class BaseChatModel<
messageList.map(coerceMessageLikeToMessage)
);

let runManagers;
let runManagers: CallbackManagerForLLMRun[] | undefined;
if (existingRunManagers !== undefined && existingRunManagers.length > 0) {
if (existingRunManagers.length !== baseMessages.length) {
throw new Error(
Expand Down
2 changes: 1 addition & 1 deletion langchain-core/src/language_models/llms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ export abstract class BaseLLM<
handledOptions: BaseCallbackConfig,
existingRunManagers?: CallbackManagerForLLMRun[]
): Promise<LLMResult> {
let runManagers;
let runManagers: CallbackManagerForLLMRun[] | undefined;
if (existingRunManagers !== undefined && existingRunManagers.length > 0) {
if (existingRunManagers.length !== prompts.length) {
throw new Error(
Expand Down
6 changes: 6 additions & 0 deletions libs/langchain-openai/src/tests/chat_models.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,12 @@ test("ChatOpenAI can cache generations", async () => {
expect(lookupSpy).toHaveBeenCalledTimes(2);
expect(updateSpy).toHaveBeenCalledTimes(2);

const res2 = await chat.generate([[message], [message]]);
expect(res2.generations.length).toBe(2);

expect(lookupSpy).toHaveBeenCalledTimes(4);
expect(updateSpy).toHaveBeenCalledTimes(2);

lookupSpy.mockRestore();
updateSpy.mockRestore();
});
Expand Down

0 comments on commit f7f7944

Please sign in to comment.