@langchain/google-vertexai-web 0.2.18 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/LICENSE +6 -6
  3. package/README.md +1 -1
  4. package/dist/_virtual/rolldown_runtime.cjs +25 -0
  5. package/dist/chat_models.cjs +307 -305
  6. package/dist/chat_models.cjs.map +1 -0
  7. package/dist/chat_models.d.cts +301 -0
  8. package/dist/chat_models.d.cts.map +1 -0
  9. package/dist/chat_models.d.ts +12 -7
  10. package/dist/chat_models.d.ts.map +1 -0
  11. package/dist/chat_models.js +306 -301
  12. package/dist/chat_models.js.map +1 -0
  13. package/dist/embeddings.cjs +21 -18
  14. package/dist/embeddings.cjs.map +1 -0
  15. package/dist/embeddings.d.cts +19 -0
  16. package/dist/embeddings.d.cts.map +1 -0
  17. package/dist/embeddings.d.ts +11 -6
  18. package/dist/embeddings.d.ts.map +1 -0
  19. package/dist/embeddings.js +21 -15
  20. package/dist/embeddings.js.map +1 -0
  21. package/dist/index.cjs +7 -19
  22. package/dist/index.d.cts +4 -0
  23. package/dist/index.d.ts +4 -3
  24. package/dist/index.js +5 -3
  25. package/dist/llms.cjs +26 -24
  26. package/dist/llms.cjs.map +1 -0
  27. package/dist/llms.d.cts +20 -0
  28. package/dist/llms.d.cts.map +1 -0
  29. package/dist/llms.d.ts +12 -7
  30. package/dist/llms.d.ts.map +1 -0
  31. package/dist/llms.js +25 -20
  32. package/dist/llms.js.map +1 -0
  33. package/dist/types.cjs +9 -17
  34. package/dist/types.d.cts +1 -0
  35. package/dist/types.d.ts +1 -1
  36. package/dist/types.js +1 -1
  37. package/dist/utils.cjs +9 -17
  38. package/dist/utils.d.cts +1 -0
  39. package/dist/utils.d.ts +1 -1
  40. package/dist/utils.js +1 -1
  41. package/package.json +55 -72
  42. package/index.cjs +0 -1
  43. package/index.d.cts +0 -1
  44. package/index.d.ts +0 -1
  45. package/index.js +0 -1
  46. package/types.cjs +0 -1
  47. package/types.d.cts +0 -1
  48. package/types.d.ts +0 -1
  49. package/types.js +0 -1
  50. package/utils.cjs +0 -1
  51. package/utils.d.cts +0 -1
  52. package/utils.d.ts +0 -1
  53. package/utils.js +0 -1
