@langchain/google 0.2.11 → 0.2.12

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.
Files changed (80) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/chat_models/{api-types.d.ts → api_types/generate_content.d.cts} +199 -199
  3. package/dist/chat_models/{api-types.d.cts → api_types/generate_content.d.ts} +199 -199
  4. package/dist/chat_models/base.cjs +53 -397
  5. package/dist/chat_models/base.cjs.map +1 -1
  6. package/dist/chat_models/base.d.cts +13 -198
  7. package/dist/chat_models/base.d.ts +15 -200
  8. package/dist/chat_models/base.js +55 -397
  9. package/dist/chat_models/base.js.map +1 -1
  10. package/dist/chat_models/handlers/base.cjs +63 -0
  11. package/dist/chat_models/handlers/base.cjs.map +1 -0
  12. package/dist/chat_models/handlers/base.d.cts +48 -0
  13. package/dist/chat_models/handlers/base.d.ts +48 -0
  14. package/dist/chat_models/handlers/base.js +63 -0
  15. package/dist/chat_models/handlers/base.js.map +1 -0
  16. package/dist/chat_models/handlers/generate_content.cjs +345 -0
  17. package/dist/chat_models/handlers/generate_content.cjs.map +1 -0
  18. package/dist/chat_models/handlers/generate_content.d.cts +34 -0
  19. package/dist/chat_models/handlers/generate_content.d.ts +34 -0
  20. package/dist/chat_models/handlers/generate_content.js +345 -0
  21. package/dist/chat_models/handlers/generate_content.js.map +1 -0
  22. package/dist/chat_models/handlers/index.cjs +4 -0
  23. package/dist/chat_models/handlers/index.d.cts +3 -0
  24. package/dist/chat_models/handlers/index.d.ts +3 -0
  25. package/dist/chat_models/handlers/index.js +3 -0
  26. package/dist/chat_models/index.cjs +11 -4
  27. package/dist/chat_models/index.cjs.map +1 -1
  28. package/dist/chat_models/index.d.cts +6 -1
  29. package/dist/chat_models/index.d.ts +6 -1
  30. package/dist/chat_models/index.js +6 -2
  31. package/dist/chat_models/index.js.map +1 -1
  32. package/dist/chat_models/node.cjs +2 -2
  33. package/dist/chat_models/node.cjs.map +1 -1
  34. package/dist/chat_models/node.js +2 -2
  35. package/dist/chat_models/node.js.map +1 -1
  36. package/dist/chat_models/types.cjs.map +1 -1
  37. package/dist/chat_models/types.d.cts +281 -94
  38. package/dist/chat_models/types.d.ts +281 -94
  39. package/dist/chat_models/types.js.map +1 -1
  40. package/dist/converters/{messages.cjs → generate_content/messages.cjs} +4 -4
  41. package/dist/converters/generate_content/messages.cjs.map +1 -0
  42. package/dist/converters/{messages.js → generate_content/messages.js} +4 -4
  43. package/dist/converters/generate_content/messages.js.map +1 -0
  44. package/dist/converters/generate_content/params.cjs +136 -0
  45. package/dist/converters/generate_content/params.cjs.map +1 -0
  46. package/dist/converters/generate_content/params.js +132 -0
  47. package/dist/converters/generate_content/params.js.map +1 -0
  48. package/dist/{utils → converters/generate_content}/stream_events.cjs +2 -2
  49. package/dist/converters/generate_content/stream_events.cjs.map +1 -0
  50. package/dist/{utils → converters/generate_content}/stream_events.js +2 -2
  51. package/dist/converters/generate_content/stream_events.js.map +1 -0
  52. package/dist/converters/{tools.cjs → generate_content/tools.cjs} +4 -4
  53. package/dist/converters/generate_content/tools.cjs.map +1 -0
  54. package/dist/converters/{tools.js → generate_content/tools.js} +4 -4
  55. package/dist/converters/generate_content/tools.js.map +1 -0
  56. package/dist/converters/{params.cjs → shared/params.cjs} +8 -93
  57. package/dist/converters/shared/params.cjs.map +1 -0
  58. package/dist/converters/{params.js → shared/params.js} +8 -91
  59. package/dist/converters/shared/params.js.map +1 -0
  60. package/dist/index.cjs +6 -0
  61. package/dist/index.d.cts +5 -1
  62. package/dist/index.d.ts +5 -1
  63. package/dist/index.js +4 -1
  64. package/dist/utils/metadata.cjs +8 -0
  65. package/dist/utils/metadata.cjs.map +1 -1
  66. package/dist/utils/metadata.js +8 -1
  67. package/dist/utils/metadata.js.map +1 -1
  68. package/dist/utils/misc.cjs.map +1 -1
  69. package/dist/utils/misc.d.cts +2 -1
  70. package/dist/utils/misc.d.ts +2 -1
  71. package/dist/utils/misc.js.map +1 -1
  72. package/package.json +4 -4
  73. package/dist/converters/messages.cjs.map +0 -1
  74. package/dist/converters/messages.js.map +0 -1
  75. package/dist/converters/params.cjs.map +0 -1
  76. package/dist/converters/params.js.map +0 -1
  77. package/dist/converters/tools.cjs.map +0 -1
  78. package/dist/converters/tools.js.map +0 -1
  79. package/dist/utils/stream_events.cjs.map +0 -1
  80. package/dist/utils/stream_events.js.map +0 -1
