Skip to content

Commit

Permalink
Add batch size arg (langchain-ai#3310)
Browse files Browse the repository at this point in the history
  • Loading branch information
hinthornw authored Nov 19, 2023
1 parent ca2bc81 commit 0a2b8a6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
9 changes: 6 additions & 3 deletions langchain/src/chat_models/base.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import {
AIMessage,
BaseMessage,
BaseMessageChunk,
BaseMessageLike,
BasePromptValue,
ChatGeneration,
ChatGenerationChunk,
ChatResult,
HumanMessage,
BaseMessageChunk,
LLMResult,
RUN_KEY,
ChatGenerationChunk,
BaseMessageLike,
coerceMessageLikeToMessage,
} from "../schema/index.js";
import {
Expand All @@ -23,6 +23,7 @@ import {
CallbackManagerForLLMRun,
Callbacks,
} from "../callbacks/manager.js";

import { RunnableConfig } from "../schema/runnable/config.js";

/**
Expand Down Expand Up @@ -164,6 +165,7 @@ export abstract class BaseChatModel<
const extra = {
options: callOptions,
invocation_params: this?.invocationParams(callOptions),
batch_size: 1,
};
const runManagers = await callbackManager_?.handleChatModelStart(
this.toJSON(),
Expand Down Expand Up @@ -231,6 +233,7 @@ export abstract class BaseChatModel<
const extra = {
options: parsedOptions,
invocation_params: this?.invocationParams(parsedOptions),
batch_size: 1,
};
const runManagers = await callbackManager_?.handleChatModelStart(
this.toJSON(),
Expand Down
17 changes: 10 additions & 7 deletions langchain/src/llms/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,21 @@ import {
LLMResult,
RUN_KEY,
} from "../schema/index.js";
import {
BaseLanguageModel,
BaseLanguageModelCallOptions,
BaseLanguageModelInput,
BaseLanguageModelParams,
} from "../base_language/index.js";
import {
BaseCallbackConfig,
CallbackManager,
CallbackManagerForLLMRun,
Callbacks,
} from "../callbacks/manager.js";
import { getBufferString } from "../memory/base.js";
import {
BaseLanguageModel,
BaseLanguageModelCallOptions,
BaseLanguageModelInput,
BaseLanguageModelParams,
} from "../base_language/index.js";

import { RunnableConfig } from "../schema/runnable/config.js";
import { getBufferString } from "../memory/base.js";

export type SerializedLLM = {
_model: string;
Expand Down Expand Up @@ -120,6 +121,7 @@ export abstract class BaseLLM<
const extra = {
options: callOptions,
invocation_params: this?.invocationParams(callOptions),
batch_size: 1,
};
const runManagers = await callbackManager_?.handleLLMStart(
this.toJSON(),
Expand Down Expand Up @@ -247,6 +249,7 @@ export abstract class BaseLLM<
const extra = {
options: parsedOptions,
invocation_params: this?.invocationParams(parsedOptions),
batch_size: prompts.length,
};
const runManagers = await callbackManager_?.handleLLMStart(
this.toJSON(),
Expand Down

0 comments on commit 0a2b8a6

Please sign in to comment.