Skip to content

Commit 89ba4a0

Browse files
JackFenerGiacomoCherrybracesproul
authored
google-common [feature]: Support JSON Mode for Gemini #5071 (#5190)
* google-common [feature]: Support JSON Mode for Gemini #5071 * added mock json file for tests * defined GoogleAIResponseMimeType type * responseMimetype default specified in the GoogleBaseLLM class that implements it * test to make sure the request contains the responseMimeType setting in the generation config * Format llms.test.ts * Format llms.ts * Format types.ts * Nit types.ts jsdoc * Format types.ts --------- Co-authored-by: GiacomoCherry <[email protected]> Co-authored-by: Brace Sproul <[email protected]>
1 parent 1329a61 commit 89ba4a0

File tree

7 files changed

+564
-0
lines changed

7 files changed

+564
-0
lines changed

libs/langchain-google-common/src/connection.ts

+1
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ export abstract class AbstractGoogleLLMConnection<
282282
topP: parameters.topP,
283283
maxOutputTokens: parameters.maxOutputTokens,
284284
stopSequences: parameters.stopSequences,
285+
responseMimeType: parameters.responseMimeType,
285286
};
286287
}
287288

libs/langchain-google-common/src/llms.ts

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
GoogleAISafetySetting,
1616
GooglePlatformType,
1717
GeminiContent,
18+
GoogleAIResponseMimeType,
1819
} from "./types.js";
1920
import {
2021
copyAIModelParams,
@@ -103,6 +104,8 @@ export abstract class GoogleBaseLLM<AuthOptions>
103104

104105
safetyHandler: GoogleAISafetyHandler;
105106

107+
responseMimeType: GoogleAIResponseMimeType = "text/plain";
108+
106109
protected connection: GoogleLLMConnection<AuthOptions>;
107110

108111
protected streamedConnection: GoogleLLMConnection<AuthOptions>;

0 commit comments

Comments
 (0)