@@ -1,68 +1,18 @@
1
- import { Prettify } from "../utils/misc.js";
2
1
  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, LangSmithParams } from "@langchain/core/language_models/chat_models";
2
+ import { GoogleChatApiHandler } from "./handlers/base.js";
3
+ import { BaseChatGoogleCallOptions, BaseChatGoogleParams, GenerateContentApiHandlerParams, GooglePlatformType } from "./types.js";
4
+ import "./handlers/index.js";
5
+ import { BaseChatModel, BindToolsInput, LangSmithParams } from "@langchain/core/language_models/chat_models";
6
6
  import { AIMessageChunk, BaseMessage } from "@langchain/core/messages";
7
- import { ChatGenerationChunk, ChatResult } from "@langchain/core/outputs";
8
7
  import { Runnable } from "@langchain/core/runnables";
9
- import { JsonSchema7Type } from "@langchain/core/utils/json_schema";
8
+ import { ChatGenerationChunk, ChatResult } from "@langchain/core/outputs";
10
9
  import { InteropZodType } from "@langchain/core/utils/types";
11
- import { BaseLanguageModelInput, StructuredOutputMethodOptions } from "@langchain/core/language_models/base";
12
10
  import { SerializableSchema } from "@langchain/core/utils/standard_schema";
11
+ import { BaseLanguageModelInput, StructuredOutputMethodOptions } from "@langchain/core/language_models/base";
13
12
  import { CallbackManagerForLLMRun } from "@langchain/core/callbacks/manager";
14
13
  import { ChatModelStreamEvent } from "@langchain/core/language_models/event";
15
14
  import { ModelProfile } from "@langchain/core/language_models/profile";
16
15
  //#region src/chat_models/base.d.ts