@@ -1,307 +1,309 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ChatVertexAI = void 0;
4
- const google_webauth_1 = require("@langchain/google-webauth");
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
+ const __langchain_google_webauth = require_rolldown_runtime.__toESM(require("@langchain/google-webauth"));
3
+
4
+ //#region src/chat_models.ts
5
5
  /**
6
- * Integration with Google Vertex AI chat models in web environments.
7
- *
8
- * Setup:
9
- * Install `@langchain/google-vertexai-web` and set your stringified
10
- * Vertex AI credentials as an environment variable named `GOOGLE_VERTEX_AI_WEB_CREDENTIALS`.
11
- *
12
- * ```bash
13
- * npm install @langchain/google-vertexai-web
14
- * export GOOGLE_VERTEX_AI_WEB_CREDENTIALS={"type":"service_account","project_id":"YOUR_PROJECT-12345",...}
15
- * ```
16
- *
17
- * ## [Constructor args](https://api.js.langchain.com/classes/_langchain_google_vertexai_web.index.ChatVertexAI.html#constructor)
18
- *
19
- * ## [Runtime args](https://api.js.langchain.com/interfaces/langchain_google_common_types.GoogleAIBaseLanguageModelCallOptions.html)
20
- *
21
- * Runtime args can be passed as the second argument to any of the base runnable methods `.invoke`. `.stream`, `.batch`, etc.
22
- * They can also be passed via `.withConfig`, or the second arg in `.bindTools`, like shown in the examples below:
23
- *
24
- * ```typescript
25
- * // If binding tools along with other options, chain `.bindTools` and `.withConfig`
26
- * const llmWithArgsBound = llm.bindTools([...]) // tools array
27
- * .withConfig({
28
- * stop: ["\n"], // other call options
29
- * });
30
- *
31
- * // When calling `.bindTools`, call options should be passed via the second argument
32
- * const llmWithTools = llm.bindTools(
33
- * [...],
34
- * {
35
- * tool_choice: "auto",
36
- * }
37
- * );
38
- * ```
39
- *
40
- * ## Examples
41
- *
42
- * <details open>
43
- * <summary><strong>Instantiate</strong></summary>
44
- *
45
- * ```typescript
46
- * import { ChatVertexAI } from '@langchain/google-vertexai-web';
47
- *
48
- * const llm = new ChatVertexAI({
49
- * model: "gemini-1.5-pro",
50
- * temperature: 0,
51
- * authOptions: {
52
- * credentials: process.env.GOOGLE_VERTEX_AI_WEB_CREDENTIALS,
53
- * },
54
- * // other params...
55
- * });
56
- * ```
57
- * </details>
58
- *
59
- * <br />
60
- *
61
- * <details>
62
- * <summary><strong>Invoking</strong></summary>
63
- *
64
- * ```typescript
65
- * const input = `Translate "I love programming" into French.`;
66
- *
67
- * // Models also accept a list of chat messages or a formatted prompt
68
- * const result = await llm.invoke(input);
69
- * console.log(result);
70
- * ```
71
- *
72
- * ```txt
73
- * AIMessageChunk {
74
- * "content": "\"J'adore programmer\" \n\nHere's why this is the best translation:\n\n* **J'adore** means \"I love\" and conveys a strong passion.\n* **Programmer** is the French verb for \"to program.\"\n\nThis translation is natural and idiomatic in French. \n",
75
- * "additional_kwargs": {},
76
- * "response_metadata": {},
77
- * "tool_calls": [],
78
- * "tool_call_chunks": [],
79
- * "invalid_tool_calls": [],
80
- * "usage_metadata": {
81
- * "input_tokens": 9,
82
- * "output_tokens": 63,
83
- * "total_tokens": 72
84
- * }
85
- * }
86
- * ```
87
- * </details>
88
- *
89
- * <br />
90
- *
91
- * <details>
92
- * <summary><strong>Streaming Chunks</strong></summary>
93
- *
94
- * ```typescript
95
- * for await (const chunk of await llm.stream(input)) {
96
- * console.log(chunk);
97
- * }
98
- * ```
99
- *
100
- * ```txt
101
- * AIMessageChunk {
102
- * "content": "\"",
103
- * "additional_kwargs": {},
104
- * "response_metadata": {},
105
- * "tool_calls": [],
106
- * "tool_call_chunks": [],
107
- * "invalid_tool_calls": []
108
- * }
109
- * AIMessageChunk {
110
- * "content": "J'adore programmer\" \n",
111
- * "additional_kwargs": {},
112
- * "response_metadata": {},
113
- * "tool_calls": [],
114
- * "tool_call_chunks": [],
115
- * "invalid_tool_calls": []
116
- * }
117
- * AIMessageChunk {
118
- * "content": "",
119
- * "additional_kwargs": {},
120
- * "response_metadata": {},
121
- * "tool_calls": [],
122
- * "tool_call_chunks": [],
123
- * "invalid_tool_calls": []
124
- * }
125
- * AIMessageChunk {
126
- * "content": "",
127
- * "additional_kwargs": {},
128
- * "response_metadata": {
129
- * "finishReason": "stop"
130
- * },
131
- * "tool_calls": [],
132
- * "tool_call_chunks": [],
133
- * "invalid_tool_calls": [],
134
- * "usage_metadata": {
135
- * "input_tokens": 9,
136
- * "output_tokens": 8,
137
- * "total_tokens": 17
138
- * }
139
- * }
140
- * ```
141
- * </details>
142
- *
143
- * <br />
144
- *
145
- * <details>
146
- * <summary><strong>Aggregate Streamed Chunks</strong></summary>
147
- *
148
- * ```typescript
149
- * import { AIMessageChunk } from '@langchain/core/messages';
150
- * import { concat } from '@langchain/core/utils/stream';
151
- *
152
- * const stream = await llm.stream(input);
153
- * let full: AIMessageChunk | undefined;
154
- * for await (const chunk of stream) {
155
- * full = !full ? chunk : concat(full, chunk);
156
- * }
157
- * console.log(full);
158
- * ```
159
- *
160
- * ```txt
161
- * AIMessageChunk {
162
- * "content": "\"J'adore programmer\" \n",
163
- * "additional_kwargs": {},
164
- * "response_metadata": {
165
- * "finishReason": "stop"
166
- * },
167
- * "tool_calls": [],
168
- * "tool_call_chunks": [],
169
- * "invalid_tool_calls": [],
170
- * "usage_metadata": {
171
- * "input_tokens": 9,
172
- * "output_tokens": 8,
173
- * "total_tokens": 17
174
- * }
175
- * }
176
- * ```
177
- * </details>
178
- *
179
- * <br />
180
- *
181
- * <details>
182
- * <summary><strong>Bind tools</strong></summary>
183
- *
184
- * ```typescript
185
- * import { z } from 'zod';
186
- *
187
- * const GetWeather = {
188
- * name: "GetWeather",
189
- * description: "Get the current weather in a given location",
190
- * schema: z.object({
191
- * location: z.string().describe("The city and state, e.g. San Francisco, CA")
192
- * }),
193
- * }
194
- *
195
- * const GetPopulation = {
196
- * name: "GetPopulation",
197
- * description: "Get the current population in a given location",
198
- * schema: z.object({
199
- * location: z.string().describe("The city and state, e.g. San Francisco, CA")
200
- * }),
201
- * }
202
- *
203
- * const llmWithTools = llm.bindTools([GetWeather, GetPopulation]);
204
- * const aiMsg = await llmWithTools.invoke(
205
- * "Which city is hotter today and which is bigger: LA or NY?"
206
- * );
207
- * console.log(aiMsg.tool_calls);
208
- * ```
209
- *
210
- * ```txt
211
- * [
212
- * {
213
- * name: 'GetPopulation',
214
- * args: { location: 'New York City, NY' },
215
- * id: '33c1c1f47e2f492799c77d2800a43912',
216
- * type: 'tool_call'
217
- * }
218
- * ]
219
- * ```
220
- * </details>
221
- *
222
- * <br />
223
- *
224
- * <details>
225
- * <summary><strong>Structured Output</strong></summary>
226
- *
227
- * ```typescript
228
- * import { z } from 'zod';
229
- *
230
- * const Joke = z.object({
231
- * setup: z.string().describe("The setup of the joke"),
232
- * punchline: z.string().describe("The punchline to the joke"),
233
- * rating: z.number().optional().describe("How funny the joke is, from 1 to 10")
234
- * }).describe('Joke to tell user.');
235
- *
236
- * const structuredLlm = llm.withStructuredOutput(Joke, { name: "Joke" });
237
- * const jokeResult = await structuredLlm.invoke("Tell me a joke about cats");
238
- * console.log(jokeResult);
239
- * ```
240
- *
241
- * ```txt
242
- * {
243
- * setup: 'What do you call a cat that loves to bowl?',
244
- * punchline: 'An alley cat!'
245
- * }
246
- * ```
247
- * </details>
248
- *
249
- * <br />
250
- *
251
- * <details>
252
- * <summary><strong>Usage Metadata</strong></summary>
253
- *
254
- * ```typescript
255
- * const aiMsgForMetadata = await llm.invoke(input);
256
- * console.log(aiMsgForMetadata.usage_metadata);
257
- * ```
258
- *
259
- * ```txt
260
- * { input_tokens: 9, output_tokens: 8, total_tokens: 17 }
261
- * ```
262
- * </details>
263
- *
264
- * <br />
265
- *
266
- * <details>
267
- * <summary><strong>Stream Usage Metadata</strong></summary>
268
- *
269
- * ```typescript
270
- * const streamForMetadata = await llm.stream(
271
- * input,
272
- * {
273
- * streamUsage: true
274
- * }
275
- * );
276
- * let fullForMetadata: AIMessageChunk | undefined;
277
- * for await (const chunk of streamForMetadata) {
278
- * fullForMetadata = !fullForMetadata ? chunk : concat(fullForMetadata, chunk);
279
- * }
280
- * console.log(fullForMetadata?.usage_metadata);
281
- * ```
282
- *
283
- * ```txt
284
- * { input_tokens: 9, output_tokens: 8, total_tokens: 17 }
285
- * ```
286
- * </details>
287
- *
288
- * <br />
289
- */
290
- class ChatVertexAI extends google_webauth_1.ChatGoogle {
291
- static lc_name() {
292
- return "ChatVertexAI";
293
- }
294
- constructor(fields) {
295
- super({
296
- ...fields,
297
- platformType: "gcp",
298
- });
299
- Object.defineProperty(this, "lc_namespace", {
300
- enumerable: true,
301
- configurable: true,
302
- writable: true,
303
- value: ["langchain", "chat_models", "vertexai"]
304
- });
305
- }
306
- }
6
+ * Integration with Google Vertex AI chat models in web environments.
7
+ *
8
+ * Setup:
9
+ * Install `@langchain/google-vertexai-web` and set your stringified
10
+ * Vertex AI credentials as an environment variable named `GOOGLE_VERTEX_AI_WEB_CREDENTIALS`.
11
+ *
12
+ * ```bash
13
+ * npm install @langchain/google-vertexai-web
14
+ * export GOOGLE_VERTEX_AI_WEB_CREDENTIALS={"type":"service_account","project_id":"YOUR_PROJECT-12345",...}
15
+ * ```
16
+ *
17
+ * ## [Constructor args](https://api.js.langchain.com/classes/_langchain_google_vertexai_web.index.ChatVertexAI.html#constructor)
18
+ *
19
+ * ## [Runtime args](https://api.js.langchain.com/interfaces/langchain_google_common_types.GoogleAIBaseLanguageModelCallOptions.html)
20
+ *
21
+ * Runtime args can be passed as the second argument to any of the base runnable methods `.invoke`. `.stream`, `.batch`, etc.
22
+ * They can also be passed via `.withConfig`, or the second arg in `.bindTools`, like shown in the examples below:
23
+ *
24
+ * ```typescript
25
+ * // If binding tools along with other options, chain `.bindTools` and `.withConfig`
26
+ * const llmWithArgsBound = llm.bindTools([...]) // tools array
27
+ * .withConfig({
28
+ * stop: ["\n"], // other call options
29
+ * });
30
+ *
31
+ * // When calling `.bindTools`, call options should be passed via the second argument
32
+ * const llmWithTools = llm.bindTools(
33
+ * [...],
34
+ * {
35
+ * tool_choice: "auto",
36
+ * }
37
+ * );
38
+ * ```
39
+ *
40
+ * ## Examples
41
+ *
42
+ * <details open>
43
+ * <summary><strong>Instantiate</strong></summary>
44
+ *
45
+ * ```typescript
46
+ * import { ChatVertexAI } from '@langchain/google-vertexai-web';
47
+ *
48
+ * const llm = new ChatVertexAI({
49
+ * model: "gemini-1.5-pro",
50
+ * temperature: 0,
51
+ * authOptions: {
52
+ * credentials: process.env.GOOGLE_VERTEX_AI_WEB_CREDENTIALS,
53
+ * },
54
+ * // other params...
55
+ * });
56
+ * ```
57
+ * </details>
58
+ *
59
+ * <br />
60
+ *
61
+ * <details>
62
+ * <summary><strong>Invoking</strong></summary>
63
+ *
64
+ * ```typescript
65
+ * const input = `Translate "I love programming" into French.`;
66
+ *
67
+ * // Models also accept a list of chat messages or a formatted prompt
68
+ * const result = await llm.invoke(input);
69
+ * console.log(result);
70
+ * ```
71
+ *
72
+ * ```txt
73
+ * AIMessageChunk {
74
+ * "content": "\"J'adore programmer\" \n\nHere's why this is the best translation:\n\n* **J'adore** means \"I love\" and conveys a strong passion.\n* **Programmer** is the French verb for \"to program.\"\n\nThis translation is natural and idiomatic in French. \n",
75
+ * "additional_kwargs": {},
76
+ * "response_metadata": {},
77
+ * "tool_calls": [],
78
+ * "tool_call_chunks": [],
79
+ * "invalid_tool_calls": [],
80
+ * "usage_metadata": {
81
+ * "input_tokens": 9,
82
+ * "output_tokens": 63,
83
+ * "total_tokens": 72
84
+ * }
85
+ * }
86
+ * ```
87
+ * </details>
88
+ *
89
+ * <br />
90
+ *
91
+ * <details>
92
+ * <summary><strong>Streaming Chunks</strong></summary>
93
+ *
94
+ * ```typescript
95
+ * for await (const chunk of await llm.stream(input)) {
96
+ * console.log(chunk);
97
+ * }
98
+ * ```
99
+ *
100
+ * ```txt
101
+ * AIMessageChunk {
102
+ * "content": "\"",
103
+ * "additional_kwargs": {},
104
+ * "response_metadata": {},
105
+ * "tool_calls": [],
106
+ * "tool_call_chunks": [],
107
+ * "invalid_tool_calls": []
108
+ * }
109
+ * AIMessageChunk {
110
+ * "content": "J'adore programmer\" \n",
111
+ * "additional_kwargs": {},
112
+ * "response_metadata": {},
113
+ * "tool_calls": [],
114
+ * "tool_call_chunks": [],
115
+ * "invalid_tool_calls": []
116
+ * }
117
+ * AIMessageChunk {
118
+ * "content": "",
119
+ * "additional_kwargs": {},
120
+ * "response_metadata": {},
121
+ * "tool_calls": [],
122
+ * "tool_call_chunks": [],
123
+ * "invalid_tool_calls": []
124
+ * }
125
+ * AIMessageChunk {
126
+ * "content": "",
127
+ * "additional_kwargs": {},
128
+ * "response_metadata": {
129
+ * "finishReason": "stop"
130
+ * },
131
+ * "tool_calls": [],
132
+ * "tool_call_chunks": [],
133
+ * "invalid_tool_calls": [],
134
+ * "usage_metadata": {
135
+ * "input_tokens": 9,
136
+ * "output_tokens": 8,
137
+ * "total_tokens": 17
138
+ * }
139
+ * }
140
+ * ```
141
+ * </details>
142
+ *
143
+ * <br />
144
+ *
145
+ * <details>
146
+ * <summary><strong>Aggregate Streamed Chunks</strong></summary>
147
+ *
148
+ * ```typescript
149
+ * import { AIMessageChunk } from '@langchain/core/messages';
150
+ * import { concat } from '@langchain/core/utils/stream';
151
+ *
152
+ * const stream = await llm.stream(input);
153
+ * let full: AIMessageChunk | undefined;
154
+ * for await (const chunk of stream) {
155
+ * full = !full ? chunk : concat(full, chunk);
156
+ * }
157
+ * console.log(full);
158
+ * ```
159
+ *
160
+ * ```txt
161
+ * AIMessageChunk {
162
+ * "content": "\"J'adore programmer\" \n",
163
+ * "additional_kwargs": {},
164
+ * "response_metadata": {
165
+ * "finishReason": "stop"
166
+ * },
167
+ * "tool_calls": [],
168
+ * "tool_call_chunks": [],
169
+ * "invalid_tool_calls": [],
170
+ * "usage_metadata": {
171
+ * "input_tokens": 9,
172
+ * "output_tokens": 8,
173
+ * "total_tokens": 17
174
+ * }
175
+ * }
176
+ * ```
177
+ * </details>
178
+ *
179
+ * <br />
180
+ *
181
+ * <details>
182
+ * <summary><strong>Bind tools</strong></summary>
183
+ *
184
+ * ```typescript
185
+ * import { z } from 'zod';
186
+ *
187
+ * const GetWeather = {
188
+ * name: "GetWeather",
189
+ * description: "Get the current weather in a given location",
190
+ * schema: z.object({
191
+ * location: z.string().describe("The city and state, e.g. San Francisco, CA")
192
+ * }),
193
+ * }
194
+ *
195
+ * const GetPopulation = {
196
+ * name: "GetPopulation",
197
+ * description: "Get the current population in a given location",
198
+ * schema: z.object({
199
+ * location: z.string().describe("The city and state, e.g. San Francisco, CA")
200
+ * }),
201
+ * }
202
+ *
203
+ * const llmWithTools = llm.bindTools([GetWeather, GetPopulation]);
204
+ * const aiMsg = await llmWithTools.invoke(
205
+ * "Which city is hotter today and which is bigger: LA or NY?"
206
+ * );
207
+ * console.log(aiMsg.tool_calls);
208
+ * ```
209
+ *
210
+ * ```txt
211
+ * [
212
+ * {
213
+ * name: 'GetPopulation',
214
+ * args: { location: 'New York City, NY' },
215
+ * id: '33c1c1f47e2f492799c77d2800a43912',
216
+ * type: 'tool_call'
217
+ * }
218
+ * ]
219
+ * ```
220
+ * </details>
221
+ *
222
+ * <br />
223
+ *
224
+ * <details>
225
+ * <summary><strong>Structured Output</strong></summary>
226
+ *
227
+ * ```typescript
228
+ * import { z } from 'zod';
229
+ *
230
+ * const Joke = z.object({
231
+ * setup: z.string().describe("The setup of the joke"),
232
+ * punchline: z.string().describe("The punchline to the joke"),
233
+ * rating: z.number().optional().describe("How funny the joke is, from 1 to 10")
234
+ * }).describe('Joke to tell user.');
235
+ *
236
+ * const structuredLlm = llm.withStructuredOutput(Joke, { name: "Joke" });
237
+ * const jokeResult = await structuredLlm.invoke("Tell me a joke about cats");
238
+ * console.log(jokeResult);
239
+ * ```
240
+ *
241
+ * ```txt
242
+ * {
243
+ * setup: 'What do you call a cat that loves to bowl?',
244
+ * punchline: 'An alley cat!'
245
+ * }
246
+ * ```
247
+ * </details>
248
+ *
249
+ * <br />
250
+ *
251
+ * <details>
252
+ * <summary><strong>Usage Metadata</strong></summary>
253
+ *
254
+ * ```typescript
255
+ * const aiMsgForMetadata = await llm.invoke(input);
256
+ * console.log(aiMsgForMetadata.usage_metadata);
257
+ * ```
258
+ *
259
+ * ```txt
260
+ * { input_tokens: 9, output_tokens: 8, total_tokens: 17 }
261
+ * ```
262
+ * </details>
263
+ *
264
+ * <br />
265
+ *
266
+ * <details>
267
+ * <summary><strong>Stream Usage Metadata</strong></summary>
268
+ *
269
+ * ```typescript
270
+ * const streamForMetadata = await llm.stream(
271
+ * input,
272
+ * {
273
+ * streamUsage: true
274
+ * }
275
+ * );
276
+ * let fullForMetadata: AIMessageChunk | undefined;
277
+ * for await (const chunk of streamForMetadata) {
278
+ * fullForMetadata = !fullForMetadata ? chunk : concat(fullForMetadata, chunk);
279
+ * }
280
+ * console.log(fullForMetadata?.usage_metadata);
281
+ * ```
282
+ *
283
+ * ```txt
284
+ * { input_tokens: 9, output_tokens: 8, total_tokens: 17 }
285
+ * ```
286
+ * </details>
287
+ *
288
+ * <br />
289
+ */
290
+ var ChatVertexAI = class extends __langchain_google_webauth.ChatGoogle {
291
+ lc_namespace = [
292
+ "langchain",
293
+ "chat_models",
294
+ "vertexai"
295
+ ];
296
+ static lc_name() {
297
+ return "ChatVertexAI";
298
+ }
299
+ constructor(fields) {
300
+ super({
301
+ ...fields,
302
+ platformType: "gcp"
303
+ });
304
+ }
305
+ };
306
+
307
+ //#endregion
307
308
  exports.ChatVertexAI = ChatVertexAI;
