diff --git a/libs/langchain-google-genai/src/chat_models.ts b/libs/langchain-google-genai/src/chat_models.ts index 799cf523a841..fc3096758445 100644 --- a/libs/langchain-google-genai/src/chat_models.ts +++ b/libs/langchain-google-genai/src/chat_models.ts @@ -101,7 +101,7 @@ export interface GoogleGenerativeAIChatInput /** * Controls the randomness of the output. * - * Values can range from [0.0,1.0], inclusive. A value closer to 1.0 + * Values can range from [0.0,2.0], inclusive. A value closer to 2.0 * will produce responses that are more varied and creative, while * a value closer to 0.0 will typically result in less surprising * responses from the model. @@ -644,8 +644,8 @@ export class ChatGoogleGenerativeAI } this.temperature = fields?.temperature ?? this.temperature; - if (this.temperature && (this.temperature < 0 || this.temperature > 1)) { - throw new Error("`temperature` must be in the range of [0.0,1.0]"); + if (this.temperature && (this.temperature < 0 || this.temperature > 2)) { + throw new Error("`temperature` must be in the range of [0.0,2.0]"); } this.topP = fields?.topP ?? this.topP; diff --git a/libs/langchain-google-genai/src/tests/chat_models.test.ts b/libs/langchain-google-genai/src/tests/chat_models.test.ts index 73cc321abd7c..db18639e9939 100644 --- a/libs/langchain-google-genai/src/tests/chat_models.test.ts +++ b/libs/langchain-google-genai/src/tests/chat_models.test.ts @@ -28,7 +28,7 @@ function extractKeys(obj: Record, keys: string[] = []) { return keys; } -test("Google AI - `temperature` must be in range [0.0,1.0]", async () => { +test("Google AI - `temperature` must be in range [0.0,2.0]", async () => { expect( () => new ChatGoogleGenerativeAI({ @@ -38,7 +38,7 @@ test("Google AI - `temperature` must be in range [0.0,1.0]", async () => { expect( () => new ChatGoogleGenerativeAI({ - temperature: 1.1, + temperature: 2.1, }) ).toThrow(); });