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