17
- import ServiceTier = Gemini.ServiceTier;
18
- export type GooglePlatformType = "gai" | "gcp";
19
- export interface BaseChatGoogleParams extends BaseChatModelParams, ChatGoogleFields {
20
- /**
21
- * The name of the Gemini model to use.
22
- *
23
- * Example: "gemini-3-pro-preview"
24
- */
25
- model: string;
26
- /**
27
- * Optional. The API client implementation for making HTTP requests to the Gemini API.
28
- * If not set, a default client will be used based on the runtime environment.
29
- */
30
- apiClient?: ApiClient;
31
- /**
32
- * Hostname for the API call (if this is running on GCP)
33
- * Usually this is computed based on location and platformType.
34
- **/
35
- endpoint?: string;
36
- /**
37
- * Region where the LLM is stored (if this is running on GCP)
38
- * Defaults to "global"
39
- **/
40
- location?: string;
41
- /**
42
- * The version of the API functions. Part of the path.
43
- * Usually this is computed based on platformType.
44
- **/
45
- apiVersion?: string;
46
- /**
47
- * What platform to run the service on.
48
- * If not specified, the class should determine this from other
49
- * means. Either way, the platform actually used will be in
50
- * the "platform" getter.
51
- */
52
- platformType?: GooglePlatformType;
53
- /**
54
- * For compatibility with Google's libraries, should this use Vertex?
55
- * The "platformType" parmeter takes precedence.
56
- */
57
- vertexai?: boolean;
58
- /**
59
- * Backwards compatibility.
60
- * @deprecated in favor of using `disableStreaming` or `.stream()`
61
- */
62
- streaming?: boolean;
63
- streamUsage?: boolean;
64
- }
65
- export interface BaseChatGoogleCallOptions extends BaseChatModelCallOptions, ChatGoogleFields {}
66
16
  export declare abstract class BaseChatGoogle<CallOptions extends BaseChatGoogleCallOptions = BaseChatGoogleCallOptions> extends BaseChatModel<CallOptions, AIMessageChunk> {
67
17
  protected params: BaseChatGoogleParams & {
68
18
  credentials?: unknown;
@@ -90,7 +40,10 @@ export declare abstract class BaseChatGoogle<CallOptions extends BaseChatGoogleC
90
40
  protected get location(): string;
91
41
  protected get endpoint(): string;
92
42
  protected get publisher(): string;
93
- protected get urlMethod(): string;
43
+ protected _apiHandler?: GoogleChatApiHandler;
44
+ protected _handlerParams?: GenerateContentApiHandlerParams;
45
+ protected syncHandlerParams(): GenerateContentApiHandlerParams;
46
+ protected get apiHandler(): GoogleChatApiHandler;
94
47
  /**
95
48
  * Returns the model profile for this instance's model, describing its
96
49
  * capabilities and constraints (e.g. max tokens, input/output modalities,
@@ -105,151 +58,12 @@ export declare abstract class BaseChatGoogle<CallOptions extends BaseChatGoogleC
105
58
  * ```
106
59
  */
107
60
  get profile(): ModelProfile;
108
- protected buildUrlGemini(urlMethod?: string): Promise<string>;
109
- protected get endpointUrl(): string;
110
- protected buildUrlVertexExpress(urlMethod?: string): Promise<string>;
111
- protected buildUrlVertexLocation(urlMethod?: string): Promise<string>;
112
- protected buildUrlVertex(urlMethod?: string): Promise<string>;
113
- protected buildUrl(urlMethod?: string): Promise<string>;
114
- invocationParams(options: this["ParsedCallOptions"]): {
115
- serviceTier?: ServiceTier | undefined;
116
- tools?: Gemini.Tool[] | undefined;
117
- toolConfig?: Gemini.Tools.ToolConfig | undefined;
118
- safetySettings: {
119
- 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" | {
120
- readonly [x: number]: string;
121
- toString: {};
122
- charAt: {};
123
- charCodeAt: {};
124
- concat: {};
125
- indexOf: {};
126
- lastIndexOf: {};
127
- localeCompare: {};
128
- match: {};
129
- replace: {};
130
- search: {};
131
- slice: {};
132
- split: {};
133
- substring: {};
134
- toLowerCase: {};
135
- toLocaleLowerCase: {};
136
- toUpperCase: {};
137
- toLocaleUpperCase: {};
138
- trim: {};
139
- readonly length: number;
140
- substr: {};
141
- valueOf: {};
142
- codePointAt: {};
143
- includes: {};
144
- endsWith: {};
145
- normalize: {};
146
- repeat: {};
147
- startsWith: {};
148
- anchor: {};
149
- big: {};
150
- blink: {};
151
- bold: {};
152
- fixed: {};
153
- fontcolor: {};
154
- fontsize: {};
155
- italics: {};
156
- link: {};
157
- small: {};
158
- strike: {};
159
- sub: {};
160
- sup: {};
161
- [Symbol.iterator]: {};
162
- padStart: {};
163
- padEnd: {};
164
- trimEnd: {};
165
- trimStart: {};
166
- trimLeft: {};
167
- trimRight: {};
168
- matchAll: {};
169
- replaceAll: {};
170
- };
171
- threshold: "BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_NONE" | "BLOCK_ONLY_HIGH" | "HARM_BLOCK_THRESHOLD_UNSPECIFIED" | "OFF" | {
172
- readonly [x: number]: string;
173
- toString: {};
174
- charAt: {};
175
- charCodeAt: {};
176
- concat: {};
177
- indexOf: {};
178
- lastIndexOf: {};
179
- localeCompare: {};
180
- match: {};
181
- replace: {};
182
- search: {};
183
- slice: {};
184
- split: {};
185
- substring: {};
186
- toLowerCase: {};
187
- toLocaleLowerCase: {};
188
- toUpperCase: {};
189
- toLocaleUpperCase: {};
190
- trim: {};
191
- readonly length: number;
192
- substr: {};
193
- valueOf: {};
194
- codePointAt: {};
195
- includes: {};
196
- endsWith: {};
197
- normalize: {};
198
- repeat: {};
199
- startsWith: {};
200
- anchor: {};
201
- big: {};
202
- blink: {};
203
- bold: {};
204
- fixed: {};
205
- fontcolor: {};
206
- fontsize: {};
207
- italics: {};
208
- link: {};
209
- small: {};
210
- strike: {};
211
- sub: {};
212
- sup: {};
213
- [Symbol.iterator]: {};
214
- padStart: {};
215
- padEnd: {};
216
- trimEnd: {};
217
- trimStart: {};
218
- trimLeft: {};
219
- trimRight: {};
220
- matchAll: {};
221
- replaceAll: {};
222
- };
223
- }[] | undefined;
224
- generationConfig: {
225
- temperature: number | undefined;
226
- topP: number | undefined;
227
- topK: number | undefined;
228
- maxOutputTokens: number | undefined;
229
- presencePenalty: number | undefined;
230
- frequencyPenalty: number | undefined;
231
- stopSequences: string[] | undefined;
232
- responseMimeType?: string | undefined;
233
- responseJsonSchema?: Record<string, unknown> | JsonSchema7Type | undefined;
234
- responseModalities?: Prettify<Gemini.GenerativeLanguageModality>[] | undefined;
235
- candidateCount: number;
236
- seed: number | undefined;
237
- responseLogprobs: boolean | undefined;
238
- logprobs: number | undefined;
239
- enableEnhancedCivicAnswers?: boolean | undefined;
240
- thinkingConfig: Gemini.ThinkingConfig | undefined;
241
- speechConfig: Gemini.SpeechConfig | undefined;
242
- imageConfig?: {
243
- aspectRatio?: string;
244
- imageSize?: string;
245
- } | undefined;
246
- mediaResolution?: "MEDIA_RESOLUTION_HIGH" | "MEDIA_RESOLUTION_LOW" | "MEDIA_RESOLUTION_MEDIUM" | "MEDIA_RESOLUTION_UNSPECIFIED" | (string & {}) | undefined;
247
- };
248
- };
61
+ buildUrl(urlMethod?: string): Promise<string>;
62
+ invocationParams(options: this["ParsedCallOptions"]): Record<string, unknown>;
249
63
  getLsParams(options: this["ParsedCallOptions"]): LangSmithParams;
250
- getHeaders(options: this["ParsedCallOptions"]): HeadersInit;
64
+ getHeaders(options?: this["ParsedCallOptions"]): HeadersInit;
251
65
  _generate(messages: BaseMessage[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): Promise<ChatResult>;
252
- _streamChatModelEvents(messages: BaseMessage[], options: this["ParsedCallOptions"], _runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatModelStreamEvent>;
66
+ _streamChatModelEvents(messages: BaseMessage[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatModelStreamEvent>;
253
67
  _streamResponseChunks(messages: BaseMessage[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatGenerationChunk>;
254
68
  /**
255
69
  * Bind tool-like objects to this chat model.
@@ -270,4 +84,5 @@ export declare abstract class BaseChatGoogle<CallOptions extends BaseChatGoogleC
270
84
  }>;
271
85
  }
272
86
  //#endregion
87
+ export type { BaseChatGoogleCallOptions, BaseChatGoogleParams };
273
88
  //# sourceMappingURL=base.d.ts.map