@langchain/google 0.1.0 → 0.1.1
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 +28 -0
- package/dist/chat_models/base.cjs +31 -40
- package/dist/chat_models/base.cjs.map +1 -1
- package/dist/chat_models/base.js +9 -17
- package/dist/chat_models/base.js.map +1 -1
- package/dist/chat_models/index.cjs +2 -3
- package/dist/chat_models/index.cjs.map +1 -1
- package/dist/chat_models/index.d.cts +0 -1
- package/dist/chat_models/index.d.ts +0 -1
- package/dist/chat_models/index.js.map +1 -1
- package/dist/chat_models/node.cjs +3 -6
- package/dist/chat_models/node.cjs.map +1 -1
- package/dist/chat_models/node.js +1 -3
- package/dist/chat_models/node.js.map +1 -1
- package/dist/chat_models/profiles.cjs +94 -95
- package/dist/chat_models/profiles.cjs.map +1 -1
- package/dist/chat_models/profiles.js +94 -95
- package/dist/chat_models/profiles.js.map +1 -1
- package/dist/chat_models/types.d.cts +4 -3
- package/dist/chat_models/types.d.ts +4 -3
- package/dist/clients/index.cjs +3 -5
- package/dist/clients/index.cjs.map +1 -1
- package/dist/clients/index.js +0 -1
- package/dist/clients/index.js.map +1 -1
- package/dist/clients/node.cjs +8 -15
- package/dist/clients/node.cjs.map +1 -1
- package/dist/clients/node.d.cts +0 -1
- package/dist/clients/node.d.ts +0 -1
- package/dist/clients/node.js +4 -10
- package/dist/clients/node.js.map +1 -1
- package/dist/const.cjs.map +1 -1
- package/dist/const.js.map +1 -1
- package/dist/converters/messages.cjs +46 -67
- package/dist/converters/messages.cjs.map +1 -1
- package/dist/converters/messages.js +22 -42
- package/dist/converters/messages.js.map +1 -1
- package/dist/converters/params.cjs +20 -27
- package/dist/converters/params.cjs.map +1 -1
- package/dist/converters/params.js +20 -27
- package/dist/converters/params.js.map +1 -1
- package/dist/converters/tools.cjs +13 -19
- package/dist/converters/tools.cjs.map +1 -1
- package/dist/converters/tools.js +7 -12
- package/dist/converters/tools.js.map +1 -1
- package/dist/index.cjs +1 -0
- package/dist/node.cjs +1 -0
- package/dist/utils/errors.cjs +34 -30
- package/dist/utils/errors.cjs.map +1 -1
- package/dist/utils/errors.js +34 -30
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/gcp-auth.cjs +10 -6
- package/dist/utils/gcp-auth.cjs.map +1 -1
- package/dist/utils/gcp-auth.js +9 -4
- package/dist/utils/gcp-auth.js.map +1 -1
- package/dist/utils/handler.cjs +3 -4
- package/dist/utils/handler.cjs.map +1 -1
- package/dist/utils/handler.js +1 -1
- package/dist/utils/handler.js.map +1 -1
- package/dist/utils/misc.cjs.map +1 -1
- package/dist/utils/misc.d.cts +6 -2
- package/dist/utils/misc.d.ts +6 -2
- package/dist/utils/misc.js.map +1 -1
- package/dist/utils/stream.cjs.map +1 -1
- package/dist/utils/stream.js.map +1 -1
- package/package.json +4 -4
- package/dist/_virtual/rolldown_runtime.cjs +0 -25
|
@@ -14,7 +14,7 @@ const PROFILES = {
|
|
|
14
14
|
toolCalling: false,
|
|
15
15
|
structuredOutput: false
|
|
16
16
|
},
|
|
17
|
-
"gemini-
|
|
17
|
+
"gemini-2.5-flash-lite-preview-09-2025": {
|
|
18
18
|
maxInputTokens: 1048576,
|
|
19
19
|
imageInputs: true,
|
|
20
20
|
audioInputs: true,
|
|
@@ -28,21 +28,7 @@ const PROFILES = {
|
|
|
28
28
|
toolCalling: true,
|
|
29
29
|
structuredOutput: true
|
|
30
30
|
},
|
|
31
|
-
"gemini-2.5-
|
|
32
|
-
maxInputTokens: 32768,
|
|
33
|
-
imageInputs: true,
|
|
34
|
-
audioInputs: false,
|
|
35
|
-
pdfInputs: false,
|
|
36
|
-
videoInputs: false,
|
|
37
|
-
maxOutputTokens: 32768,
|
|
38
|
-
reasoningOutput: true,
|
|
39
|
-
imageOutputs: true,
|
|
40
|
-
audioOutputs: false,
|
|
41
|
-
videoOutputs: false,
|
|
42
|
-
toolCalling: false,
|
|
43
|
-
structuredOutput: false
|
|
44
|
-
},
|
|
45
|
-
"gemini-2.5-flash-preview-05-20": {
|
|
31
|
+
"gemini-2.5-pro-preview-06-05": {
|
|
46
32
|
maxInputTokens: 1048576,
|
|
47
33
|
imageInputs: true,
|
|
48
34
|
audioInputs: true,
|
|
@@ -56,7 +42,7 @@ const PROFILES = {
|
|
|
56
42
|
toolCalling: true,
|
|
57
43
|
structuredOutput: true
|
|
58
44
|
},
|
|
59
|
-
"gemini-flash-
|
|
45
|
+
"gemini-2.5-flash-preview-04-17": {
|
|
60
46
|
maxInputTokens: 1048576,
|
|
61
47
|
imageInputs: true,
|
|
62
48
|
audioInputs: true,
|
|
@@ -68,15 +54,15 @@ const PROFILES = {
|
|
|
68
54
|
audioOutputs: false,
|
|
69
55
|
videoOutputs: false,
|
|
70
56
|
toolCalling: true,
|
|
71
|
-
structuredOutput:
|
|
57
|
+
structuredOutput: false
|
|
72
58
|
},
|
|
73
|
-
"gemini-
|
|
74
|
-
maxInputTokens:
|
|
59
|
+
"gemini-2.5-flash-preview-09-2025": {
|
|
60
|
+
maxInputTokens: 1048576,
|
|
75
61
|
imageInputs: true,
|
|
76
62
|
audioInputs: true,
|
|
77
63
|
pdfInputs: true,
|
|
78
64
|
videoInputs: true,
|
|
79
|
-
maxOutputTokens:
|
|
65
|
+
maxOutputTokens: 65536,
|
|
80
66
|
reasoningOutput: true,
|
|
81
67
|
imageOutputs: false,
|
|
82
68
|
audioOutputs: false,
|
|
@@ -84,7 +70,7 @@ const PROFILES = {
|
|
|
84
70
|
toolCalling: true,
|
|
85
71
|
structuredOutput: true
|
|
86
72
|
},
|
|
87
|
-
"gemini-2.5-
|
|
73
|
+
"gemini-2.5-pro-preview-05-06": {
|
|
88
74
|
maxInputTokens: 1048576,
|
|
89
75
|
imageInputs: true,
|
|
90
76
|
audioInputs: true,
|
|
@@ -98,7 +84,7 @@ const PROFILES = {
|
|
|
98
84
|
toolCalling: true,
|
|
99
85
|
structuredOutput: true
|
|
100
86
|
},
|
|
101
|
-
"gemini-flash-
|
|
87
|
+
"gemini-2.5-flash-preview-05-20": {
|
|
102
88
|
maxInputTokens: 1048576,
|
|
103
89
|
imageInputs: true,
|
|
104
90
|
audioInputs: true,
|
|
@@ -112,7 +98,7 @@ const PROFILES = {
|
|
|
112
98
|
toolCalling: true,
|
|
113
99
|
structuredOutput: true
|
|
114
100
|
},
|
|
115
|
-
"gemini-2.5-
|
|
101
|
+
"gemini-2.5-flash": {
|
|
116
102
|
maxInputTokens: 1048576,
|
|
117
103
|
imageInputs: true,
|
|
118
104
|
audioInputs: true,
|
|
@@ -126,28 +112,28 @@ const PROFILES = {
|
|
|
126
112
|
toolCalling: true,
|
|
127
113
|
structuredOutput: true
|
|
128
114
|
},
|
|
129
|
-
"gemini-2.5-flash
|
|
130
|
-
maxInputTokens:
|
|
131
|
-
imageInputs:
|
|
132
|
-
audioInputs:
|
|
115
|
+
"gemini-live-2.5-flash": {
|
|
116
|
+
maxInputTokens: 128e3,
|
|
117
|
+
imageInputs: true,
|
|
118
|
+
audioInputs: true,
|
|
133
119
|
pdfInputs: false,
|
|
134
|
-
videoInputs:
|
|
135
|
-
maxOutputTokens:
|
|
136
|
-
reasoningOutput:
|
|
120
|
+
videoInputs: true,
|
|
121
|
+
maxOutputTokens: 8e3,
|
|
122
|
+
reasoningOutput: true,
|
|
137
123
|
imageOutputs: false,
|
|
138
124
|
audioOutputs: true,
|
|
139
125
|
videoOutputs: false,
|
|
140
|
-
toolCalling:
|
|
126
|
+
toolCalling: true,
|
|
141
127
|
structuredOutput: false
|
|
142
128
|
},
|
|
143
|
-
"gemini-
|
|
129
|
+
"gemini-3-flash-preview": {
|
|
144
130
|
maxInputTokens: 1048576,
|
|
145
131
|
imageInputs: true,
|
|
146
132
|
audioInputs: true,
|
|
147
133
|
pdfInputs: true,
|
|
148
134
|
videoInputs: true,
|
|
149
|
-
maxOutputTokens:
|
|
150
|
-
reasoningOutput:
|
|
135
|
+
maxOutputTokens: 65536,
|
|
136
|
+
reasoningOutput: true,
|
|
151
137
|
imageOutputs: false,
|
|
152
138
|
audioOutputs: false,
|
|
153
139
|
videoOutputs: false,
|
|
@@ -168,21 +154,35 @@ const PROFILES = {
|
|
|
168
154
|
toolCalling: true,
|
|
169
155
|
structuredOutput: false
|
|
170
156
|
},
|
|
171
|
-
"gemini-2.
|
|
157
|
+
"gemini-2.5-flash-lite": {
|
|
172
158
|
maxInputTokens: 1048576,
|
|
173
159
|
imageInputs: true,
|
|
174
160
|
audioInputs: true,
|
|
175
161
|
pdfInputs: true,
|
|
176
162
|
videoInputs: true,
|
|
177
|
-
maxOutputTokens:
|
|
178
|
-
reasoningOutput:
|
|
163
|
+
maxOutputTokens: 65536,
|
|
164
|
+
reasoningOutput: true,
|
|
179
165
|
imageOutputs: false,
|
|
180
166
|
audioOutputs: false,
|
|
181
167
|
videoOutputs: false,
|
|
182
168
|
toolCalling: true,
|
|
183
169
|
structuredOutput: true
|
|
184
170
|
},
|
|
185
|
-
"gemini-2.5-flash-
|
|
171
|
+
"gemini-2.5-flash-preview-tts": {
|
|
172
|
+
maxInputTokens: 8e3,
|
|
173
|
+
imageInputs: false,
|
|
174
|
+
audioInputs: false,
|
|
175
|
+
pdfInputs: false,
|
|
176
|
+
videoInputs: false,
|
|
177
|
+
maxOutputTokens: 16e3,
|
|
178
|
+
reasoningOutput: false,
|
|
179
|
+
imageOutputs: false,
|
|
180
|
+
audioOutputs: true,
|
|
181
|
+
videoOutputs: false,
|
|
182
|
+
toolCalling: false,
|
|
183
|
+
structuredOutput: false
|
|
184
|
+
},
|
|
185
|
+
"gemini-flash-latest": {
|
|
186
186
|
maxInputTokens: 1048576,
|
|
187
187
|
imageInputs: true,
|
|
188
188
|
audioInputs: true,
|
|
@@ -196,7 +196,7 @@ const PROFILES = {
|
|
|
196
196
|
toolCalling: true,
|
|
197
197
|
structuredOutput: true
|
|
198
198
|
},
|
|
199
|
-
"gemini-2.5-
|
|
199
|
+
"gemini-2.5-flash-lite-preview-06-17": {
|
|
200
200
|
maxInputTokens: 1048576,
|
|
201
201
|
imageInputs: true,
|
|
202
202
|
audioInputs: true,
|
|
@@ -208,34 +208,34 @@ const PROFILES = {
|
|
|
208
208
|
audioOutputs: false,
|
|
209
209
|
videoOutputs: false,
|
|
210
210
|
toolCalling: true,
|
|
211
|
-
structuredOutput:
|
|
211
|
+
structuredOutput: false
|
|
212
212
|
},
|
|
213
|
-
"gemini-
|
|
214
|
-
maxInputTokens:
|
|
213
|
+
"gemini-2.5-flash-image": {
|
|
214
|
+
maxInputTokens: 32768,
|
|
215
215
|
imageInputs: true,
|
|
216
|
-
audioInputs:
|
|
216
|
+
audioInputs: false,
|
|
217
217
|
pdfInputs: false,
|
|
218
|
-
videoInputs:
|
|
219
|
-
maxOutputTokens:
|
|
218
|
+
videoInputs: false,
|
|
219
|
+
maxOutputTokens: 32768,
|
|
220
220
|
reasoningOutput: true,
|
|
221
|
-
imageOutputs:
|
|
222
|
-
audioOutputs:
|
|
221
|
+
imageOutputs: true,
|
|
222
|
+
audioOutputs: false,
|
|
223
223
|
videoOutputs: false,
|
|
224
|
-
toolCalling:
|
|
224
|
+
toolCalling: false,
|
|
225
225
|
structuredOutput: false
|
|
226
226
|
},
|
|
227
|
-
"gemini-2.5-
|
|
228
|
-
maxInputTokens:
|
|
229
|
-
imageInputs:
|
|
230
|
-
audioInputs:
|
|
231
|
-
pdfInputs:
|
|
232
|
-
videoInputs:
|
|
233
|
-
maxOutputTokens:
|
|
234
|
-
reasoningOutput:
|
|
227
|
+
"gemini-2.5-pro-preview-tts": {
|
|
228
|
+
maxInputTokens: 8e3,
|
|
229
|
+
imageInputs: false,
|
|
230
|
+
audioInputs: false,
|
|
231
|
+
pdfInputs: false,
|
|
232
|
+
videoInputs: false,
|
|
233
|
+
maxOutputTokens: 16e3,
|
|
234
|
+
reasoningOutput: false,
|
|
235
235
|
imageOutputs: false,
|
|
236
|
-
audioOutputs:
|
|
236
|
+
audioOutputs: true,
|
|
237
237
|
videoOutputs: false,
|
|
238
|
-
toolCalling:
|
|
238
|
+
toolCalling: false,
|
|
239
239
|
structuredOutput: false
|
|
240
240
|
},
|
|
241
241
|
"gemini-2.5-flash-image-preview": {
|
|
@@ -252,56 +252,42 @@ const PROFILES = {
|
|
|
252
252
|
toolCalling: false,
|
|
253
253
|
structuredOutput: false
|
|
254
254
|
},
|
|
255
|
-
"gemini-
|
|
256
|
-
maxInputTokens:
|
|
255
|
+
"gemini-1.5-flash-8b": {
|
|
256
|
+
maxInputTokens: 1e6,
|
|
257
257
|
imageInputs: true,
|
|
258
258
|
audioInputs: true,
|
|
259
|
-
pdfInputs:
|
|
259
|
+
pdfInputs: false,
|
|
260
260
|
videoInputs: true,
|
|
261
|
-
maxOutputTokens:
|
|
262
|
-
reasoningOutput:
|
|
261
|
+
maxOutputTokens: 8192,
|
|
262
|
+
reasoningOutput: false,
|
|
263
263
|
imageOutputs: false,
|
|
264
264
|
audioOutputs: false,
|
|
265
265
|
videoOutputs: false,
|
|
266
266
|
toolCalling: true,
|
|
267
|
-
structuredOutput:
|
|
267
|
+
structuredOutput: false
|
|
268
268
|
},
|
|
269
|
-
"gemini-
|
|
270
|
-
maxInputTokens:
|
|
269
|
+
"gemini-3-pro-preview": {
|
|
270
|
+
maxInputTokens: 1e6,
|
|
271
271
|
imageInputs: true,
|
|
272
272
|
audioInputs: true,
|
|
273
273
|
pdfInputs: true,
|
|
274
274
|
videoInputs: true,
|
|
275
|
-
maxOutputTokens:
|
|
275
|
+
maxOutputTokens: 64e3,
|
|
276
276
|
reasoningOutput: true,
|
|
277
277
|
imageOutputs: false,
|
|
278
278
|
audioOutputs: false,
|
|
279
279
|
videoOutputs: false,
|
|
280
280
|
toolCalling: true,
|
|
281
|
-
structuredOutput:
|
|
282
|
-
},
|
|
283
|
-
"gemini-2.5-pro-preview-tts": {
|
|
284
|
-
maxInputTokens: 8e3,
|
|
285
|
-
imageInputs: false,
|
|
286
|
-
audioInputs: false,
|
|
287
|
-
pdfInputs: false,
|
|
288
|
-
videoInputs: false,
|
|
289
|
-
maxOutputTokens: 16e3,
|
|
290
|
-
reasoningOutput: false,
|
|
291
|
-
imageOutputs: false,
|
|
292
|
-
audioOutputs: true,
|
|
293
|
-
videoOutputs: false,
|
|
294
|
-
toolCalling: false,
|
|
295
|
-
structuredOutput: false
|
|
281
|
+
structuredOutput: true
|
|
296
282
|
},
|
|
297
|
-
"gemini-2.
|
|
283
|
+
"gemini-2.0-flash-lite": {
|
|
298
284
|
maxInputTokens: 1048576,
|
|
299
285
|
imageInputs: true,
|
|
300
286
|
audioInputs: true,
|
|
301
287
|
pdfInputs: true,
|
|
302
288
|
videoInputs: true,
|
|
303
|
-
maxOutputTokens:
|
|
304
|
-
reasoningOutput:
|
|
289
|
+
maxOutputTokens: 8192,
|
|
290
|
+
reasoningOutput: false,
|
|
305
291
|
imageOutputs: false,
|
|
306
292
|
audioOutputs: false,
|
|
307
293
|
videoOutputs: false,
|
|
@@ -322,21 +308,21 @@ const PROFILES = {
|
|
|
322
308
|
toolCalling: true,
|
|
323
309
|
structuredOutput: false
|
|
324
310
|
},
|
|
325
|
-
"gemini-
|
|
326
|
-
maxInputTokens:
|
|
311
|
+
"gemini-flash-lite-latest": {
|
|
312
|
+
maxInputTokens: 1048576,
|
|
327
313
|
imageInputs: true,
|
|
328
314
|
audioInputs: true,
|
|
329
|
-
pdfInputs:
|
|
315
|
+
pdfInputs: true,
|
|
330
316
|
videoInputs: true,
|
|
331
|
-
maxOutputTokens:
|
|
332
|
-
reasoningOutput:
|
|
317
|
+
maxOutputTokens: 65536,
|
|
318
|
+
reasoningOutput: true,
|
|
333
319
|
imageOutputs: false,
|
|
334
320
|
audioOutputs: false,
|
|
335
321
|
videoOutputs: false,
|
|
336
322
|
toolCalling: true,
|
|
337
|
-
structuredOutput:
|
|
323
|
+
structuredOutput: true
|
|
338
324
|
},
|
|
339
|
-
"gemini-2.5-
|
|
325
|
+
"gemini-2.5-pro": {
|
|
340
326
|
maxInputTokens: 1048576,
|
|
341
327
|
imageInputs: true,
|
|
342
328
|
audioInputs: true,
|
|
@@ -350,6 +336,20 @@ const PROFILES = {
|
|
|
350
336
|
toolCalling: true,
|
|
351
337
|
structuredOutput: true
|
|
352
338
|
},
|
|
339
|
+
"gemini-2.0-flash": {
|
|
340
|
+
maxInputTokens: 1048576,
|
|
341
|
+
imageInputs: true,
|
|
342
|
+
audioInputs: true,
|
|
343
|
+
pdfInputs: true,
|
|
344
|
+
videoInputs: true,
|
|
345
|
+
maxOutputTokens: 8192,
|
|
346
|
+
reasoningOutput: false,
|
|
347
|
+
imageOutputs: false,
|
|
348
|
+
audioOutputs: false,
|
|
349
|
+
videoOutputs: false,
|
|
350
|
+
toolCalling: true,
|
|
351
|
+
structuredOutput: true
|
|
352
|
+
},
|
|
353
353
|
"gemini-1.5-pro": {
|
|
354
354
|
maxInputTokens: 1e6,
|
|
355
355
|
imageInputs: true,
|
|
@@ -365,8 +365,7 @@ const PROFILES = {
|
|
|
365
365
|
structuredOutput: false
|
|
366
366
|
}
|
|
367
367
|
};
|
|
368
|
-
var profiles_default = PROFILES;
|
|
369
368
|
|
|
370
369
|
//#endregion
|
|
371
|
-
export {
|
|
370
|
+
export { PROFILES as default };
|
|
372
371
|
//# sourceMappingURL=profiles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profiles.js","names":["PROFILES: Record<string, ModelProfile>"],"sources":["../../src/chat_models/profiles.ts"],"sourcesContent":["/**\n * This file was automatically generated by an automated script. Do not edit manually.\n */\nimport type { ModelProfile } from \"@langchain/core/language_models/profile\";\nconst PROFILES: Record<string, ModelProfile> = {\n \"gemini-embedding-001\": {\n maxInputTokens: 2048,\n imageInputs: false,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 3072,\n reasoningOutput: false,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: false,\n structuredOutput: false,\n },\n \"gemini-3-flash-preview\": {\n maxInputTokens: 1048576,\n imageInputs: true,\n audioInputs: true,\n pdfInputs: true,\n videoInputs: true,\n maxOutputTokens: 65536,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"gemini-2.5-flash-image\": {\n maxInputTokens: 32768,\n imageInputs: true,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 32768,\n reasoningOutput: true,\n imageOutputs: true,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: false,\n structuredOutput: false,\n },\n \"gemini-2.5-flash-preview-05-20\": {\n maxInputTokens: 1048576,\n imageInputs: true,\n audioInputs: true,\n pdfInputs: true,\n videoInputs: true,\n maxOutputTokens: 65536,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"gemini-flash-lite-latest\": {\n maxInputTokens: 1048576,\n imageInputs: true,\n audioInputs: true,\n pdfInputs: true,\n videoInputs: true,\n maxOutputTokens: 65536,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"gemini-3-pro-preview\": {\n maxInputTokens: 1000000,\n imageInputs: true,\n audioInputs: true,\n pdfInputs: true,\n videoInputs: true,\n maxOutputTokens: 64000,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"gemini-2.5-flash\": {\n maxInputTokens: 1048576,\n imageInputs: true,\n audioInputs: true,\n pdfInputs: true,\n videoInputs: true,\n maxOutputTokens: 65536,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"gemini-flash-latest\": {\n maxInputTokens: 1048576,\n imageInputs: true,\n audioInputs: true,\n pdfInputs: true,\n videoInputs: true,\n maxOutputTokens: 65536,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"gemini-2.5-pro-preview-05-06\": {\n maxInputTokens: 1048576,\n imageInputs: true,\n audioInputs: true,\n pdfInputs: true,\n videoInputs: true,\n maxOutputTokens: 65536,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"gemini-2.5-flash-preview-tts\": {\n maxInputTokens: 8000,\n imageInputs: false,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 16000,\n reasoningOutput: false,\n imageOutputs: false,\n audioOutputs: true,\n videoOutputs: false,\n toolCalling: false,\n structuredOutput: false,\n },\n \"gemini-2.0-flash-lite\": {\n maxInputTokens: 1048576,\n imageInputs: true,\n audioInputs: true,\n pdfInputs: true,\n videoInputs: true,\n maxOutputTokens: 8192,\n reasoningOutput: false,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"gemini-live-2.5-flash-preview-native-audio\": {\n maxInputTokens: 131072,\n imageInputs: false,\n audioInputs: true,\n pdfInputs: false,\n videoInputs: true,\n maxOutputTokens: 65536,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: true,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: false,\n },\n \"gemini-2.0-flash\": {\n maxInputTokens: 1048576,\n imageInputs: true,\n audioInputs: true,\n pdfInputs: true,\n videoInputs: true,\n maxOutputTokens: 8192,\n reasoningOutput: false,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"gemini-2.5-flash-lite\": {\n maxInputTokens: 1048576,\n imageInputs: true,\n audioInputs: true,\n pdfInputs: true,\n videoInputs: true,\n maxOutputTokens: 65536,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"gemini-2.5-pro-preview-06-05\": {\n maxInputTokens: 1048576,\n imageInputs: true,\n audioInputs: true,\n pdfInputs: true,\n videoInputs: true,\n maxOutputTokens: 65536,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"gemini-live-2.5-flash\": {\n maxInputTokens: 128000,\n imageInputs: true,\n audioInputs: true,\n pdfInputs: false,\n videoInputs: true,\n maxOutputTokens: 8000,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: true,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: false,\n },\n \"gemini-2.5-flash-lite-preview-06-17\": {\n maxInputTokens: 1048576,\n imageInputs: true,\n audioInputs: true,\n pdfInputs: true,\n videoInputs: true,\n maxOutputTokens: 65536,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: false,\n },\n \"gemini-2.5-flash-image-preview\": {\n maxInputTokens: 32768,\n imageInputs: true,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 32768,\n reasoningOutput: true,\n imageOutputs: true,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: false,\n structuredOutput: false,\n },\n \"gemini-2.5-flash-preview-09-2025\": {\n maxInputTokens: 1048576,\n imageInputs: true,\n audioInputs: true,\n pdfInputs: true,\n videoInputs: true,\n maxOutputTokens: 65536,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"gemini-2.5-flash-preview-04-17\": {\n maxInputTokens: 1048576,\n imageInputs: true,\n audioInputs: true,\n pdfInputs: true,\n videoInputs: true,\n maxOutputTokens: 65536,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: false,\n },\n \"gemini-2.5-pro-preview-tts\": {\n maxInputTokens: 8000,\n imageInputs: false,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 16000,\n reasoningOutput: false,\n imageOutputs: false,\n audioOutputs: true,\n videoOutputs: false,\n toolCalling: false,\n structuredOutput: false,\n },\n \"gemini-2.5-pro\": {\n maxInputTokens: 1048576,\n imageInputs: true,\n audioInputs: true,\n pdfInputs: true,\n videoInputs: true,\n maxOutputTokens: 65536,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"gemini-1.5-flash\": {\n maxInputTokens: 1000000,\n imageInputs: true,\n audioInputs: true,\n pdfInputs: false,\n videoInputs: true,\n maxOutputTokens: 8192,\n reasoningOutput: false,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: false,\n },\n \"gemini-1.5-flash-8b\": {\n maxInputTokens: 1000000,\n imageInputs: true,\n audioInputs: true,\n pdfInputs: false,\n videoInputs: true,\n maxOutputTokens: 8192,\n reasoningOutput: false,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: false,\n },\n \"gemini-2.5-flash-lite-preview-09-2025\": {\n maxInputTokens: 1048576,\n imageInputs: true,\n audioInputs: true,\n pdfInputs: true,\n videoInputs: true,\n maxOutputTokens: 65536,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"gemini-1.5-pro\": {\n maxInputTokens: 1000000,\n imageInputs: true,\n audioInputs: true,\n pdfInputs: false,\n videoInputs: true,\n maxOutputTokens: 8192,\n reasoningOutput: false,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: false,\n },\n};\nexport default PROFILES;\n"],"mappings":";AAIA,MAAMA,WAAyC;CAC7C,wBAAwB;EACtB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;CACnB;CACD,0BAA0B;EACxB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;CACnB;CACD,0BAA0B;EACxB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;CACnB;CACD,kCAAkC;EAChC,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;CACnB;CACD,4BAA4B;EAC1B,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;CACnB;CACD,wBAAwB;EACtB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;CACnB;CACD,oBAAoB;EAClB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;CACnB;CACD,uBAAuB;EACrB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;CACnB;CACD,gCAAgC;EAC9B,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;CACnB;CACD,gCAAgC;EAC9B,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;CACnB;CACD,yBAAyB;EACvB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;CACnB;CACD,8CAA8C;EAC5C,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;CACnB;CACD,oBAAoB;EAClB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;CACnB;CACD,yBAAyB;EACvB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;CACnB;CACD,gCAAgC;EAC9B,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;CACnB;CACD,yBAAyB;EACvB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;CACnB;CACD,uCAAuC;EACrC,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;CACnB;CACD,kCAAkC;EAChC,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;CACnB;CACD,oCAAoC;EAClC,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;CACnB;CACD,kCAAkC;EAChC,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;CACnB;CACD,8BAA8B;EAC5B,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;CACnB;CACD,kBAAkB;EAChB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;CACnB;CACD,oBAAoB;EAClB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;CACnB;CACD,uBAAuB;EACrB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;CACnB;CACD,yCAAyC;EACvC,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;CACnB;CACD,kBAAkB;EAChB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;CACnB;AACF;AACD,uBAAe"}
|
|
1
|
+
{"version":3,"file":"profiles.js","names":[],"sources":["../../src/chat_models/profiles.ts"],"sourcesContent":["/**\n * This file was automatically generated by an automated script. Do not edit manually.\n */\nimport type { ModelProfile } from \"@langchain/core/language_models/profile\";\nconst PROFILES: Record<string, ModelProfile> = {\n \"gemini-embedding-001\": {\n maxInputTokens: 2048,\n imageInputs: false,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 3072,\n reasoningOutput: false,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: false,\n structuredOutput: false,\n },\n \"gemini-2.5-flash-lite-preview-09-2025\": {\n maxInputTokens: 1048576,\n imageInputs: true,\n audioInputs: true,\n pdfInputs: true,\n videoInputs: true,\n maxOutputTokens: 65536,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"gemini-2.5-pro-preview-06-05\": {\n maxInputTokens: 1048576,\n imageInputs: true,\n audioInputs: true,\n pdfInputs: true,\n videoInputs: true,\n maxOutputTokens: 65536,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"gemini-2.5-flash-preview-04-17\": {\n maxInputTokens: 1048576,\n imageInputs: true,\n audioInputs: true,\n pdfInputs: true,\n videoInputs: true,\n maxOutputTokens: 65536,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: false,\n },\n \"gemini-2.5-flash-preview-09-2025\": {\n maxInputTokens: 1048576,\n imageInputs: true,\n audioInputs: true,\n pdfInputs: true,\n videoInputs: true,\n maxOutputTokens: 65536,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"gemini-2.5-pro-preview-05-06\": {\n maxInputTokens: 1048576,\n imageInputs: true,\n audioInputs: true,\n pdfInputs: true,\n videoInputs: true,\n maxOutputTokens: 65536,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"gemini-2.5-flash-preview-05-20\": {\n maxInputTokens: 1048576,\n imageInputs: true,\n audioInputs: true,\n pdfInputs: true,\n videoInputs: true,\n maxOutputTokens: 65536,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"gemini-2.5-flash\": {\n maxInputTokens: 1048576,\n imageInputs: true,\n audioInputs: true,\n pdfInputs: true,\n videoInputs: true,\n maxOutputTokens: 65536,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"gemini-live-2.5-flash\": {\n maxInputTokens: 128000,\n imageInputs: true,\n audioInputs: true,\n pdfInputs: false,\n videoInputs: true,\n maxOutputTokens: 8000,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: true,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: false,\n },\n \"gemini-3-flash-preview\": {\n maxInputTokens: 1048576,\n imageInputs: true,\n audioInputs: true,\n pdfInputs: true,\n videoInputs: true,\n maxOutputTokens: 65536,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"gemini-live-2.5-flash-preview-native-audio\": {\n maxInputTokens: 131072,\n imageInputs: false,\n audioInputs: true,\n pdfInputs: false,\n videoInputs: true,\n maxOutputTokens: 65536,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: true,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: false,\n },\n \"gemini-2.5-flash-lite\": {\n maxInputTokens: 1048576,\n imageInputs: true,\n audioInputs: true,\n pdfInputs: true,\n videoInputs: true,\n maxOutputTokens: 65536,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"gemini-2.5-flash-preview-tts\": {\n maxInputTokens: 8000,\n imageInputs: false,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 16000,\n reasoningOutput: false,\n imageOutputs: false,\n audioOutputs: true,\n videoOutputs: false,\n toolCalling: false,\n structuredOutput: false,\n },\n \"gemini-flash-latest\": {\n maxInputTokens: 1048576,\n imageInputs: true,\n audioInputs: true,\n pdfInputs: true,\n videoInputs: true,\n maxOutputTokens: 65536,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"gemini-2.5-flash-lite-preview-06-17\": {\n maxInputTokens: 1048576,\n imageInputs: true,\n audioInputs: true,\n pdfInputs: true,\n videoInputs: true,\n maxOutputTokens: 65536,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: false,\n },\n \"gemini-2.5-flash-image\": {\n maxInputTokens: 32768,\n imageInputs: true,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 32768,\n reasoningOutput: true,\n imageOutputs: true,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: false,\n structuredOutput: false,\n },\n \"gemini-2.5-pro-preview-tts\": {\n maxInputTokens: 8000,\n imageInputs: false,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 16000,\n reasoningOutput: false,\n imageOutputs: false,\n audioOutputs: true,\n videoOutputs: false,\n toolCalling: false,\n structuredOutput: false,\n },\n \"gemini-2.5-flash-image-preview\": {\n maxInputTokens: 32768,\n imageInputs: true,\n audioInputs: false,\n pdfInputs: false,\n videoInputs: false,\n maxOutputTokens: 32768,\n reasoningOutput: true,\n imageOutputs: true,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: false,\n structuredOutput: false,\n },\n \"gemini-1.5-flash-8b\": {\n maxInputTokens: 1000000,\n imageInputs: true,\n audioInputs: true,\n pdfInputs: false,\n videoInputs: true,\n maxOutputTokens: 8192,\n reasoningOutput: false,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: false,\n },\n \"gemini-3-pro-preview\": {\n maxInputTokens: 1000000,\n imageInputs: true,\n audioInputs: true,\n pdfInputs: true,\n videoInputs: true,\n maxOutputTokens: 64000,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"gemini-2.0-flash-lite\": {\n maxInputTokens: 1048576,\n imageInputs: true,\n audioInputs: true,\n pdfInputs: true,\n videoInputs: true,\n maxOutputTokens: 8192,\n reasoningOutput: false,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"gemini-1.5-flash\": {\n maxInputTokens: 1000000,\n imageInputs: true,\n audioInputs: true,\n pdfInputs: false,\n videoInputs: true,\n maxOutputTokens: 8192,\n reasoningOutput: false,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: false,\n },\n \"gemini-flash-lite-latest\": {\n maxInputTokens: 1048576,\n imageInputs: true,\n audioInputs: true,\n pdfInputs: true,\n videoInputs: true,\n maxOutputTokens: 65536,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"gemini-2.5-pro\": {\n maxInputTokens: 1048576,\n imageInputs: true,\n audioInputs: true,\n pdfInputs: true,\n videoInputs: true,\n maxOutputTokens: 65536,\n reasoningOutput: true,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"gemini-2.0-flash\": {\n maxInputTokens: 1048576,\n imageInputs: true,\n audioInputs: true,\n pdfInputs: true,\n videoInputs: true,\n maxOutputTokens: 8192,\n reasoningOutput: false,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: true,\n },\n \"gemini-1.5-pro\": {\n maxInputTokens: 1000000,\n imageInputs: true,\n audioInputs: true,\n pdfInputs: false,\n videoInputs: true,\n maxOutputTokens: 8192,\n reasoningOutput: false,\n imageOutputs: false,\n audioOutputs: false,\n videoOutputs: false,\n toolCalling: true,\n structuredOutput: false,\n },\n};\nexport default PROFILES;\n"],"mappings":";AAIA,MAAM,WAAyC;CAC7C,wBAAwB;EACtB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,yCAAyC;EACvC,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,gCAAgC;EAC9B,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,kCAAkC;EAChC,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,oCAAoC;EAClC,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,gCAAgC;EAC9B,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,kCAAkC;EAChC,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,oBAAoB;EAClB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,yBAAyB;EACvB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,0BAA0B;EACxB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,8CAA8C;EAC5C,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,yBAAyB;EACvB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,gCAAgC;EAC9B,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,uBAAuB;EACrB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,uCAAuC;EACrC,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,0BAA0B;EACxB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,8BAA8B;EAC5B,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,kCAAkC;EAChC,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,uBAAuB;EACrB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,wBAAwB;EACtB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,yBAAyB;EACvB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,oBAAoB;EAClB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,4BAA4B;EAC1B,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,kBAAkB;EAChB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,oBAAoB;EAClB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACD,kBAAkB;EAChB,gBAAgB;EAChB,aAAa;EACb,aAAa;EACb,WAAW;EACX,aAAa;EACb,iBAAiB;EACjB,iBAAiB;EACjB,cAAc;EACd,cAAc;EACd,cAAc;EACd,aAAa;EACb,kBAAkB;EACnB;CACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Prettify } from "../utils/misc.cjs";
|
|
1
|
+
import { LowercaseLiteral, Prettify } from "../utils/misc.cjs";
|
|
2
2
|
import { Gemini } from "./api-types.cjs";
|
|
3
3
|
import { BindToolsInput } from "@langchain/core/language_models/chat_models";
|
|
4
4
|
import { InteropZodType } from "@langchain/core/utils/types";
|
|
@@ -184,9 +184,10 @@ declare module "./api-types.js" {
|
|
|
184
184
|
/**
|
|
185
185
|
* The level of "thinking" or reasoning configured for the model.
|
|
186
186
|
*
|
|
187
|
-
*
|
|
187
|
+
* Extends GeminiBase.ThinkingConfig["thinkingLevel"] to also accept
|
|
188
|
+
* lowercase variants (e.g. "high" in addition to "HIGH").
|
|
188
189
|
*/
|
|
189
|
-
type ThinkingLevel = Gemini.ThinkingConfig["thinkingLevel"]
|
|
190
|
+
type ThinkingLevel = Gemini.ThinkingConfig["thinkingLevel"] | LowercaseLiteral<Gemini.ThinkingConfig["thinkingLevel"]>;
|
|
190
191
|
/**
|
|
191
192
|
* The role of a content message. The spec types this as `string`, but
|
|
192
193
|
* the API only accepts these specific values.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Prettify } from "../utils/misc.js";
|
|
1
|
+
import { LowercaseLiteral, Prettify } from "../utils/misc.js";
|
|
2
2
|
import { Gemini } from "./api-types.js";
|
|
3
3
|
import { BindToolsInput } from "@langchain/core/language_models/chat_models";
|
|
4
4
|
import { InteropZodType } from "@langchain/core/utils/types";
|
|
@@ -184,9 +184,10 @@ declare module "./api-types.js" {
|
|
|
184
184
|
/**
|
|
185
185
|
* The level of "thinking" or reasoning configured for the model.
|
|
186
186
|
*
|
|
187
|
-
*
|
|
187
|
+
* Extends GeminiBase.ThinkingConfig["thinkingLevel"] to also accept
|
|
188
|
+
* lowercase variants (e.g. "high" in addition to "HIGH").
|
|
188
189
|
*/
|
|
189
|
-
type ThinkingLevel = Gemini.ThinkingConfig["thinkingLevel"]
|
|
190
|
+
type ThinkingLevel = Gemini.ThinkingConfig["thinkingLevel"] | LowercaseLiteral<Gemini.ThinkingConfig["thinkingLevel"]>;
|
|
190
191
|
/**
|
|
191
192
|
* The role of a content message. The spec types this as `string`, but
|
|
192
193
|
* the API only accepts these specific values.
|
package/dist/clients/index.cjs
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
1
|
const require_const = require('../const.cjs');
|
|
3
2
|
const require_misc = require('../utils/misc.cjs');
|
|
4
3
|
const require_errors = require('../utils/errors.cjs');
|
|
5
4
|
const require_gcp_auth = require('../utils/gcp-auth.cjs');
|
|
6
|
-
|
|
5
|
+
let _langchain_core_utils_env = require("@langchain/core/utils/env");
|
|
7
6
|
|
|
8
7
|
//#region src/clients/index.ts
|
|
9
8
|
/**
|
|
@@ -161,12 +160,11 @@ var WebApiClient = class extends ApiClient {
|
|
|
161
160
|
constructor(params) {
|
|
162
161
|
super();
|
|
163
162
|
this.params = params;
|
|
164
|
-
this.apiKey = params.apiKey ?? (0,
|
|
163
|
+
this.apiKey = params.apiKey ?? (0, _langchain_core_utils_env.getEnvironmentVariable)("GOOGLE_API_KEY");
|
|
165
164
|
this.credentials = require_misc.iife(() => {
|
|
166
165
|
if (params.credentials) return require_gcp_auth.normalizeGCPCredentials(params.credentials);
|
|
167
|
-
const credentialsVar = (0,
|
|
166
|
+
const credentialsVar = (0, _langchain_core_utils_env.getEnvironmentVariable)("GOOGLE_CLOUD_CREDENTIALS");
|
|
168
167
|
if (credentialsVar) return require_gcp_auth.normalizeGCPCredentials(credentialsVar);
|
|
169
|
-
return void 0;
|
|
170
168
|
});
|
|
171
169
|
}
|
|
172
170
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["params: WebApiClientParams","iife","normalizeGCPCredentials","request: Request","AuthError","GOOGLE_API_KEY_HEADER","GCP_API_KEY_HEADER","getGCPCredentialsAccessToken"],"sources":["../../src/clients/index.ts"],"sourcesContent":["import { getEnvironmentVariable } from \"@langchain/core/utils/env\";\nimport { GCP_API_KEY_HEADER, GOOGLE_API_KEY_HEADER } from \"../const.js\";\nimport {\n GCPCredentials,\n getGCPCredentialsAccessToken,\n normalizeGCPCredentials,\n} from \"../utils/gcp-auth.js\";\nimport { AuthError } from \"../utils/errors.js\";\nimport { iife } from \"../utils/misc.js\";\n\n/**\n * Abstract base class for API clients that interact with Google services.\n *\n * This class defines the contract for API clients, requiring implementations\n * to provide a fetch method that handles HTTP requests with appropriate\n * authentication headers. Concrete implementations should handle different\n * authentication strategies (API keys, service account credentials, etc.)\n * based on the runtime environment.\n *\n * @abstract\n *\n * @example\n * ```typescript\n * class MyApiClient extends ApiClient {\n * async fetch(request: Request): Promise<Response> {\n * // Add authentication headers\n * request.headers.set('Authorization', 'Bearer token');\n * return fetch(request);\n * }\n * }\n * ```\n */\nexport abstract class ApiClient {\n /**\n * Has an API Key been set for this client?\n */\n abstract hasApiKey(): boolean;\n\n /**\n * For some credential methods, we know what the project ID is.\n * This is necessary for OAuth-based access to Vertex\n */\n async getProjectId(): Promise<string> {\n return \"unknown-project-id\";\n }\n\n /**\n * Executes an HTTP request with appropriate authentication.\n *\n * Implementations should add necessary authentication headers to the request\n * before forwarding it to the underlying fetch implementation.\n *\n * @param request - The HTTP request to execute\n * @returns A Promise that resolves to the HTTP response\n *\n * @abstract\n */\n abstract fetch(request: Request): Promise<Response>;\n}\n\n/**\n * Configuration parameters for the WebApiClient.\n *\n * This interface defines the authentication options available for web-based\n * API clients. Authentication can be provided via an API key or GCP service\n * account credentials. The client will automatically check environment variables\n * if explicit values are not provided.\n *\n * @interface\n */\nexport interface WebApiClientParams {\n /**\n * Google API key for authentication.\n *\n * If not provided, the client will attempt to read from the\n * `GOOGLE_API_KEY` environment variable.\n *\n * @see https://cloud.google.com/docs/authentication/api-keys\n */\n apiKey?: string;\n\n /**\n * GCP service account credentials for authentication.\n *\n * Can be provided as either:\n * - A JSON string containing the service account key\n * - A GCPCredentials object\n *\n * If not provided, the client will attempt to read from the\n * `GOOGLE_CLOUD_CREDENTIALS` environment variable.\n *\n * @see https://cloud.google.com/iam/docs/creating-managing-service-account-keys\n */\n credentials?: string | GCPCredentials;\n\n /**\n * Google Auth options configuration.\n *\n * @deprecated This option is not supported in web environments.\n * Import from `@langchain/google/node` to configure google auth options\n * using the NodeApiClient instead.\n */\n googleAuthOptions?: never;\n}\n\n/**\n * Web-compatible API client for Google services.\n *\n * This client provides authentication for Google API requests in web environments\n * (browsers, edge functions, etc.) where the google-auth-library is not available.\n * It supports two authentication methods:\n *\n * 1. **API Key Authentication**: Simple key-based authentication suitable for\n * public APIs and client-side applications.\n *\n * 2. **Service Account Credentials**: OAuth2-based authentication using GCP\n * service account keys. The client automatically handles token generation\n * and caching.\n *\n * The client follows this authentication priority:\n * 1. Explicit `apiKey` parameter\n * 2. `GOOGLE_API_KEY` environment variable\n * 3. Explicit `credentials` parameter\n * 4. `GOOGLE_CLOUD_CREDENTIALS` environment variable\n *\n * @extends ApiClient\n *\n * @example\n * ```typescript\n * // Using API key\n * const client = new WebApiClient({\n * apiKey: 'your-api-key'\n * });\n *\n * // Using service account credentials\n * const client = new WebApiClient({\n * credentials: {\n * type: \"service_account\",\n * project_id: \"my-project\",\n * private_key_id: \"key-id\",\n * private_key: \"-----BEGIN PRIVATE KEY-----\\n...\",\n * client_email: \"service-account@project.iam.gserviceaccount.com\",\n * // ... other required fields\n * }\n * });\n *\n * // Using environment variables\n * // Set GOOGLE_API_KEY or GOOGLE_CLOUD_CREDENTIALS\n * const client = new WebApiClient({});\n *\n * // Make authenticated requests\n * const request = new Request('https://api.google.com/...');\n * const response = await client.fetch(request);\n * ```\n *\n * @remarks\n * - API keys are added via the `X-Goog-Api-Key` header\n * - Service account tokens are added via the `Authorization` header with Bearer scheme\n * - Tokens are automatically cached and refreshed as needed\n * - For Node.js environments with advanced auth requirements, use NodeApiClient instead\n *\n * @see {@link NodeApiClient} for Node.js-specific authentication options\n * @see {@link GCPCredentials} for service account credential structure\n */\nexport class WebApiClient extends ApiClient {\n hasApiKey(): boolean {\n return typeof this.apiKey === \"string\" && this.apiKey !== \"\";\n }\n\n async getProjectId(): Promise<string> {\n if (typeof this.credentials !== \"undefined\") {\n return this.credentials.project_id;\n } else {\n return super.getProjectId();\n }\n }\n\n /**\n * The Google API key used for authentication, if provided.\n *\n * This value is resolved from either the constructor parameter or the\n * `GOOGLE_API_KEY` environment variable.\n *\n * @protected\n */\n protected apiKey?: string;\n\n /**\n * The normalized GCP service account credentials, if provided.\n *\n * This value is resolved from either the constructor parameter or the\n * `GOOGLE_CLOUD_CREDENTIALS` environment variable, and is normalized\n * to ensure immutability.\n *\n * @protected\n */\n protected credentials?: GCPCredentials;\n\n /**\n * Creates a new WebApiClient instance.\n *\n * The constructor initializes authentication credentials by checking:\n * 1. Explicit parameters passed to the constructor\n * 2. Environment variables (`GOOGLE_API_KEY`, `GOOGLE_CLOUD_CREDENTIALS`)\n *\n * Credentials are normalized and frozen to prevent accidental modification.\n *\n * @param params - Configuration parameters for the client\n *\n * @example\n * ```typescript\n * // Minimal configuration (uses environment variables)\n * const client = new WebApiClient({});\n *\n * // With explicit API key\n * const client = new WebApiClient({\n * apiKey: 'your-api-key'\n * });\n *\n * // With service account credentials as JSON string\n * const client = new WebApiClient({\n * credentials: '{\"type\":\"service_account\",...}'\n * });\n *\n * // With service account credentials as object\n * const client = new WebApiClient({\n * credentials: {\n * type: \"service_account\",\n * // ... other fields\n * }\n * });\n * ```\n */\n constructor(protected params: WebApiClientParams) {\n super();\n this.apiKey = params.apiKey ?? getEnvironmentVariable(\"GOOGLE_API_KEY\");\n this.credentials = iife(() => {\n if (params.credentials) {\n return normalizeGCPCredentials(params.credentials);\n }\n const credentialsVar = getEnvironmentVariable(\"GOOGLE_CLOUD_CREDENTIALS\");\n if (credentialsVar) {\n return normalizeGCPCredentials(credentialsVar);\n }\n return undefined;\n });\n }\n\n /**\n * Executes an HTTP request with appropriate Google API authentication.\n *\n * This method adds authentication headers to the request based on the\n * configured authentication method:\n *\n * - If an API key is configured, adds the `X-Goog-Api-Key` header\n * - If service account credentials are configured, generates an access token\n * and adds it via the `Authorization` header with Bearer scheme\n *\n * The authentication priority is:\n * 1. API key (if provided)\n * 2. Service account credentials (if provided)\n *\n * @param request - The HTTP request to execute. Headers will be modified\n * in-place to include authentication information.\n * @returns A Promise that resolves to the HTTP response\n *\n * @throws {AuthError} If no authentication method is available (neither apiKey\n * nor credentials), or if service account authentication\n * fails (e.g., invalid credentials, network error, or\n * token generation failure)\n *\n * @example\n * ```typescript\n * const client = new WebApiClient({ apiKey: 'your-key' });\n * const request = new Request('https://generativelanguage.googleapis.com/v1/models');\n * const response = await client.fetch(request);\n * const data = await response.json();\n * ```\n *\n * @remarks\n * - The request object is modified in-place by adding headers\n * - Service account tokens are automatically cached and refreshed\n * - If both API key and credentials are provided, API key takes precedence\n */\n async fetch(request: Request): Promise<Response> {\n if (!this.apiKey && !this.credentials) {\n throw new AuthError({\n message:\n \"No authentication method available. Please provide either an apiKey or credentials.\",\n });\n }\n if (this.apiKey) {\n request.headers.set(GOOGLE_API_KEY_HEADER, this.apiKey);\n }\n if (this.credentials) {\n request.headers.set(\n GCP_API_KEY_HEADER,\n `Bearer ${await getGCPCredentialsAccessToken(this.credentials)}`\n );\n }\n return fetch(request);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,IAAsB,YAAtB,MAAgC;;;;;CAU9B,MAAM,eAAgC;AACpC,SAAO;CACR;AAcF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0GD,IAAa,eAAb,cAAkC,UAAU;CAC1C,YAAqB;AACnB,SAAO,OAAO,KAAK,WAAW,YAAY,KAAK,WAAW;CAC3D;CAED,MAAM,eAAgC;AACpC,MAAI,OAAO,KAAK,gBAAgB,YAC9B,QAAO,KAAK,YAAY;MAExB,QAAO,MAAM,cAAc;CAE9B;;;;;;;;;CAUD,AAAU;;;;;;;;;;CAWV,AAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqCV,YAAsBA,QAA4B;EAChD,OAAO;EADa;EAEpB,KAAK,SAAS,OAAO,iEAAiC,iBAAiB;EACvE,KAAK,cAAcC,kBAAK,MAAM;AAC5B,OAAI,OAAO,YACT,QAAOC,yCAAwB,OAAO,YAAY;GAEpD,MAAM,wEAAwC,2BAA2B;AACzE,OAAI,eACF,QAAOA,yCAAwB,eAAe;AAEhD,UAAO;EACR,EAAC;CACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsCD,MAAM,MAAMC,SAAqC;AAC/C,MAAI,CAAC,KAAK,UAAU,CAAC,KAAK,YACxB,OAAM,IAAIC,yBAAU,EAClB,SACE,sFACH;AAEH,MAAI,KAAK,QACP,QAAQ,QAAQ,IAAIC,qCAAuB,KAAK,OAAO;AAEzD,MAAI,KAAK,aACP,QAAQ,QAAQ,IACdC,kCACA,CAAC,OAAO,EAAE,MAAMC,8CAA6B,KAAK,YAAY,EAAE,CACjE;AAEH,SAAO,MAAM,QAAQ;CACtB;AACF"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["iife","normalizeGCPCredentials","AuthError","GOOGLE_API_KEY_HEADER","GCP_API_KEY_HEADER","getGCPCredentialsAccessToken"],"sources":["../../src/clients/index.ts"],"sourcesContent":["import { getEnvironmentVariable } from \"@langchain/core/utils/env\";\nimport { GCP_API_KEY_HEADER, GOOGLE_API_KEY_HEADER } from \"../const.js\";\nimport {\n GCPCredentials,\n getGCPCredentialsAccessToken,\n normalizeGCPCredentials,\n} from \"../utils/gcp-auth.js\";\nimport { AuthError } from \"../utils/errors.js\";\nimport { iife } from \"../utils/misc.js\";\n\n/**\n * Abstract base class for API clients that interact with Google services.\n *\n * This class defines the contract for API clients, requiring implementations\n * to provide a fetch method that handles HTTP requests with appropriate\n * authentication headers. Concrete implementations should handle different\n * authentication strategies (API keys, service account credentials, etc.)\n * based on the runtime environment.\n *\n * @abstract\n *\n * @example\n * ```typescript\n * class MyApiClient extends ApiClient {\n * async fetch(request: Request): Promise<Response> {\n * // Add authentication headers\n * request.headers.set('Authorization', 'Bearer token');\n * return fetch(request);\n * }\n * }\n * ```\n */\nexport abstract class ApiClient {\n /**\n * Has an API Key been set for this client?\n */\n abstract hasApiKey(): boolean;\n\n /**\n * For some credential methods, we know what the project ID is.\n * This is necessary for OAuth-based access to Vertex\n */\n async getProjectId(): Promise<string> {\n return \"unknown-project-id\";\n }\n\n /**\n * Executes an HTTP request with appropriate authentication.\n *\n * Implementations should add necessary authentication headers to the request\n * before forwarding it to the underlying fetch implementation.\n *\n * @param request - The HTTP request to execute\n * @returns A Promise that resolves to the HTTP response\n *\n * @abstract\n */\n abstract fetch(request: Request): Promise<Response>;\n}\n\n/**\n * Configuration parameters for the WebApiClient.\n *\n * This interface defines the authentication options available for web-based\n * API clients. Authentication can be provided via an API key or GCP service\n * account credentials. The client will automatically check environment variables\n * if explicit values are not provided.\n *\n * @interface\n */\nexport interface WebApiClientParams {\n /**\n * Google API key for authentication.\n *\n * If not provided, the client will attempt to read from the\n * `GOOGLE_API_KEY` environment variable.\n *\n * @see https://cloud.google.com/docs/authentication/api-keys\n */\n apiKey?: string;\n\n /**\n * GCP service account credentials for authentication.\n *\n * Can be provided as either:\n * - A JSON string containing the service account key\n * - A GCPCredentials object\n *\n * If not provided, the client will attempt to read from the\n * `GOOGLE_CLOUD_CREDENTIALS` environment variable.\n *\n * @see https://cloud.google.com/iam/docs/creating-managing-service-account-keys\n */\n credentials?: string | GCPCredentials;\n\n /**\n * Google Auth options configuration.\n *\n * @deprecated This option is not supported in web environments.\n * Import from `@langchain/google/node` to configure google auth options\n * using the NodeApiClient instead.\n */\n googleAuthOptions?: never;\n}\n\n/**\n * Web-compatible API client for Google services.\n *\n * This client provides authentication for Google API requests in web environments\n * (browsers, edge functions, etc.) where the google-auth-library is not available.\n * It supports two authentication methods:\n *\n * 1. **API Key Authentication**: Simple key-based authentication suitable for\n * public APIs and client-side applications.\n *\n * 2. **Service Account Credentials**: OAuth2-based authentication using GCP\n * service account keys. The client automatically handles token generation\n * and caching.\n *\n * The client follows this authentication priority:\n * 1. Explicit `apiKey` parameter\n * 2. `GOOGLE_API_KEY` environment variable\n * 3. Explicit `credentials` parameter\n * 4. `GOOGLE_CLOUD_CREDENTIALS` environment variable\n *\n * @extends ApiClient\n *\n * @example\n * ```typescript\n * // Using API key\n * const client = new WebApiClient({\n * apiKey: 'your-api-key'\n * });\n *\n * // Using service account credentials\n * const client = new WebApiClient({\n * credentials: {\n * type: \"service_account\",\n * project_id: \"my-project\",\n * private_key_id: \"key-id\",\n * private_key: \"-----BEGIN PRIVATE KEY-----\\n...\",\n * client_email: \"service-account@project.iam.gserviceaccount.com\",\n * // ... other required fields\n * }\n * });\n *\n * // Using environment variables\n * // Set GOOGLE_API_KEY or GOOGLE_CLOUD_CREDENTIALS\n * const client = new WebApiClient({});\n *\n * // Make authenticated requests\n * const request = new Request('https://api.google.com/...');\n * const response = await client.fetch(request);\n * ```\n *\n * @remarks\n * - API keys are added via the `X-Goog-Api-Key` header\n * - Service account tokens are added via the `Authorization` header with Bearer scheme\n * - Tokens are automatically cached and refreshed as needed\n * - For Node.js environments with advanced auth requirements, use NodeApiClient instead\n *\n * @see {@link NodeApiClient} for Node.js-specific authentication options\n * @see {@link GCPCredentials} for service account credential structure\n */\nexport class WebApiClient extends ApiClient {\n hasApiKey(): boolean {\n return typeof this.apiKey === \"string\" && this.apiKey !== \"\";\n }\n\n async getProjectId(): Promise<string> {\n if (typeof this.credentials !== \"undefined\") {\n return this.credentials.project_id;\n } else {\n return super.getProjectId();\n }\n }\n\n /**\n * The Google API key used for authentication, if provided.\n *\n * This value is resolved from either the constructor parameter or the\n * `GOOGLE_API_KEY` environment variable.\n *\n * @protected\n */\n protected apiKey?: string;\n\n /**\n * The normalized GCP service account credentials, if provided.\n *\n * This value is resolved from either the constructor parameter or the\n * `GOOGLE_CLOUD_CREDENTIALS` environment variable, and is normalized\n * to ensure immutability.\n *\n * @protected\n */\n protected credentials?: GCPCredentials;\n\n /**\n * Creates a new WebApiClient instance.\n *\n * The constructor initializes authentication credentials by checking:\n * 1. Explicit parameters passed to the constructor\n * 2. Environment variables (`GOOGLE_API_KEY`, `GOOGLE_CLOUD_CREDENTIALS`)\n *\n * Credentials are normalized and frozen to prevent accidental modification.\n *\n * @param params - Configuration parameters for the client\n *\n * @example\n * ```typescript\n * // Minimal configuration (uses environment variables)\n * const client = new WebApiClient({});\n *\n * // With explicit API key\n * const client = new WebApiClient({\n * apiKey: 'your-api-key'\n * });\n *\n * // With service account credentials as JSON string\n * const client = new WebApiClient({\n * credentials: '{\"type\":\"service_account\",...}'\n * });\n *\n * // With service account credentials as object\n * const client = new WebApiClient({\n * credentials: {\n * type: \"service_account\",\n * // ... other fields\n * }\n * });\n * ```\n */\n constructor(protected params: WebApiClientParams) {\n super();\n this.apiKey = params.apiKey ?? getEnvironmentVariable(\"GOOGLE_API_KEY\");\n this.credentials = iife(() => {\n if (params.credentials) {\n return normalizeGCPCredentials(params.credentials);\n }\n const credentialsVar = getEnvironmentVariable(\"GOOGLE_CLOUD_CREDENTIALS\");\n if (credentialsVar) {\n return normalizeGCPCredentials(credentialsVar);\n }\n return undefined;\n });\n }\n\n /**\n * Executes an HTTP request with appropriate Google API authentication.\n *\n * This method adds authentication headers to the request based on the\n * configured authentication method:\n *\n * - If an API key is configured, adds the `X-Goog-Api-Key` header\n * - If service account credentials are configured, generates an access token\n * and adds it via the `Authorization` header with Bearer scheme\n *\n * The authentication priority is:\n * 1. API key (if provided)\n * 2. Service account credentials (if provided)\n *\n * @param request - The HTTP request to execute. Headers will be modified\n * in-place to include authentication information.\n * @returns A Promise that resolves to the HTTP response\n *\n * @throws {AuthError} If no authentication method is available (neither apiKey\n * nor credentials), or if service account authentication\n * fails (e.g., invalid credentials, network error, or\n * token generation failure)\n *\n * @example\n * ```typescript\n * const client = new WebApiClient({ apiKey: 'your-key' });\n * const request = new Request('https://generativelanguage.googleapis.com/v1/models');\n * const response = await client.fetch(request);\n * const data = await response.json();\n * ```\n *\n * @remarks\n * - The request object is modified in-place by adding headers\n * - Service account tokens are automatically cached and refreshed\n * - If both API key and credentials are provided, API key takes precedence\n */\n async fetch(request: Request): Promise<Response> {\n if (!this.apiKey && !this.credentials) {\n throw new AuthError({\n message:\n \"No authentication method available. Please provide either an apiKey or credentials.\",\n });\n }\n if (this.apiKey) {\n request.headers.set(GOOGLE_API_KEY_HEADER, this.apiKey);\n }\n if (this.credentials) {\n request.headers.set(\n GCP_API_KEY_HEADER,\n `Bearer ${await getGCPCredentialsAccessToken(this.credentials)}`\n );\n }\n return fetch(request);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,IAAsB,YAAtB,MAAgC;;;;;CAU9B,MAAM,eAAgC;AACpC,SAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyHX,IAAa,eAAb,cAAkC,UAAU;CAC1C,YAAqB;AACnB,SAAO,OAAO,KAAK,WAAW,YAAY,KAAK,WAAW;;CAG5D,MAAM,eAAgC;AACpC,MAAI,OAAO,KAAK,gBAAgB,YAC9B,QAAO,KAAK,YAAY;MAExB,QAAO,MAAM,cAAc;;;;;;;;;;CAY/B,AAAU;;;;;;;;;;CAWV,AAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqCV,YAAY,AAAU,QAA4B;AAChD,SAAO;EADa;AAEpB,OAAK,SAAS,OAAO,gEAAiC,iBAAiB;AACvE,OAAK,cAAcA,wBAAW;AAC5B,OAAI,OAAO,YACT,QAAOC,yCAAwB,OAAO,YAAY;GAEpD,MAAM,uEAAwC,2BAA2B;AACzE,OAAI,eACF,QAAOA,yCAAwB,eAAe;IAGhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuCJ,MAAM,MAAM,SAAqC;AAC/C,MAAI,CAAC,KAAK,UAAU,CAAC,KAAK,YACxB,OAAM,IAAIC,yBAAU,EAClB,SACE,uFACH,CAAC;AAEJ,MAAI,KAAK,OACP,SAAQ,QAAQ,IAAIC,qCAAuB,KAAK,OAAO;AAEzD,MAAI,KAAK,YACP,SAAQ,QAAQ,IACdC,kCACA,UAAU,MAAMC,8CAA6B,KAAK,YAAY,GAC/D;AAEH,SAAO,MAAM,QAAQ"}
|
package/dist/clients/index.js
CHANGED
|
@@ -165,7 +165,6 @@ var WebApiClient = class extends ApiClient {
|
|
|
165
165
|
if (params.credentials) return normalizeGCPCredentials(params.credentials);
|
|
166
166
|
const credentialsVar = getEnvironmentVariable("GOOGLE_CLOUD_CREDENTIALS");
|
|
167
167
|
if (credentialsVar) return normalizeGCPCredentials(credentialsVar);
|
|
168
|
-
return void 0;
|
|
169
168
|
});
|
|
170
169
|
}
|
|
171
170
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["params: WebApiClientParams","request: Request"],"sources":["../../src/clients/index.ts"],"sourcesContent":["import { getEnvironmentVariable } from \"@langchain/core/utils/env\";\nimport { GCP_API_KEY_HEADER, GOOGLE_API_KEY_HEADER } from \"../const.js\";\nimport {\n GCPCredentials,\n getGCPCredentialsAccessToken,\n normalizeGCPCredentials,\n} from \"../utils/gcp-auth.js\";\nimport { AuthError } from \"../utils/errors.js\";\nimport { iife } from \"../utils/misc.js\";\n\n/**\n * Abstract base class for API clients that interact with Google services.\n *\n * This class defines the contract for API clients, requiring implementations\n * to provide a fetch method that handles HTTP requests with appropriate\n * authentication headers. Concrete implementations should handle different\n * authentication strategies (API keys, service account credentials, etc.)\n * based on the runtime environment.\n *\n * @abstract\n *\n * @example\n * ```typescript\n * class MyApiClient extends ApiClient {\n * async fetch(request: Request): Promise<Response> {\n * // Add authentication headers\n * request.headers.set('Authorization', 'Bearer token');\n * return fetch(request);\n * }\n * }\n * ```\n */\nexport abstract class ApiClient {\n /**\n * Has an API Key been set for this client?\n */\n abstract hasApiKey(): boolean;\n\n /**\n * For some credential methods, we know what the project ID is.\n * This is necessary for OAuth-based access to Vertex\n */\n async getProjectId(): Promise<string> {\n return \"unknown-project-id\";\n }\n\n /**\n * Executes an HTTP request with appropriate authentication.\n *\n * Implementations should add necessary authentication headers to the request\n * before forwarding it to the underlying fetch implementation.\n *\n * @param request - The HTTP request to execute\n * @returns A Promise that resolves to the HTTP response\n *\n * @abstract\n */\n abstract fetch(request: Request): Promise<Response>;\n}\n\n/**\n * Configuration parameters for the WebApiClient.\n *\n * This interface defines the authentication options available for web-based\n * API clients. Authentication can be provided via an API key or GCP service\n * account credentials. The client will automatically check environment variables\n * if explicit values are not provided.\n *\n * @interface\n */\nexport interface WebApiClientParams {\n /**\n * Google API key for authentication.\n *\n * If not provided, the client will attempt to read from the\n * `GOOGLE_API_KEY` environment variable.\n *\n * @see https://cloud.google.com/docs/authentication/api-keys\n */\n apiKey?: string;\n\n /**\n * GCP service account credentials for authentication.\n *\n * Can be provided as either:\n * - A JSON string containing the service account key\n * - A GCPCredentials object\n *\n * If not provided, the client will attempt to read from the\n * `GOOGLE_CLOUD_CREDENTIALS` environment variable.\n *\n * @see https://cloud.google.com/iam/docs/creating-managing-service-account-keys\n */\n credentials?: string | GCPCredentials;\n\n /**\n * Google Auth options configuration.\n *\n * @deprecated This option is not supported in web environments.\n * Import from `@langchain/google/node` to configure google auth options\n * using the NodeApiClient instead.\n */\n googleAuthOptions?: never;\n}\n\n/**\n * Web-compatible API client for Google services.\n *\n * This client provides authentication for Google API requests in web environments\n * (browsers, edge functions, etc.) where the google-auth-library is not available.\n * It supports two authentication methods:\n *\n * 1. **API Key Authentication**: Simple key-based authentication suitable for\n * public APIs and client-side applications.\n *\n * 2. **Service Account Credentials**: OAuth2-based authentication using GCP\n * service account keys. The client automatically handles token generation\n * and caching.\n *\n * The client follows this authentication priority:\n * 1. Explicit `apiKey` parameter\n * 2. `GOOGLE_API_KEY` environment variable\n * 3. Explicit `credentials` parameter\n * 4. `GOOGLE_CLOUD_CREDENTIALS` environment variable\n *\n * @extends ApiClient\n *\n * @example\n * ```typescript\n * // Using API key\n * const client = new WebApiClient({\n * apiKey: 'your-api-key'\n * });\n *\n * // Using service account credentials\n * const client = new WebApiClient({\n * credentials: {\n * type: \"service_account\",\n * project_id: \"my-project\",\n * private_key_id: \"key-id\",\n * private_key: \"-----BEGIN PRIVATE KEY-----\\n...\",\n * client_email: \"service-account@project.iam.gserviceaccount.com\",\n * // ... other required fields\n * }\n * });\n *\n * // Using environment variables\n * // Set GOOGLE_API_KEY or GOOGLE_CLOUD_CREDENTIALS\n * const client = new WebApiClient({});\n *\n * // Make authenticated requests\n * const request = new Request('https://api.google.com/...');\n * const response = await client.fetch(request);\n * ```\n *\n * @remarks\n * - API keys are added via the `X-Goog-Api-Key` header\n * - Service account tokens are added via the `Authorization` header with Bearer scheme\n * - Tokens are automatically cached and refreshed as needed\n * - For Node.js environments with advanced auth requirements, use NodeApiClient instead\n *\n * @see {@link NodeApiClient} for Node.js-specific authentication options\n * @see {@link GCPCredentials} for service account credential structure\n */\nexport class WebApiClient extends ApiClient {\n hasApiKey(): boolean {\n return typeof this.apiKey === \"string\" && this.apiKey !== \"\";\n }\n\n async getProjectId(): Promise<string> {\n if (typeof this.credentials !== \"undefined\") {\n return this.credentials.project_id;\n } else {\n return super.getProjectId();\n }\n }\n\n /**\n * The Google API key used for authentication, if provided.\n *\n * This value is resolved from either the constructor parameter or the\n * `GOOGLE_API_KEY` environment variable.\n *\n * @protected\n */\n protected apiKey?: string;\n\n /**\n * The normalized GCP service account credentials, if provided.\n *\n * This value is resolved from either the constructor parameter or the\n * `GOOGLE_CLOUD_CREDENTIALS` environment variable, and is normalized\n * to ensure immutability.\n *\n * @protected\n */\n protected credentials?: GCPCredentials;\n\n /**\n * Creates a new WebApiClient instance.\n *\n * The constructor initializes authentication credentials by checking:\n * 1. Explicit parameters passed to the constructor\n * 2. Environment variables (`GOOGLE_API_KEY`, `GOOGLE_CLOUD_CREDENTIALS`)\n *\n * Credentials are normalized and frozen to prevent accidental modification.\n *\n * @param params - Configuration parameters for the client\n *\n * @example\n * ```typescript\n * // Minimal configuration (uses environment variables)\n * const client = new WebApiClient({});\n *\n * // With explicit API key\n * const client = new WebApiClient({\n * apiKey: 'your-api-key'\n * });\n *\n * // With service account credentials as JSON string\n * const client = new WebApiClient({\n * credentials: '{\"type\":\"service_account\",...}'\n * });\n *\n * // With service account credentials as object\n * const client = new WebApiClient({\n * credentials: {\n * type: \"service_account\",\n * // ... other fields\n * }\n * });\n * ```\n */\n constructor(protected params: WebApiClientParams) {\n super();\n this.apiKey = params.apiKey ?? getEnvironmentVariable(\"GOOGLE_API_KEY\");\n this.credentials = iife(() => {\n if (params.credentials) {\n return normalizeGCPCredentials(params.credentials);\n }\n const credentialsVar = getEnvironmentVariable(\"GOOGLE_CLOUD_CREDENTIALS\");\n if (credentialsVar) {\n return normalizeGCPCredentials(credentialsVar);\n }\n return undefined;\n });\n }\n\n /**\n * Executes an HTTP request with appropriate Google API authentication.\n *\n * This method adds authentication headers to the request based on the\n * configured authentication method:\n *\n * - If an API key is configured, adds the `X-Goog-Api-Key` header\n * - If service account credentials are configured, generates an access token\n * and adds it via the `Authorization` header with Bearer scheme\n *\n * The authentication priority is:\n * 1. API key (if provided)\n * 2. Service account credentials (if provided)\n *\n * @param request - The HTTP request to execute. Headers will be modified\n * in-place to include authentication information.\n * @returns A Promise that resolves to the HTTP response\n *\n * @throws {AuthError} If no authentication method is available (neither apiKey\n * nor credentials), or if service account authentication\n * fails (e.g., invalid credentials, network error, or\n * token generation failure)\n *\n * @example\n * ```typescript\n * const client = new WebApiClient({ apiKey: 'your-key' });\n * const request = new Request('https://generativelanguage.googleapis.com/v1/models');\n * const response = await client.fetch(request);\n * const data = await response.json();\n * ```\n *\n * @remarks\n * - The request object is modified in-place by adding headers\n * - Service account tokens are automatically cached and refreshed\n * - If both API key and credentials are provided, API key takes precedence\n */\n async fetch(request: Request): Promise<Response> {\n if (!this.apiKey && !this.credentials) {\n throw new AuthError({\n message:\n \"No authentication method available. Please provide either an apiKey or credentials.\",\n });\n }\n if (this.apiKey) {\n request.headers.set(GOOGLE_API_KEY_HEADER, this.apiKey);\n }\n if (this.credentials) {\n request.headers.set(\n GCP_API_KEY_HEADER,\n `Bearer ${await getGCPCredentialsAccessToken(this.credentials)}`\n );\n }\n return fetch(request);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,IAAsB,YAAtB,MAAgC;;;;;CAU9B,MAAM,eAAgC;AACpC,SAAO;CACR;AAcF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0GD,IAAa,eAAb,cAAkC,UAAU;CAC1C,YAAqB;AACnB,SAAO,OAAO,KAAK,WAAW,YAAY,KAAK,WAAW;CAC3D;CAED,MAAM,eAAgC;AACpC,MAAI,OAAO,KAAK,gBAAgB,YAC9B,QAAO,KAAK,YAAY;MAExB,QAAO,MAAM,cAAc;CAE9B;;;;;;;;;CAUD,AAAU;;;;;;;;;;CAWV,AAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqCV,YAAsBA,QAA4B;EAChD,OAAO;EADa;EAEpB,KAAK,SAAS,OAAO,UAAU,uBAAuB,iBAAiB;EACvE,KAAK,cAAc,KAAK,MAAM;AAC5B,OAAI,OAAO,YACT,QAAO,wBAAwB,OAAO,YAAY;GAEpD,MAAM,iBAAiB,uBAAuB,2BAA2B;AACzE,OAAI,eACF,QAAO,wBAAwB,eAAe;AAEhD,UAAO;EACR,EAAC;CACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsCD,MAAM,MAAMC,SAAqC;AAC/C,MAAI,CAAC,KAAK,UAAU,CAAC,KAAK,YACxB,OAAM,IAAI,UAAU,EAClB,SACE,sFACH;AAEH,MAAI,KAAK,QACP,QAAQ,QAAQ,IAAI,uBAAuB,KAAK,OAAO;AAEzD,MAAI,KAAK,aACP,QAAQ,QAAQ,IACd,oBACA,CAAC,OAAO,EAAE,MAAM,6BAA6B,KAAK,YAAY,EAAE,CACjE;AAEH,SAAO,MAAM,QAAQ;CACtB;AACF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/clients/index.ts"],"sourcesContent":["import { getEnvironmentVariable } from \"@langchain/core/utils/env\";\nimport { GCP_API_KEY_HEADER, GOOGLE_API_KEY_HEADER } from \"../const.js\";\nimport {\n GCPCredentials,\n getGCPCredentialsAccessToken,\n normalizeGCPCredentials,\n} from \"../utils/gcp-auth.js\";\nimport { AuthError } from \"../utils/errors.js\";\nimport { iife } from \"../utils/misc.js\";\n\n/**\n * Abstract base class for API clients that interact with Google services.\n *\n * This class defines the contract for API clients, requiring implementations\n * to provide a fetch method that handles HTTP requests with appropriate\n * authentication headers. Concrete implementations should handle different\n * authentication strategies (API keys, service account credentials, etc.)\n * based on the runtime environment.\n *\n * @abstract\n *\n * @example\n * ```typescript\n * class MyApiClient extends ApiClient {\n * async fetch(request: Request): Promise<Response> {\n * // Add authentication headers\n * request.headers.set('Authorization', 'Bearer token');\n * return fetch(request);\n * }\n * }\n * ```\n */\nexport abstract class ApiClient {\n /**\n * Has an API Key been set for this client?\n */\n abstract hasApiKey(): boolean;\n\n /**\n * For some credential methods, we know what the project ID is.\n * This is necessary for OAuth-based access to Vertex\n */\n async getProjectId(): Promise<string> {\n return \"unknown-project-id\";\n }\n\n /**\n * Executes an HTTP request with appropriate authentication.\n *\n * Implementations should add necessary authentication headers to the request\n * before forwarding it to the underlying fetch implementation.\n *\n * @param request - The HTTP request to execute\n * @returns A Promise that resolves to the HTTP response\n *\n * @abstract\n */\n abstract fetch(request: Request): Promise<Response>;\n}\n\n/**\n * Configuration parameters for the WebApiClient.\n *\n * This interface defines the authentication options available for web-based\n * API clients. Authentication can be provided via an API key or GCP service\n * account credentials. The client will automatically check environment variables\n * if explicit values are not provided.\n *\n * @interface\n */\nexport interface WebApiClientParams {\n /**\n * Google API key for authentication.\n *\n * If not provided, the client will attempt to read from the\n * `GOOGLE_API_KEY` environment variable.\n *\n * @see https://cloud.google.com/docs/authentication/api-keys\n */\n apiKey?: string;\n\n /**\n * GCP service account credentials for authentication.\n *\n * Can be provided as either:\n * - A JSON string containing the service account key\n * - A GCPCredentials object\n *\n * If not provided, the client will attempt to read from the\n * `GOOGLE_CLOUD_CREDENTIALS` environment variable.\n *\n * @see https://cloud.google.com/iam/docs/creating-managing-service-account-keys\n */\n credentials?: string | GCPCredentials;\n\n /**\n * Google Auth options configuration.\n *\n * @deprecated This option is not supported in web environments.\n * Import from `@langchain/google/node` to configure google auth options\n * using the NodeApiClient instead.\n */\n googleAuthOptions?: never;\n}\n\n/**\n * Web-compatible API client for Google services.\n *\n * This client provides authentication for Google API requests in web environments\n * (browsers, edge functions, etc.) where the google-auth-library is not available.\n * It supports two authentication methods:\n *\n * 1. **API Key Authentication**: Simple key-based authentication suitable for\n * public APIs and client-side applications.\n *\n * 2. **Service Account Credentials**: OAuth2-based authentication using GCP\n * service account keys. The client automatically handles token generation\n * and caching.\n *\n * The client follows this authentication priority:\n * 1. Explicit `apiKey` parameter\n * 2. `GOOGLE_API_KEY` environment variable\n * 3. Explicit `credentials` parameter\n * 4. `GOOGLE_CLOUD_CREDENTIALS` environment variable\n *\n * @extends ApiClient\n *\n * @example\n * ```typescript\n * // Using API key\n * const client = new WebApiClient({\n * apiKey: 'your-api-key'\n * });\n *\n * // Using service account credentials\n * const client = new WebApiClient({\n * credentials: {\n * type: \"service_account\",\n * project_id: \"my-project\",\n * private_key_id: \"key-id\",\n * private_key: \"-----BEGIN PRIVATE KEY-----\\n...\",\n * client_email: \"service-account@project.iam.gserviceaccount.com\",\n * // ... other required fields\n * }\n * });\n *\n * // Using environment variables\n * // Set GOOGLE_API_KEY or GOOGLE_CLOUD_CREDENTIALS\n * const client = new WebApiClient({});\n *\n * // Make authenticated requests\n * const request = new Request('https://api.google.com/...');\n * const response = await client.fetch(request);\n * ```\n *\n * @remarks\n * - API keys are added via the `X-Goog-Api-Key` header\n * - Service account tokens are added via the `Authorization` header with Bearer scheme\n * - Tokens are automatically cached and refreshed as needed\n * - For Node.js environments with advanced auth requirements, use NodeApiClient instead\n *\n * @see {@link NodeApiClient} for Node.js-specific authentication options\n * @see {@link GCPCredentials} for service account credential structure\n */\nexport class WebApiClient extends ApiClient {\n hasApiKey(): boolean {\n return typeof this.apiKey === \"string\" && this.apiKey !== \"\";\n }\n\n async getProjectId(): Promise<string> {\n if (typeof this.credentials !== \"undefined\") {\n return this.credentials.project_id;\n } else {\n return super.getProjectId();\n }\n }\n\n /**\n * The Google API key used for authentication, if provided.\n *\n * This value is resolved from either the constructor parameter or the\n * `GOOGLE_API_KEY` environment variable.\n *\n * @protected\n */\n protected apiKey?: string;\n\n /**\n * The normalized GCP service account credentials, if provided.\n *\n * This value is resolved from either the constructor parameter or the\n * `GOOGLE_CLOUD_CREDENTIALS` environment variable, and is normalized\n * to ensure immutability.\n *\n * @protected\n */\n protected credentials?: GCPCredentials;\n\n /**\n * Creates a new WebApiClient instance.\n *\n * The constructor initializes authentication credentials by checking:\n * 1. Explicit parameters passed to the constructor\n * 2. Environment variables (`GOOGLE_API_KEY`, `GOOGLE_CLOUD_CREDENTIALS`)\n *\n * Credentials are normalized and frozen to prevent accidental modification.\n *\n * @param params - Configuration parameters for the client\n *\n * @example\n * ```typescript\n * // Minimal configuration (uses environment variables)\n * const client = new WebApiClient({});\n *\n * // With explicit API key\n * const client = new WebApiClient({\n * apiKey: 'your-api-key'\n * });\n *\n * // With service account credentials as JSON string\n * const client = new WebApiClient({\n * credentials: '{\"type\":\"service_account\",...}'\n * });\n *\n * // With service account credentials as object\n * const client = new WebApiClient({\n * credentials: {\n * type: \"service_account\",\n * // ... other fields\n * }\n * });\n * ```\n */\n constructor(protected params: WebApiClientParams) {\n super();\n this.apiKey = params.apiKey ?? getEnvironmentVariable(\"GOOGLE_API_KEY\");\n this.credentials = iife(() => {\n if (params.credentials) {\n return normalizeGCPCredentials(params.credentials);\n }\n const credentialsVar = getEnvironmentVariable(\"GOOGLE_CLOUD_CREDENTIALS\");\n if (credentialsVar) {\n return normalizeGCPCredentials(credentialsVar);\n }\n return undefined;\n });\n }\n\n /**\n * Executes an HTTP request with appropriate Google API authentication.\n *\n * This method adds authentication headers to the request based on the\n * configured authentication method:\n *\n * - If an API key is configured, adds the `X-Goog-Api-Key` header\n * - If service account credentials are configured, generates an access token\n * and adds it via the `Authorization` header with Bearer scheme\n *\n * The authentication priority is:\n * 1. API key (if provided)\n * 2. Service account credentials (if provided)\n *\n * @param request - The HTTP request to execute. Headers will be modified\n * in-place to include authentication information.\n * @returns A Promise that resolves to the HTTP response\n *\n * @throws {AuthError} If no authentication method is available (neither apiKey\n * nor credentials), or if service account authentication\n * fails (e.g., invalid credentials, network error, or\n * token generation failure)\n *\n * @example\n * ```typescript\n * const client = new WebApiClient({ apiKey: 'your-key' });\n * const request = new Request('https://generativelanguage.googleapis.com/v1/models');\n * const response = await client.fetch(request);\n * const data = await response.json();\n * ```\n *\n * @remarks\n * - The request object is modified in-place by adding headers\n * - Service account tokens are automatically cached and refreshed\n * - If both API key and credentials are provided, API key takes precedence\n */\n async fetch(request: Request): Promise<Response> {\n if (!this.apiKey && !this.credentials) {\n throw new AuthError({\n message:\n \"No authentication method available. Please provide either an apiKey or credentials.\",\n });\n }\n if (this.apiKey) {\n request.headers.set(GOOGLE_API_KEY_HEADER, this.apiKey);\n }\n if (this.credentials) {\n request.headers.set(\n GCP_API_KEY_HEADER,\n `Bearer ${await getGCPCredentialsAccessToken(this.credentials)}`\n );\n }\n return fetch(request);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,IAAsB,YAAtB,MAAgC;;;;;CAU9B,MAAM,eAAgC;AACpC,SAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyHX,IAAa,eAAb,cAAkC,UAAU;CAC1C,YAAqB;AACnB,SAAO,OAAO,KAAK,WAAW,YAAY,KAAK,WAAW;;CAG5D,MAAM,eAAgC;AACpC,MAAI,OAAO,KAAK,gBAAgB,YAC9B,QAAO,KAAK,YAAY;MAExB,QAAO,MAAM,cAAc;;;;;;;;;;CAY/B,AAAU;;;;;;;;;;CAWV,AAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqCV,YAAY,AAAU,QAA4B;AAChD,SAAO;EADa;AAEpB,OAAK,SAAS,OAAO,UAAU,uBAAuB,iBAAiB;AACvE,OAAK,cAAc,WAAW;AAC5B,OAAI,OAAO,YACT,QAAO,wBAAwB,OAAO,YAAY;GAEpD,MAAM,iBAAiB,uBAAuB,2BAA2B;AACzE,OAAI,eACF,QAAO,wBAAwB,eAAe;IAGhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuCJ,MAAM,MAAM,SAAqC;AAC/C,MAAI,CAAC,KAAK,UAAU,CAAC,KAAK,YACxB,OAAM,IAAI,UAAU,EAClB,SACE,uFACH,CAAC;AAEJ,MAAI,KAAK,OACP,SAAQ,QAAQ,IAAI,uBAAuB,KAAK,OAAO;AAEzD,MAAI,KAAK,YACP,SAAQ,QAAQ,IACd,oBACA,UAAU,MAAM,6BAA6B,KAAK,YAAY,GAC/D;AAEH,SAAO,MAAM,QAAQ"}
|