@langchain/google 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/LICENSE +21 -0
- package/README.md +97 -0
- package/dist/_virtual/rolldown_runtime.cjs +25 -0
- package/dist/chat_models/api-types.d.cts +1506 -0
- package/dist/chat_models/api-types.d.ts +1506 -0
- package/dist/chat_models/base.cjs +445 -0
- package/dist/chat_models/base.cjs.map +1 -0
- package/dist/chat_models/base.d.cts +319 -0
- package/dist/chat_models/base.d.ts +319 -0
- package/dist/chat_models/base.js +442 -0
- package/dist/chat_models/base.js.map +1 -0
- package/dist/chat_models/index.cjs +23 -0
- package/dist/chat_models/index.cjs.map +1 -0
- package/dist/chat_models/index.d.cts +39 -0
- package/dist/chat_models/index.d.ts +39 -0
- package/dist/chat_models/index.js +22 -0
- package/dist/chat_models/index.js.map +1 -0
- package/dist/chat_models/node.cjs +35 -0
- package/dist/chat_models/node.cjs.map +1 -0
- package/dist/chat_models/node.d.cts +13 -0
- package/dist/chat_models/node.d.ts +13 -0
- package/dist/chat_models/node.js +34 -0
- package/dist/chat_models/node.js.map +1 -0
- package/dist/chat_models/profiles.cjs +373 -0
- package/dist/chat_models/profiles.cjs.map +1 -0
- package/dist/chat_models/profiles.js +372 -0
- package/dist/chat_models/profiles.js.map +1 -0
- package/dist/chat_models/types.d.cts +250 -0
- package/dist/chat_models/types.d.ts +250 -0
- package/dist/clients/index.cjs +219 -0
- package/dist/clients/index.cjs.map +1 -0
- package/dist/clients/index.d.cts +49 -0
- package/dist/clients/index.d.ts +49 -0
- package/dist/clients/index.js +217 -0
- package/dist/clients/index.js.map +1 -0
- package/dist/clients/node.cjs +327 -0
- package/dist/clients/node.cjs.map +1 -0
- package/dist/clients/node.d.cts +59 -0
- package/dist/clients/node.d.ts +59 -0
- package/dist/clients/node.js +325 -0
- package/dist/clients/node.js.map +1 -0
- package/dist/const.cjs +13 -0
- package/dist/const.cjs.map +1 -0
- package/dist/const.js +9 -0
- package/dist/const.js.map +1 -0
- package/dist/converters/messages.cjs +697 -0
- package/dist/converters/messages.cjs.map +1 -0
- package/dist/converters/messages.js +691 -0
- package/dist/converters/messages.js.map +1 -0
- package/dist/converters/params.cjs +205 -0
- package/dist/converters/params.cjs.map +1 -0
- package/dist/converters/params.js +202 -0
- package/dist/converters/params.js.map +1 -0
- package/dist/converters/tools.cjs +356 -0
- package/dist/converters/tools.cjs.map +1 -0
- package/dist/converters/tools.js +353 -0
- package/dist/converters/tools.js.map +1 -0
- package/dist/index.cjs +7 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +4 -0
- package/dist/node.cjs +7 -0
- package/dist/node.d.cts +3 -0
- package/dist/node.d.ts +3 -0
- package/dist/node.js +4 -0
- package/dist/utils/errors.cjs +543 -0
- package/dist/utils/errors.cjs.map +1 -0
- package/dist/utils/errors.js +535 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/gcp-auth.cjs +188 -0
- package/dist/utils/gcp-auth.cjs.map +1 -0
- package/dist/utils/gcp-auth.d.cts +43 -0
- package/dist/utils/gcp-auth.d.ts +43 -0
- package/dist/utils/gcp-auth.js +186 -0
- package/dist/utils/gcp-auth.js.map +1 -0
- package/dist/utils/handler.cjs +67 -0
- package/dist/utils/handler.cjs.map +1 -0
- package/dist/utils/handler.d.cts +34 -0
- package/dist/utils/handler.d.ts +34 -0
- package/dist/utils/handler.js +64 -0
- package/dist/utils/handler.js.map +1 -0
- package/dist/utils/misc.cjs +10 -0
- package/dist/utils/misc.cjs.map +1 -0
- package/dist/utils/misc.d.cts +14 -0
- package/dist/utils/misc.d.ts +14 -0
- package/dist/utils/misc.js +9 -0
- package/dist/utils/misc.js.map +1 -0
- package/dist/utils/stream.cjs +26 -0
- package/dist/utils/stream.cjs.map +1 -0
- package/dist/utils/stream.js +25 -0
- package/dist/utils/stream.js.map +1 -0
- package/package.json +96 -0
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import { Prettify } from "../utils/misc.cjs";
|
|
2
|
+
import { ApiClient } from "../clients/index.cjs";
|
|
3
|
+
import { Gemini } from "./api-types.cjs";
|
|
4
|
+
import { ChatGoogleFields } from "./types.cjs";
|
|
5
|
+
import { BaseChatModel, BaseChatModelCallOptions, BaseChatModelParams, BindToolsInput } from "@langchain/core/language_models/chat_models";
|
|
6
|
+
import { AIMessageChunk, BaseMessage } from "@langchain/core/messages";
|
|
7
|
+
import { CallbackManagerForLLMRun } from "@langchain/core/callbacks/manager";
|
|
8
|
+
import { ChatGenerationChunk, ChatResult } from "@langchain/core/outputs";
|
|
9
|
+
import { ModelProfile } from "@langchain/core/language_models/profile";
|
|
10
|
+
import { BaseLanguageModelInput, StructuredOutputMethodOptions } from "@langchain/core/language_models/base";
|
|
11
|
+
import { Runnable } from "@langchain/core/runnables";
|
|
12
|
+
import { JsonSchema7Type } from "@langchain/core/utils/json_schema";
|
|
13
|
+
import { InteropZodType } from "@langchain/core/utils/types";
|
|
14
|
+
|
|
15
|
+
//#region src/chat_models/base.d.ts
|
|
16
|
+
type GooglePlatformType = "gai" | "gcp";
|
|
17
|
+
interface BaseChatGoogleParams extends BaseChatModelParams, ChatGoogleFields {
|
|
18
|
+
/**
|
|
19
|
+
* The name of the Gemini model to use.
|
|
20
|
+
*
|
|
21
|
+
* Example: "gemini-3-pro-preview"
|
|
22
|
+
*/
|
|
23
|
+
model: string;
|
|
24
|
+
/**
|
|
25
|
+
* Optional. The API client implementation for making HTTP requests to the Gemini API.
|
|
26
|
+
* If not set, a default client will be used based on the runtime environment.
|
|
27
|
+
*/
|
|
28
|
+
apiClient?: ApiClient;
|
|
29
|
+
/**
|
|
30
|
+
* Hostname for the API call (if this is running on GCP)
|
|
31
|
+
* Usually this is computed based on location and platformType.
|
|
32
|
+
**/
|
|
33
|
+
endpoint?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Region where the LLM is stored (if this is running on GCP)
|
|
36
|
+
* Defaults to "global"
|
|
37
|
+
**/
|
|
38
|
+
location?: string;
|
|
39
|
+
/**
|
|
40
|
+
* The version of the API functions. Part of the path.
|
|
41
|
+
* Usually this is computed based on platformType.
|
|
42
|
+
**/
|
|
43
|
+
apiVersion?: string;
|
|
44
|
+
/**
|
|
45
|
+
* What platform to run the service on.
|
|
46
|
+
* If not specified, the class should determine this from other
|
|
47
|
+
* means. Either way, the platform actually used will be in
|
|
48
|
+
* the "platform" getter.
|
|
49
|
+
*/
|
|
50
|
+
platformType?: GooglePlatformType;
|
|
51
|
+
/**
|
|
52
|
+
* For compatibility with Google's libraries, should this use Vertex?
|
|
53
|
+
* The "platformType" parmeter takes precedence.
|
|
54
|
+
*/
|
|
55
|
+
vertexai?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Backwards compatibility.
|
|
58
|
+
* @deprecated in favor of using `disableStreaming` or `.stream()`
|
|
59
|
+
*/
|
|
60
|
+
streaming?: boolean;
|
|
61
|
+
streamUsage?: boolean;
|
|
62
|
+
}
|
|
63
|
+
interface BaseChatGoogleCallOptions extends BaseChatModelCallOptions, ChatGoogleFields {}
|
|
64
|
+
declare abstract class BaseChatGoogle<CallOptions extends BaseChatGoogleCallOptions = BaseChatGoogleCallOptions> extends BaseChatModel<CallOptions, AIMessageChunk> {
|
|
65
|
+
protected params: BaseChatGoogleParams;
|
|
66
|
+
model: string;
|
|
67
|
+
streaming: boolean;
|
|
68
|
+
disableStreaming: boolean;
|
|
69
|
+
streamUsage: boolean;
|
|
70
|
+
protected _platform?: GooglePlatformType;
|
|
71
|
+
protected _endpoint?: string;
|
|
72
|
+
protected _location?: string;
|
|
73
|
+
protected _apiVersion?: string;
|
|
74
|
+
protected apiClient: ApiClient;
|
|
75
|
+
constructor(params: BaseChatGoogleParams);
|
|
76
|
+
_llmType(): string;
|
|
77
|
+
protected get platformType(): GooglePlatformType | undefined;
|
|
78
|
+
protected get platform(): GooglePlatformType;
|
|
79
|
+
protected get isVertexExpress(): boolean;
|
|
80
|
+
protected get apiVersion(): string;
|
|
81
|
+
protected get location(): string;
|
|
82
|
+
protected get endpoint(): string;
|
|
83
|
+
protected get publisher(): string;
|
|
84
|
+
protected get urlMethod(): string;
|
|
85
|
+
/**
|
|
86
|
+
* Returns the model profile for this instance's model, describing its
|
|
87
|
+
* capabilities and constraints (e.g. max tokens, input/output modalities,
|
|
88
|
+
* tool calling support).
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* const model = new ChatGoogle({ model: "gemini-2.5-pro" });
|
|
93
|
+
* const profile = model.profile;
|
|
94
|
+
* console.log(profile.maxInputTokens); // 1048576
|
|
95
|
+
* console.log(profile.imageInputs); // true
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
get profile(): ModelProfile;
|
|
99
|
+
protected buildUrlGemini(urlMethod?: string): Promise<string>;
|
|
100
|
+
protected buildUrlVertexExpress(urlMethod?: string): Promise<string>;
|
|
101
|
+
protected buildUrlVertexLocation(urlMethod?: string): Promise<string>;
|
|
102
|
+
protected buildUrlVertex(urlMethod?: string): Promise<string>;
|
|
103
|
+
protected buildUrl(urlMethod?: string): Promise<string>;
|
|
104
|
+
invocationParams(options: this["ParsedCallOptions"]): {
|
|
105
|
+
tools?: Gemini.Tool[] | undefined;
|
|
106
|
+
toolConfig?: Gemini.Tools.ToolConfig | undefined;
|
|
107
|
+
safetySettings: {
|
|
108
|
+
category: "HARM_CATEGORY_CIVIC_INTEGRITY" | "HARM_CATEGORY_DANGEROUS" | "HARM_CATEGORY_DANGEROUS_CONTENT" | "HARM_CATEGORY_DEROGATORY" | "HARM_CATEGORY_HARASSMENT" | "HARM_CATEGORY_HATE_SPEECH" | "HARM_CATEGORY_MEDICAL" | "HARM_CATEGORY_SEXUAL" | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | "HARM_CATEGORY_TOXICITY" | "HARM_CATEGORY_UNSPECIFIED" | "HARM_CATEGORY_VIOLENCE" | {
|
|
109
|
+
readonly [x: number]: string;
|
|
110
|
+
toString: {};
|
|
111
|
+
charAt: {};
|
|
112
|
+
charCodeAt: {};
|
|
113
|
+
concat: {};
|
|
114
|
+
indexOf: {};
|
|
115
|
+
lastIndexOf: {};
|
|
116
|
+
localeCompare: {};
|
|
117
|
+
match: {};
|
|
118
|
+
replace: {};
|
|
119
|
+
search: {};
|
|
120
|
+
slice: {};
|
|
121
|
+
split: {};
|
|
122
|
+
substring: {};
|
|
123
|
+
toLowerCase: {};
|
|
124
|
+
toLocaleLowerCase: {};
|
|
125
|
+
toUpperCase: {};
|
|
126
|
+
toLocaleUpperCase: {};
|
|
127
|
+
trim: {};
|
|
128
|
+
readonly length: number;
|
|
129
|
+
substr: {};
|
|
130
|
+
valueOf: {};
|
|
131
|
+
codePointAt: {};
|
|
132
|
+
includes: {};
|
|
133
|
+
endsWith: {};
|
|
134
|
+
normalize: {};
|
|
135
|
+
repeat: {};
|
|
136
|
+
startsWith: {};
|
|
137
|
+
anchor: {};
|
|
138
|
+
big: {};
|
|
139
|
+
blink: {};
|
|
140
|
+
bold: {};
|
|
141
|
+
fixed: {};
|
|
142
|
+
fontcolor: {};
|
|
143
|
+
fontsize: {};
|
|
144
|
+
italics: {};
|
|
145
|
+
link: {};
|
|
146
|
+
small: {};
|
|
147
|
+
strike: {};
|
|
148
|
+
sub: {};
|
|
149
|
+
sup: {};
|
|
150
|
+
[Symbol.iterator]: {};
|
|
151
|
+
padStart: {};
|
|
152
|
+
padEnd: {};
|
|
153
|
+
trimEnd: {};
|
|
154
|
+
trimStart: {};
|
|
155
|
+
trimLeft: {};
|
|
156
|
+
trimRight: {};
|
|
157
|
+
matchAll: {};
|
|
158
|
+
replaceAll: {};
|
|
159
|
+
};
|
|
160
|
+
threshold: "BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_NONE" | "BLOCK_ONLY_HIGH" | "HARM_BLOCK_THRESHOLD_UNSPECIFIED" | "OFF" | {
|
|
161
|
+
readonly [x: number]: string;
|
|
162
|
+
toString: {};
|
|
163
|
+
charAt: {};
|
|
164
|
+
charCodeAt: {};
|
|
165
|
+
concat: {};
|
|
166
|
+
indexOf: {};
|
|
167
|
+
lastIndexOf: {};
|
|
168
|
+
localeCompare: {};
|
|
169
|
+
match: {};
|
|
170
|
+
replace: {};
|
|
171
|
+
search: {};
|
|
172
|
+
slice: {};
|
|
173
|
+
split: {};
|
|
174
|
+
substring: {};
|
|
175
|
+
toLowerCase: {};
|
|
176
|
+
toLocaleLowerCase: {};
|
|
177
|
+
toUpperCase: {};
|
|
178
|
+
toLocaleUpperCase: {};
|
|
179
|
+
trim: {};
|
|
180
|
+
readonly length: number;
|
|
181
|
+
substr: {};
|
|
182
|
+
valueOf: {};
|
|
183
|
+
codePointAt: {};
|
|
184
|
+
includes: {};
|
|
185
|
+
endsWith: {};
|
|
186
|
+
normalize: {};
|
|
187
|
+
repeat: {};
|
|
188
|
+
startsWith: {};
|
|
189
|
+
anchor: {};
|
|
190
|
+
big: {};
|
|
191
|
+
blink: {};
|
|
192
|
+
bold: {};
|
|
193
|
+
fixed: {};
|
|
194
|
+
fontcolor: {};
|
|
195
|
+
fontsize: {};
|
|
196
|
+
italics: {};
|
|
197
|
+
link: {};
|
|
198
|
+
small: {};
|
|
199
|
+
strike: {};
|
|
200
|
+
sub: {};
|
|
201
|
+
sup: {};
|
|
202
|
+
[Symbol.iterator]: {};
|
|
203
|
+
padStart: {};
|
|
204
|
+
padEnd: {};
|
|
205
|
+
trimEnd: {};
|
|
206
|
+
trimStart: {};
|
|
207
|
+
trimLeft: {};
|
|
208
|
+
trimRight: {};
|
|
209
|
+
matchAll: {};
|
|
210
|
+
replaceAll: {};
|
|
211
|
+
};
|
|
212
|
+
}[] | undefined;
|
|
213
|
+
generationConfig: {
|
|
214
|
+
temperature: number | undefined;
|
|
215
|
+
topP: number | undefined;
|
|
216
|
+
topK: number | undefined;
|
|
217
|
+
maxOutputTokens: number | undefined;
|
|
218
|
+
presencePenalty: number | undefined;
|
|
219
|
+
frequencyPenalty: number | undefined;
|
|
220
|
+
stopSequences: string[] | undefined;
|
|
221
|
+
responseMimeType?: string | undefined;
|
|
222
|
+
responseJsonSchema?: Record<string, unknown> | JsonSchema7Type | undefined;
|
|
223
|
+
responseModalities?: Prettify<Gemini.GenerativeLanguageModality>[] | undefined;
|
|
224
|
+
candidateCount: number;
|
|
225
|
+
seed: number | undefined;
|
|
226
|
+
responseLogprobs: boolean | undefined;
|
|
227
|
+
logprobs: number | undefined;
|
|
228
|
+
enableEnhancedCivicAnswers?: boolean | undefined;
|
|
229
|
+
thinkingConfig: Gemini.ThinkingConfig | undefined;
|
|
230
|
+
speechConfig: Gemini.SpeechConfig | undefined;
|
|
231
|
+
imageConfig?: {
|
|
232
|
+
aspectRatio?: string | undefined;
|
|
233
|
+
imageSize?: string | undefined;
|
|
234
|
+
} | undefined;
|
|
235
|
+
mediaResolution?: {
|
|
236
|
+
level?: "MEDIA_RESOLUTION_HIGH" | "MEDIA_RESOLUTION_LOW" | "MEDIA_RESOLUTION_MEDIUM" | "MEDIA_RESOLUTION_ULTRA_HIGH" | "MEDIA_RESOLUTION_UNSPECIFIED" | {
|
|
237
|
+
readonly [x: number]: string;
|
|
238
|
+
toString: {};
|
|
239
|
+
charAt: {};
|
|
240
|
+
charCodeAt: {};
|
|
241
|
+
concat: {};
|
|
242
|
+
indexOf: {};
|
|
243
|
+
lastIndexOf: {};
|
|
244
|
+
localeCompare: {};
|
|
245
|
+
match: {};
|
|
246
|
+
replace: {};
|
|
247
|
+
search: {};
|
|
248
|
+
slice: {};
|
|
249
|
+
split: {};
|
|
250
|
+
substring: {};
|
|
251
|
+
toLowerCase: {};
|
|
252
|
+
toLocaleLowerCase: {};
|
|
253
|
+
toUpperCase: {};
|
|
254
|
+
toLocaleUpperCase: {};
|
|
255
|
+
trim: {};
|
|
256
|
+
readonly length: number;
|
|
257
|
+
substr: {};
|
|
258
|
+
valueOf: {};
|
|
259
|
+
codePointAt: {};
|
|
260
|
+
includes: {};
|
|
261
|
+
endsWith: {};
|
|
262
|
+
normalize: {};
|
|
263
|
+
repeat: {};
|
|
264
|
+
startsWith: {};
|
|
265
|
+
anchor: {};
|
|
266
|
+
big: {};
|
|
267
|
+
blink: {};
|
|
268
|
+
bold: {};
|
|
269
|
+
fixed: {};
|
|
270
|
+
fontcolor: {};
|
|
271
|
+
fontsize: {};
|
|
272
|
+
italics: {};
|
|
273
|
+
link: {};
|
|
274
|
+
small: {};
|
|
275
|
+
strike: {};
|
|
276
|
+
sub: {};
|
|
277
|
+
sup: {};
|
|
278
|
+
[Symbol.iterator]: {};
|
|
279
|
+
padStart: {};
|
|
280
|
+
padEnd: {};
|
|
281
|
+
trimEnd: {};
|
|
282
|
+
trimStart: {};
|
|
283
|
+
trimLeft: {};
|
|
284
|
+
trimRight: {};
|
|
285
|
+
matchAll: {};
|
|
286
|
+
replaceAll: {};
|
|
287
|
+
} | undefined;
|
|
288
|
+
} | undefined;
|
|
289
|
+
};
|
|
290
|
+
};
|
|
291
|
+
_generate(messages: BaseMessage[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): Promise<ChatResult>;
|
|
292
|
+
_streamResponseChunks(messages: BaseMessage[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatGenerationChunk>;
|
|
293
|
+
/**
|
|
294
|
+
* Bind tool-like objects to this chat model.
|
|
295
|
+
*
|
|
296
|
+
* @param tools A list of tool definitions to bind to this chat model.
|
|
297
|
+
* Can be a structured tool, an OpenAI formatted tool, or a Gemini function declaration.
|
|
298
|
+
* @param kwargs Any additional parameters to bind.
|
|
299
|
+
*/
|
|
300
|
+
bindTools(tools: BindToolsInput[], kwargs?: Partial<CallOptions>): Runnable<BaseMessage[], AIMessageChunk, CallOptions>;
|
|
301
|
+
/**
|
|
302
|
+
* Get structured output from the model based on a schema.
|
|
303
|
+
*
|
|
304
|
+
* This method supports two modes:
|
|
305
|
+
* - `jsonMode`: Uses `responseSchema` to get JSON responses directly (preferred for structured outputs)
|
|
306
|
+
* - `functionCalling`: Uses function calling with tools (default, for compatibility)
|
|
307
|
+
*
|
|
308
|
+
* @param outputSchema - The schema to use for structured output (Zod schema or JSON Schema)
|
|
309
|
+
* @param config - Configuration options including method and whether to include raw response
|
|
310
|
+
* @returns A Runnable that returns the parsed structured output
|
|
311
|
+
*/
|
|
312
|
+
withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput> | Record<string, any>, config?: StructuredOutputMethodOptions<boolean>): Runnable<BaseLanguageModelInput, RunOutput> | Runnable<BaseLanguageModelInput, {
|
|
313
|
+
raw: BaseMessage;
|
|
314
|
+
parsed: RunOutput;
|
|
315
|
+
}>;
|
|
316
|
+
}
|
|
317
|
+
//#endregion
|
|
318
|
+
export { BaseChatGoogle, BaseChatGoogleCallOptions, BaseChatGoogleParams };
|
|
319
|
+
//# sourceMappingURL=base.d.cts.map
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import { Prettify } from "../utils/misc.js";
|
|
2
|
+
import { ApiClient } from "../clients/index.js";
|
|
3
|
+
import { Gemini } from "./api-types.js";
|
|
4
|
+
import { ChatGoogleFields } from "./types.js";
|
|
5
|
+
import { BaseChatModel, BaseChatModelCallOptions, BaseChatModelParams, BindToolsInput } from "@langchain/core/language_models/chat_models";
|
|
6
|
+
import { AIMessageChunk, BaseMessage } from "@langchain/core/messages";
|
|
7
|
+
import { ChatGenerationChunk, ChatResult } from "@langchain/core/outputs";
|
|
8
|
+
import { Runnable } from "@langchain/core/runnables";
|
|
9
|
+
import { JsonSchema7Type } from "@langchain/core/utils/json_schema";
|
|
10
|
+
import { InteropZodType } from "@langchain/core/utils/types";
|
|
11
|
+
import { BaseLanguageModelInput, StructuredOutputMethodOptions } from "@langchain/core/language_models/base";
|
|
12
|
+
import { CallbackManagerForLLMRun } from "@langchain/core/callbacks/manager";
|
|
13
|
+
import { ModelProfile } from "@langchain/core/language_models/profile";
|
|
14
|
+
|
|
15
|
+
//#region src/chat_models/base.d.ts
|
|
16
|
+
type GooglePlatformType = "gai" | "gcp";
|
|
17
|
+
interface BaseChatGoogleParams extends BaseChatModelParams, ChatGoogleFields {
|
|
18
|
+
/**
|
|
19
|
+
* The name of the Gemini model to use.
|
|
20
|
+
*
|
|
21
|
+
* Example: "gemini-3-pro-preview"
|
|
22
|
+
*/
|
|
23
|
+
model: string;
|
|
24
|
+
/**
|
|
25
|
+
* Optional. The API client implementation for making HTTP requests to the Gemini API.
|
|
26
|
+
* If not set, a default client will be used based on the runtime environment.
|
|
27
|
+
*/
|
|
28
|
+
apiClient?: ApiClient;
|
|
29
|
+
/**
|
|
30
|
+
* Hostname for the API call (if this is running on GCP)
|
|
31
|
+
* Usually this is computed based on location and platformType.
|
|
32
|
+
**/
|
|
33
|
+
endpoint?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Region where the LLM is stored (if this is running on GCP)
|
|
36
|
+
* Defaults to "global"
|
|
37
|
+
**/
|
|
38
|
+
location?: string;
|
|
39
|
+
/**
|
|
40
|
+
* The version of the API functions. Part of the path.
|
|
41
|
+
* Usually this is computed based on platformType.
|
|
42
|
+
**/
|
|
43
|
+
apiVersion?: string;
|
|
44
|
+
/**
|
|
45
|
+
* What platform to run the service on.
|
|
46
|
+
* If not specified, the class should determine this from other
|
|
47
|
+
* means. Either way, the platform actually used will be in
|
|
48
|
+
* the "platform" getter.
|
|
49
|
+
*/
|
|
50
|
+
platformType?: GooglePlatformType;
|
|
51
|
+
/**
|
|
52
|
+
* For compatibility with Google's libraries, should this use Vertex?
|
|
53
|
+
* The "platformType" parmeter takes precedence.
|
|
54
|
+
*/
|
|
55
|
+
vertexai?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Backwards compatibility.
|
|
58
|
+
* @deprecated in favor of using `disableStreaming` or `.stream()`
|
|
59
|
+
*/
|
|
60
|
+
streaming?: boolean;
|
|
61
|
+
streamUsage?: boolean;
|
|
62
|
+
}
|
|
63
|
+
interface BaseChatGoogleCallOptions extends BaseChatModelCallOptions, ChatGoogleFields {}
|
|
64
|
+
declare abstract class BaseChatGoogle<CallOptions extends BaseChatGoogleCallOptions = BaseChatGoogleCallOptions> extends BaseChatModel<CallOptions, AIMessageChunk> {
|
|
65
|
+
protected params: BaseChatGoogleParams;
|
|
66
|
+
model: string;
|
|
67
|
+
streaming: boolean;
|
|
68
|
+
disableStreaming: boolean;
|
|
69
|
+
streamUsage: boolean;
|
|
70
|
+
protected _platform?: GooglePlatformType;
|
|
71
|
+
protected _endpoint?: string;
|
|
72
|
+
protected _location?: string;
|
|
73
|
+
protected _apiVersion?: string;
|
|
74
|
+
protected apiClient: ApiClient;
|
|
75
|
+
constructor(params: BaseChatGoogleParams);
|
|
76
|
+
_llmType(): string;
|
|
77
|
+
protected get platformType(): GooglePlatformType | undefined;
|
|
78
|
+
protected get platform(): GooglePlatformType;
|
|
79
|
+
protected get isVertexExpress(): boolean;
|
|
80
|
+
protected get apiVersion(): string;
|
|
81
|
+
protected get location(): string;
|
|
82
|
+
protected get endpoint(): string;
|
|
83
|
+
protected get publisher(): string;
|
|
84
|
+
protected get urlMethod(): string;
|
|
85
|
+
/**
|
|
86
|
+
* Returns the model profile for this instance's model, describing its
|
|
87
|
+
* capabilities and constraints (e.g. max tokens, input/output modalities,
|
|
88
|
+
* tool calling support).
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* const model = new ChatGoogle({ model: "gemini-2.5-pro" });
|
|
93
|
+
* const profile = model.profile;
|
|
94
|
+
* console.log(profile.maxInputTokens); // 1048576
|
|
95
|
+
* console.log(profile.imageInputs); // true
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
get profile(): ModelProfile;
|
|
99
|
+
protected buildUrlGemini(urlMethod?: string): Promise<string>;
|
|
100
|
+
protected buildUrlVertexExpress(urlMethod?: string): Promise<string>;
|
|
101
|
+
protected buildUrlVertexLocation(urlMethod?: string): Promise<string>;
|
|
102
|
+
protected buildUrlVertex(urlMethod?: string): Promise<string>;
|
|
103
|
+
protected buildUrl(urlMethod?: string): Promise<string>;
|
|
104
|
+
invocationParams(options: this["ParsedCallOptions"]): {
|
|
105
|
+
tools?: Gemini.Tool[] | undefined;
|
|
106
|
+
toolConfig?: Gemini.Tools.ToolConfig | undefined;
|
|
107
|
+
safetySettings: {
|
|
108
|
+
category: "HARM_CATEGORY_CIVIC_INTEGRITY" | "HARM_CATEGORY_DANGEROUS" | "HARM_CATEGORY_DANGEROUS_CONTENT" | "HARM_CATEGORY_DEROGATORY" | "HARM_CATEGORY_HARASSMENT" | "HARM_CATEGORY_HATE_SPEECH" | "HARM_CATEGORY_MEDICAL" | "HARM_CATEGORY_SEXUAL" | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | "HARM_CATEGORY_TOXICITY" | "HARM_CATEGORY_UNSPECIFIED" | "HARM_CATEGORY_VIOLENCE" | {
|
|
109
|
+
readonly [x: number]: string;
|
|
110
|
+
toString: {};
|
|
111
|
+
charAt: {};
|
|
112
|
+
charCodeAt: {};
|
|
113
|
+
concat: {};
|
|
114
|
+
indexOf: {};
|
|
115
|
+
lastIndexOf: {};
|
|
116
|
+
localeCompare: {};
|
|
117
|
+
match: {};
|
|
118
|
+
replace: {};
|
|
119
|
+
search: {};
|
|
120
|
+
slice: {};
|
|
121
|
+
split: {};
|
|
122
|
+
substring: {};
|
|
123
|
+
toLowerCase: {};
|
|
124
|
+
toLocaleLowerCase: {};
|
|
125
|
+
toUpperCase: {};
|
|
126
|
+
toLocaleUpperCase: {};
|
|
127
|
+
trim: {};
|
|
128
|
+
readonly length: number;
|
|
129
|
+
substr: {};
|
|
130
|
+
valueOf: {};
|
|
131
|
+
codePointAt: {};
|
|
132
|
+
includes: {};
|
|
133
|
+
endsWith: {};
|
|
134
|
+
normalize: {};
|
|
135
|
+
repeat: {};
|
|
136
|
+
startsWith: {};
|
|
137
|
+
anchor: {};
|
|
138
|
+
big: {};
|
|
139
|
+
blink: {};
|
|
140
|
+
bold: {};
|
|
141
|
+
fixed: {};
|
|
142
|
+
fontcolor: {};
|
|
143
|
+
fontsize: {};
|
|
144
|
+
italics: {};
|
|
145
|
+
link: {};
|
|
146
|
+
small: {};
|
|
147
|
+
strike: {};
|
|
148
|
+
sub: {};
|
|
149
|
+
sup: {};
|
|
150
|
+
[Symbol.iterator]: {};
|
|
151
|
+
padStart: {};
|
|
152
|
+
padEnd: {};
|
|
153
|
+
trimEnd: {};
|
|
154
|
+
trimStart: {};
|
|
155
|
+
trimLeft: {};
|
|
156
|
+
trimRight: {};
|
|
157
|
+
matchAll: {};
|
|
158
|
+
replaceAll: {};
|
|
159
|
+
};
|
|
160
|
+
threshold: "BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_NONE" | "BLOCK_ONLY_HIGH" | "HARM_BLOCK_THRESHOLD_UNSPECIFIED" | "OFF" | {
|
|
161
|
+
readonly [x: number]: string;
|
|
162
|
+
toString: {};
|
|
163
|
+
charAt: {};
|
|
164
|
+
charCodeAt: {};
|
|
165
|
+
concat: {};
|
|
166
|
+
indexOf: {};
|
|
167
|
+
lastIndexOf: {};
|
|
168
|
+
localeCompare: {};
|
|
169
|
+
match: {};
|
|
170
|
+
replace: {};
|
|
171
|
+
search: {};
|
|
172
|
+
slice: {};
|
|
173
|
+
split: {};
|
|
174
|
+
substring: {};
|
|
175
|
+
toLowerCase: {};
|
|
176
|
+
toLocaleLowerCase: {};
|
|
177
|
+
toUpperCase: {};
|
|
178
|
+
toLocaleUpperCase: {};
|
|
179
|
+
trim: {};
|
|
180
|
+
readonly length: number;
|
|
181
|
+
substr: {};
|
|
182
|
+
valueOf: {};
|
|
183
|
+
codePointAt: {};
|
|
184
|
+
includes: {};
|
|
185
|
+
endsWith: {};
|
|
186
|
+
normalize: {};
|
|
187
|
+
repeat: {};
|
|
188
|
+
startsWith: {};
|
|
189
|
+
anchor: {};
|
|
190
|
+
big: {};
|
|
191
|
+
blink: {};
|
|
192
|
+
bold: {};
|
|
193
|
+
fixed: {};
|
|
194
|
+
fontcolor: {};
|
|
195
|
+
fontsize: {};
|
|
196
|
+
italics: {};
|
|
197
|
+
link: {};
|
|
198
|
+
small: {};
|
|
199
|
+
strike: {};
|
|
200
|
+
sub: {};
|
|
201
|
+
sup: {};
|
|
202
|
+
[Symbol.iterator]: {};
|
|
203
|
+
padStart: {};
|
|
204
|
+
padEnd: {};
|
|
205
|
+
trimEnd: {};
|
|
206
|
+
trimStart: {};
|
|
207
|
+
trimLeft: {};
|
|
208
|
+
trimRight: {};
|
|
209
|
+
matchAll: {};
|
|
210
|
+
replaceAll: {};
|
|
211
|
+
};
|
|
212
|
+
}[] | undefined;
|
|
213
|
+
generationConfig: {
|
|
214
|
+
temperature: number | undefined;
|
|
215
|
+
topP: number | undefined;
|
|
216
|
+
topK: number | undefined;
|
|
217
|
+
maxOutputTokens: number | undefined;
|
|
218
|
+
presencePenalty: number | undefined;
|
|
219
|
+
frequencyPenalty: number | undefined;
|
|
220
|
+
stopSequences: string[] | undefined;
|
|
221
|
+
responseMimeType?: string | undefined;
|
|
222
|
+
responseJsonSchema?: Record<string, unknown> | JsonSchema7Type | undefined;
|
|
223
|
+
responseModalities?: Prettify<Gemini.GenerativeLanguageModality>[] | undefined;
|
|
224
|
+
candidateCount: number;
|
|
225
|
+
seed: number | undefined;
|
|
226
|
+
responseLogprobs: boolean | undefined;
|
|
227
|
+
logprobs: number | undefined;
|
|
228
|
+
enableEnhancedCivicAnswers?: boolean | undefined;
|
|
229
|
+
thinkingConfig: Gemini.ThinkingConfig | undefined;
|
|
230
|
+
speechConfig: Gemini.SpeechConfig | undefined;
|
|
231
|
+
imageConfig?: {
|
|
232
|
+
aspectRatio?: string | undefined;
|
|
233
|
+
imageSize?: string | undefined;
|
|
234
|
+
} | undefined;
|
|
235
|
+
mediaResolution?: {
|
|
236
|
+
level?: "MEDIA_RESOLUTION_HIGH" | "MEDIA_RESOLUTION_LOW" | "MEDIA_RESOLUTION_MEDIUM" | "MEDIA_RESOLUTION_ULTRA_HIGH" | "MEDIA_RESOLUTION_UNSPECIFIED" | {
|
|
237
|
+
readonly [x: number]: string;
|
|
238
|
+
toString: {};
|
|
239
|
+
charAt: {};
|
|
240
|
+
charCodeAt: {};
|
|
241
|
+
concat: {};
|
|
242
|
+
indexOf: {};
|
|
243
|
+
lastIndexOf: {};
|
|
244
|
+
localeCompare: {};
|
|
245
|
+
match: {};
|
|
246
|
+
replace: {};
|
|
247
|
+
search: {};
|
|
248
|
+
slice: {};
|
|
249
|
+
split: {};
|
|
250
|
+
substring: {};
|
|
251
|
+
toLowerCase: {};
|
|
252
|
+
toLocaleLowerCase: {};
|
|
253
|
+
toUpperCase: {};
|
|
254
|
+
toLocaleUpperCase: {};
|
|
255
|
+
trim: {};
|
|
256
|
+
readonly length: number;
|
|
257
|
+
substr: {};
|
|
258
|
+
valueOf: {};
|
|
259
|
+
codePointAt: {};
|
|
260
|
+
includes: {};
|
|
261
|
+
endsWith: {};
|
|
262
|
+
normalize: {};
|
|
263
|
+
repeat: {};
|
|
264
|
+
startsWith: {};
|
|
265
|
+
anchor: {};
|
|
266
|
+
big: {};
|
|
267
|
+
blink: {};
|
|
268
|
+
bold: {};
|
|
269
|
+
fixed: {};
|
|
270
|
+
fontcolor: {};
|
|
271
|
+
fontsize: {};
|
|
272
|
+
italics: {};
|
|
273
|
+
link: {};
|
|
274
|
+
small: {};
|
|
275
|
+
strike: {};
|
|
276
|
+
sub: {};
|
|
277
|
+
sup: {};
|
|
278
|
+
[Symbol.iterator]: {};
|
|
279
|
+
padStart: {};
|
|
280
|
+
padEnd: {};
|
|
281
|
+
trimEnd: {};
|
|
282
|
+
trimStart: {};
|
|
283
|
+
trimLeft: {};
|
|
284
|
+
trimRight: {};
|
|
285
|
+
matchAll: {};
|
|
286
|
+
replaceAll: {};
|
|
287
|
+
} | undefined;
|
|
288
|
+
} | undefined;
|
|
289
|
+
};
|
|
290
|
+
};
|
|
291
|
+
_generate(messages: BaseMessage[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): Promise<ChatResult>;
|
|
292
|
+
_streamResponseChunks(messages: BaseMessage[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatGenerationChunk>;
|
|
293
|
+
/**
|
|
294
|
+
* Bind tool-like objects to this chat model.
|
|
295
|
+
*
|
|
296
|
+
* @param tools A list of tool definitions to bind to this chat model.
|
|
297
|
+
* Can be a structured tool, an OpenAI formatted tool, or a Gemini function declaration.
|
|
298
|
+
* @param kwargs Any additional parameters to bind.
|
|
299
|
+
*/
|
|
300
|
+
bindTools(tools: BindToolsInput[], kwargs?: Partial<CallOptions>): Runnable<BaseMessage[], AIMessageChunk, CallOptions>;
|
|
301
|
+
/**
|
|
302
|
+
* Get structured output from the model based on a schema.
|
|
303
|
+
*
|
|
304
|
+
* This method supports two modes:
|
|
305
|
+
* - `jsonMode`: Uses `responseSchema` to get JSON responses directly (preferred for structured outputs)
|
|
306
|
+
* - `functionCalling`: Uses function calling with tools (default, for compatibility)
|
|
307
|
+
*
|
|
308
|
+
* @param outputSchema - The schema to use for structured output (Zod schema or JSON Schema)
|
|
309
|
+
* @param config - Configuration options including method and whether to include raw response
|
|
310
|
+
* @returns A Runnable that returns the parsed structured output
|
|
311
|
+
*/
|
|
312
|
+
withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput> | Record<string, any>, config?: StructuredOutputMethodOptions<boolean>): Runnable<BaseLanguageModelInput, RunOutput> | Runnable<BaseLanguageModelInput, {
|
|
313
|
+
raw: BaseMessage;
|
|
314
|
+
parsed: RunOutput;
|
|
315
|
+
}>;
|
|
316
|
+
}
|
|
317
|
+
//#endregion
|
|
318
|
+
export { BaseChatGoogle, BaseChatGoogleCallOptions, BaseChatGoogleParams };
|
|
319
|
+
//# sourceMappingURL=base.d.ts.map
|