@langchain/google 0.2.11 → 0.2.13
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 +29 -0
- package/dist/chat_models/{api-types.d.ts → api_types/generate_content.d.cts} +198 -200
- package/dist/chat_models/{api-types.d.cts → api_types/generate_content.d.ts} +198 -200
- package/dist/chat_models/api_types/interactions.d.cts +1423 -0
- package/dist/chat_models/api_types/interactions.d.ts +1423 -0
- package/dist/chat_models/base.cjs +60 -403
- package/dist/chat_models/base.cjs.map +1 -1
- package/dist/chat_models/base.d.cts +13 -200
- package/dist/chat_models/base.d.ts +15 -202
- package/dist/chat_models/base.js +61 -402
- package/dist/chat_models/base.js.map +1 -1
- package/dist/chat_models/handlers/base.cjs +62 -0
- package/dist/chat_models/handlers/base.cjs.map +1 -0
- package/dist/chat_models/handlers/base.d.cts +46 -0
- package/dist/chat_models/handlers/base.d.ts +46 -0
- package/dist/chat_models/handlers/base.js +62 -0
- package/dist/chat_models/handlers/base.js.map +1 -0
- package/dist/chat_models/handlers/generate_content.cjs +344 -0
- package/dist/chat_models/handlers/generate_content.cjs.map +1 -0
- package/dist/chat_models/handlers/generate_content.d.cts +32 -0
- package/dist/chat_models/handlers/generate_content.d.ts +32 -0
- package/dist/chat_models/handlers/generate_content.js +344 -0
- package/dist/chat_models/handlers/generate_content.js.map +1 -0
- package/dist/chat_models/handlers/index.cjs +6 -0
- package/dist/chat_models/handlers/index.d.cts +4 -0
- package/dist/chat_models/handlers/index.d.ts +4 -0
- package/dist/chat_models/handlers/index.js +4 -0
- package/dist/chat_models/handlers/interactions.cjs +303 -0
- package/dist/chat_models/handlers/interactions.cjs.map +1 -0
- package/dist/chat_models/handlers/interactions.d.cts +33 -0
- package/dist/chat_models/handlers/interactions.d.ts +33 -0
- package/dist/chat_models/handlers/interactions.js +303 -0
- package/dist/chat_models/handlers/interactions.js.map +1 -0
- package/dist/chat_models/index.cjs +14 -6
- package/dist/chat_models/index.cjs.map +1 -1
- package/dist/chat_models/index.d.cts +7 -3
- package/dist/chat_models/index.d.ts +7 -3
- package/dist/chat_models/index.js +8 -4
- package/dist/chat_models/index.js.map +1 -1
- package/dist/chat_models/node.cjs +4 -5
- package/dist/chat_models/node.cjs.map +1 -1
- package/dist/chat_models/node.d.cts +1 -3
- package/dist/chat_models/node.d.ts +1 -3
- package/dist/chat_models/node.js +3 -4
- package/dist/chat_models/node.js.map +1 -1
- package/dist/chat_models/profiles.cjs +1 -2
- package/dist/chat_models/profiles.js +1 -2
- package/dist/chat_models/types.cjs +1 -2
- package/dist/chat_models/types.cjs.map +1 -1
- package/dist/chat_models/types.d.cts +776 -88
- package/dist/chat_models/types.d.ts +776 -88
- package/dist/chat_models/types.js +1 -2
- package/dist/chat_models/types.js.map +1 -1
- package/dist/clients/index.cjs +3 -4
- package/dist/clients/index.d.cts +0 -2
- package/dist/clients/index.d.ts +0 -2
- package/dist/clients/index.js +3 -4
- package/dist/clients/node.cjs +4 -5
- package/dist/clients/node.d.cts +0 -2
- package/dist/clients/node.d.ts +0 -2
- package/dist/clients/node.js +4 -5
- package/dist/const.cjs +1 -2
- package/dist/const.js +1 -2
- package/dist/converters/{messages.cjs → generate_content/messages.cjs} +4 -5
- package/dist/converters/generate_content/messages.cjs.map +1 -0
- package/dist/converters/{messages.js → generate_content/messages.js} +4 -5
- package/dist/converters/generate_content/messages.js.map +1 -0
- package/dist/converters/generate_content/params.cjs +135 -0
- package/dist/converters/generate_content/params.cjs.map +1 -0
- package/dist/converters/generate_content/params.js +131 -0
- package/dist/converters/generate_content/params.js.map +1 -0
- package/dist/{utils → converters/generate_content}/stream_events.cjs +2 -3
- package/dist/converters/generate_content/stream_events.cjs.map +1 -0
- package/dist/{utils → converters/generate_content}/stream_events.js +2 -3
- package/dist/converters/generate_content/stream_events.js.map +1 -0
- package/dist/converters/{tools.cjs → generate_content/tools.cjs} +4 -5
- package/dist/converters/generate_content/tools.cjs.map +1 -0
- package/dist/converters/{tools.js → generate_content/tools.js} +4 -5
- package/dist/converters/generate_content/tools.js.map +1 -0
- package/dist/converters/interactions/messages.cjs +766 -0
- package/dist/converters/interactions/messages.cjs.map +1 -0
- package/dist/converters/interactions/messages.js +759 -0
- package/dist/converters/interactions/messages.js.map +1 -0
- package/dist/converters/interactions/params.cjs +244 -0
- package/dist/converters/interactions/params.cjs.map +1 -0
- package/dist/converters/interactions/params.js +237 -0
- package/dist/converters/interactions/params.js.map +1 -0
- package/dist/converters/interactions/stream_events.cjs +769 -0
- package/dist/converters/interactions/stream_events.cjs.map +1 -0
- package/dist/converters/interactions/stream_events.js +768 -0
- package/dist/converters/interactions/stream_events.js.map +1 -0
- package/dist/converters/interactions/tools.cjs +229 -0
- package/dist/converters/interactions/tools.cjs.map +1 -0
- package/dist/converters/interactions/tools.js +228 -0
- package/dist/converters/interactions/tools.js.map +1 -0
- package/dist/converters/{params.cjs → shared/params.cjs} +8 -94
- package/dist/converters/shared/params.cjs.map +1 -0
- package/dist/converters/{params.js → shared/params.js} +8 -92
- package/dist/converters/shared/params.js.map +1 -0
- package/dist/index.cjs +8 -0
- package/dist/index.d.cts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +5 -1
- package/dist/node.cjs +1 -1
- package/dist/node.d.cts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/node.js +1 -1
- package/dist/utils/errors.cjs +1 -2
- package/dist/utils/errors.js +1 -2
- package/dist/utils/gcp-auth.cjs +3 -4
- package/dist/utils/gcp-auth.d.cts +0 -2
- package/dist/utils/gcp-auth.d.ts +0 -2
- package/dist/utils/gcp-auth.js +3 -4
- package/dist/utils/handler.cjs +1 -2
- package/dist/utils/handler.d.cts +0 -2
- package/dist/utils/handler.d.ts +0 -2
- package/dist/utils/handler.js +1 -2
- package/dist/utils/metadata.cjs +9 -2
- package/dist/utils/metadata.cjs.map +1 -1
- package/dist/utils/metadata.js +9 -3
- package/dist/utils/metadata.js.map +1 -1
- package/dist/utils/misc.cjs +1 -2
- package/dist/utils/misc.cjs.map +1 -1
- package/dist/utils/misc.d.cts +2 -3
- package/dist/utils/misc.d.ts +2 -3
- package/dist/utils/misc.js +1 -2
- package/dist/utils/misc.js.map +1 -1
- package/dist/utils/stream.cjs +1 -2
- package/dist/utils/stream.js +1 -2
- package/package.json +12 -10
- package/dist/converters/messages.cjs.map +0 -1
- package/dist/converters/messages.js.map +0 -1
- package/dist/converters/params.cjs.map +0 -1
- package/dist/converters/params.js.map +0 -1
- package/dist/converters/tools.cjs.map +0 -1
- package/dist/converters/tools.js.map +0 -1
- package/dist/utils/stream_events.cjs.map +0 -1
- package/dist/utils/stream_events.js.map +0 -1
|
@@ -1,68 +1,17 @@
|
|
|
1
|
-
import { Prettify } from "../utils/misc.js";
|
|
2
1
|
import { ApiClient } from "../clients/index.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
2
|
+
import { GoogleChatApiHandler } from "./handlers/base.js";
|
|
3
|
+
import { BaseChatGoogleCallOptions, BaseChatGoogleParams, GenerateContentApiHandlerParams, GooglePlatformType, InteractionsApiHandlerParams } 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 {
|
|
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
|
-
//#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
15
|
export declare abstract class BaseChatGoogle<CallOptions extends BaseChatGoogleCallOptions = BaseChatGoogleCallOptions> extends BaseChatModel<CallOptions, AIMessageChunk> {
|
|
67
16
|
protected params: BaseChatGoogleParams & {
|
|
68
17
|
credentials?: unknown;
|
|
@@ -90,7 +39,10 @@ export declare abstract class BaseChatGoogle<CallOptions extends BaseChatGoogleC
|
|
|
90
39
|
protected get location(): string;
|
|
91
40
|
protected get endpoint(): string;
|
|
92
41
|
protected get publisher(): string;
|
|
93
|
-
protected
|
|
42
|
+
protected _apiHandler?: GoogleChatApiHandler;
|
|
43
|
+
protected _handlerParams?: GenerateContentApiHandlerParams & InteractionsApiHandlerParams;
|
|
44
|
+
protected syncHandlerParams(): GenerateContentApiHandlerParams & InteractionsApiHandlerParams;
|
|
45
|
+
protected get apiHandler(): GoogleChatApiHandler;
|
|
94
46
|
/**
|
|
95
47
|
* Returns the model profile for this instance's model, describing its
|
|
96
48
|
* capabilities and constraints (e.g. max tokens, input/output modalities,
|
|
@@ -105,151 +57,12 @@ export declare abstract class BaseChatGoogle<CallOptions extends BaseChatGoogleC
|
|
|
105
57
|
* ```
|
|
106
58
|
*/
|
|
107
59
|
get profile(): ModelProfile;
|
|
108
|
-
|
|
109
|
-
|
|
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
|
-
};
|
|
60
|
+
buildUrl(urlMethod?: string): Promise<string>;
|
|
61
|
+
invocationParams(options: this["ParsedCallOptions"]): Record<string, unknown>;
|
|
249
62
|
getLsParams(options: this["ParsedCallOptions"]): LangSmithParams;
|
|
250
|
-
getHeaders(options
|
|
63
|
+
getHeaders(options?: this["ParsedCallOptions"]): HeadersInit;
|
|
251
64
|
_generate(messages: BaseMessage[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): Promise<ChatResult>;
|
|
252
|
-
_streamChatModelEvents(messages: BaseMessage[], options: this["ParsedCallOptions"],
|
|
65
|
+
_streamChatModelEvents(messages: BaseMessage[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatModelStreamEvent>;
|
|
253
66
|
_streamResponseChunks(messages: BaseMessage[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatGenerationChunk>;
|
|
254
67
|
/**
|
|
255
68
|
* Bind tool-like objects to this chat model.
|
|
@@ -269,5 +82,5 @@ export declare abstract class BaseChatGoogle<CallOptions extends BaseChatGoogleC
|
|
|
269
82
|
parsed: RunOutput;
|
|
270
83
|
}>;
|
|
271
84
|
}
|
|
272
|
-
|
|
85
|
+
export type { BaseChatGoogleCallOptions, BaseChatGoogleParams };
|
|
273
86
|
//# sourceMappingURL=base.d.ts.map
|