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