309
+ //# sourceMappingURL=chat_models.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat_models.cjs","names":["ChatGoogle","fields?: ChatVertexAIInput"],"sources":["../src/chat_models.ts"],"sourcesContent":["import { type ChatGoogleInput, ChatGoogle } from \"@langchain/google-webauth\";\n\n/**\n * Input to a Google Vertex AI chat model class.\n */\nexport interface ChatVertexAIInput extends ChatGoogleInput {}\n\n/**\n * Integration with Google Vertex AI chat models in web environments.\n *\n * Setup:\n * Install `@langchain/google-vertexai-web` and set your stringified\n * Vertex AI credentials as an environment variable named `GOOGLE_VERTEX_AI_WEB_CREDENTIALS`.\n *\n * ```bash\n * npm install @langchain/google-vertexai-web\n * export GOOGLE_VERTEX_AI_WEB_CREDENTIALS={\"type\":\"service_account\",\"project_id\":\"YOUR_PROJECT-12345\",...}\n * ```\n *\n * ## [Constructor args](https://api.js.langchain.com/classes/_langchain_google_vertexai_web.index.ChatVertexAI.html#constructor)\n *\n * ## [Runtime args](https://api.js.langchain.com/interfaces/langchain_google_common_types.GoogleAIBaseLanguageModelCallOptions.html)\n *\n * Runtime args can be passed as the second argument to any of the base runnable methods `.invoke`. `.stream`, `.batch`, etc.\n * They can also be passed via `.withConfig`, or the second arg in `.bindTools`, like shown in the examples below:\n *\n * ```typescript\n * // If binding tools along with other options, chain `.bindTools` and `.withConfig`\n * const llmWithArgsBound = llm.bindTools([...]) // tools array\n * .withConfig({\n * stop: [\"\\n\"], // other call options\n * });\n *\n * // When calling `.bindTools`, call options should be passed via the second argument\n * const llmWithTools = llm.bindTools(\n * [...],\n * {\n * tool_choice: \"auto\",\n * }\n * );\n * ```\n *\n * ## Examples\n *\n * <details open>\n * <summary><strong>Instantiate</strong></summary>\n *\n * ```typescript\n * import { ChatVertexAI } from '@langchain/google-vertexai-web';\n *\n * const llm = new ChatVertexAI({\n * model: \"gemini-1.5-pro\",\n * temperature: 0,\n * authOptions: {\n * credentials: process.env.GOOGLE_VERTEX_AI_WEB_CREDENTIALS,\n * },\n * // other params...\n * });\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Invoking</strong></summary>\n *\n * ```typescript\n * const input = `Translate \"I love programming\" into French.`;\n *\n * // Models also accept a list of chat messages or a formatted prompt\n * const result = await llm.invoke(input);\n * console.log(result);\n * ```\n *\n * ```txt\n * AIMessageChunk {\n * \"content\": \"\\\"J'adore programmer\\\" \\n\\nHere's why this is the best translation:\\n\\n* **J'adore** means \\\"I love\\\" and conveys a strong passion.\\n* **Programmer** is the French verb for \\\"to program.\\\"\\n\\nThis translation is natural and idiomatic in French. \\n\",\n * \"additional_kwargs\": {},\n * \"response_metadata\": {},\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": [],\n * \"usage_metadata\": {\n * \"input_tokens\": 9,\n * \"output_tokens\": 63,\n * \"total_tokens\": 72\n * }\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Streaming Chunks</strong></summary>\n *\n * ```typescript\n * for await (const chunk of await llm.stream(input)) {\n * console.log(chunk);\n * }\n * ```\n *\n * ```txt\n * AIMessageChunk {\n * \"content\": \"\\\"\",\n * \"additional_kwargs\": {},\n * \"response_metadata\": {},\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \"J'adore programmer\\\" \\n\",\n * \"additional_kwargs\": {},\n * \"response_metadata\": {},\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \"\",\n * \"additional_kwargs\": {},\n * \"response_metadata\": {},\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": []\n * }\n * AIMessageChunk {\n * \"content\": \"\",\n * \"additional_kwargs\": {},\n * \"response_metadata\": {\n * \"finishReason\": \"stop\"\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": [],\n * \"usage_metadata\": {\n * \"input_tokens\": 9,\n * \"output_tokens\": 8,\n * \"total_tokens\": 17\n * }\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Aggregate Streamed Chunks</strong></summary>\n *\n * ```typescript\n * import { AIMessageChunk } from '@langchain/core/messages';\n * import { concat } from '@langchain/core/utils/stream';\n *\n * const stream = await llm.stream(input);\n * let full: AIMessageChunk | undefined;\n * for await (const chunk of stream) {\n * full = !full ? chunk : concat(full, chunk);\n * }\n * console.log(full);\n * ```\n *\n * ```txt\n * AIMessageChunk {\n * \"content\": \"\\\"J'adore programmer\\\" \\n\",\n * \"additional_kwargs\": {},\n * \"response_metadata\": {\n * \"finishReason\": \"stop\"\n * },\n * \"tool_calls\": [],\n * \"tool_call_chunks\": [],\n * \"invalid_tool_calls\": [],\n * \"usage_metadata\": {\n * \"input_tokens\": 9,\n * \"output_tokens\": 8,\n * \"total_tokens\": 17\n * }\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Bind tools</strong></summary>\n *\n * ```typescript\n * import { z } from 'zod';\n *\n * const GetWeather = {\n * name: \"GetWeather\",\n * description: \"Get the current weather in a given location\",\n * schema: z.object({\n * location: z.string().describe(\"The city and state, e.g. San Francisco, CA\")\n * }),\n * }\n *\n * const GetPopulation = {\n * name: \"GetPopulation\",\n * description: \"Get the current population in a given location\",\n * schema: z.object({\n * location: z.string().describe(\"The city and state, e.g. San Francisco, CA\")\n * }),\n * }\n *\n * const llmWithTools = llm.bindTools([GetWeather, GetPopulation]);\n * const aiMsg = await llmWithTools.invoke(\n * \"Which city is hotter today and which is bigger: LA or NY?\"\n * );\n * console.log(aiMsg.tool_calls);\n * ```\n *\n * ```txt\n * [\n * {\n * name: 'GetPopulation',\n * args: { location: 'New York City, NY' },\n * id: '33c1c1f47e2f492799c77d2800a43912',\n * type: 'tool_call'\n * }\n * ]\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Structured Output</strong></summary>\n *\n * ```typescript\n * import { z } from 'zod';\n *\n * const Joke = z.object({\n * setup: z.string().describe(\"The setup of the joke\"),\n * punchline: z.string().describe(\"The punchline to the joke\"),\n * rating: z.number().optional().describe(\"How funny the joke is, from 1 to 10\")\n * }).describe('Joke to tell user.');\n *\n * const structuredLlm = llm.withStructuredOutput(Joke, { name: \"Joke\" });\n * const jokeResult = await structuredLlm.invoke(\"Tell me a joke about cats\");\n * console.log(jokeResult);\n * ```\n *\n * ```txt\n * {\n * setup: 'What do you call a cat that loves to bowl?',\n * punchline: 'An alley cat!'\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Usage Metadata</strong></summary>\n *\n * ```typescript\n * const aiMsgForMetadata = await llm.invoke(input);\n * console.log(aiMsgForMetadata.usage_metadata);\n * ```\n *\n * ```txt\n * { input_tokens: 9, output_tokens: 8, total_tokens: 17 }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Stream Usage Metadata</strong></summary>\n *\n * ```typescript\n * const streamForMetadata = await llm.stream(\n * input,\n * {\n * streamUsage: true\n * }\n * );\n * let fullForMetadata: AIMessageChunk | undefined;\n * for await (const chunk of streamForMetadata) {\n * fullForMetadata = !fullForMetadata ? chunk : concat(fullForMetadata, chunk);\n * }\n * console.log(fullForMetadata?.usage_metadata);\n * ```\n *\n * ```txt\n * { input_tokens: 9, output_tokens: 8, total_tokens: 17 }\n * ```\n * </details>\n *\n * <br />\n */\nexport class ChatVertexAI extends ChatGoogle {\n lc_namespace = [\"langchain\", \"chat_models\", \"vertexai\"];\n\n static lc_name() {\n return \"ChatVertexAI\";\n }\n\n constructor(fields?: ChatVertexAIInput) {\n super({\n ...fields,\n platformType: \"gcp\",\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoSA,IAAa,eAAb,cAAkCA,sCAAW;CAC3C,eAAe;EAAC;EAAa;EAAe;CAAW;CAEvD,OAAO,UAAU;AACf,SAAO;CACR;CAED,YAAYC,QAA4B;EACtC,MAAM;GACJ,GAAG;GACH,cAAc;EACf,EAAC;CACH;AACF"}