@langchain/google-vertexai-web 0.2.17 → 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
@@ -0,0 +1,301 @@
1
+ import { ChatGoogle, ChatGoogleInput } from "@langchain/google-webauth";
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 in web environments.
11
+ *
12
+ * Setup:
13
+ * Install `@langchain/google-vertexai-web` and set your stringified
14
+ * Vertex AI credentials as an environment variable named `GOOGLE_VERTEX_AI_WEB_CREDENTIALS`.
15
+ *
16
+ * ```bash
17
+ * npm install @langchain/google-vertexai-web
18
+ * export GOOGLE_VERTEX_AI_WEB_CREDENTIALS={"type":"service_account","project_id":"YOUR_PROJECT-12345",...}
19
+ * ```
20
+ *
21
+ * ## [Constructor args](https://api.js.langchain.com/classes/_langchain_google_vertexai_web.index.ChatVertexAI.html#constructor)
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
+ * // If binding tools along with other options, chain `.bindTools` and `.withConfig`
30
+ * const llmWithArgsBound = llm.bindTools([...]) // tools array
31
+ * .withConfig({
32
+ * stop: ["\n"], // other call options
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-web';
51
+ *
52
+ * const llm = new ChatVertexAI({
53
+ * model: "gemini-1.5-pro",
54
+ * temperature: 0,
55
+ * authOptions: {
56
+ * credentials: process.env.GOOGLE_VERTEX_AI_WEB_CREDENTIALS,
57
+ * },
58
+ * // other params...
59
+ * });
60
+ * ```
61
+ * </details>
62
+ *
63
+ * <br />
64
+ *
65
+ * <details>
66
+ * <summary><strong>Invoking</strong></summary>
67
+ *
68
+ * ```typescript
69
+ * const input = `Translate "I love programming" into French.`;
70
+ *
71
+ * // Models also accept a list of chat messages or a formatted prompt
72
+ * const result = await llm.invoke(input);
73
+ * console.log(result);
74
+ * ```
75
+ *
76
+ * ```txt
77
+ * AIMessageChunk {
78
+ * "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",
79
+ * "additional_kwargs": {},
80
+ * "response_metadata": {},
81
+ * "tool_calls": [],
82
+ * "tool_call_chunks": [],
83
+ * "invalid_tool_calls": [],
84
+ * "usage_metadata": {
85
+ * "input_tokens": 9,
86
+ * "output_tokens": 63,
87
+ * "total_tokens": 72
88
+ * }
89
+ * }
90
+ * ```
91
+ * </details>
92
+ *
93
+ * <br />
94
+ *
95
+ * <details>
96
+ * <summary><strong>Streaming Chunks</strong></summary>
97
+ *
98
+ * ```typescript
99
+ * for await (const chunk of await llm.stream(input)) {
100
+ * console.log(chunk);
101
+ * }
102
+ * ```
103
+ *
104
+ * ```txt
105
+ * AIMessageChunk {
106
+ * "content": "\"",
107
+ * "additional_kwargs": {},
108
+ * "response_metadata": {},
109
+ * "tool_calls": [],
110
+ * "tool_call_chunks": [],
111
+ * "invalid_tool_calls": []
112
+ * }
113
+ * AIMessageChunk {
114
+ * "content": "J'adore programmer\" \n",
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
+ * "tool_calls": [],
126
+ * "tool_call_chunks": [],
127
+ * "invalid_tool_calls": []
128
+ * }
129
+ * AIMessageChunk {
130
+ * "content": "",
131
+ * "additional_kwargs": {},
132
+ * "response_metadata": {
133
+ * "finishReason": "stop"
134
+ * },
135
+ * "tool_calls": [],
136
+ * "tool_call_chunks": [],
137
+ * "invalid_tool_calls": [],
138
+ * "usage_metadata": {
139
+ * "input_tokens": 9,
140
+ * "output_tokens": 8,
141
+ * "total_tokens": 17
142
+ * }
143
+ * }
144
+ * ```
145
+ * </details>
146
+ *
147
+ * <br />
148
+ *
149
+ * <details>
150
+ * <summary><strong>Aggregate Streamed Chunks</strong></summary>
151
+ *
152
+ * ```typescript
153
+ * import { AIMessageChunk } from '@langchain/core/messages';
154
+ * import { concat } from '@langchain/core/utils/stream';
155
+ *
156
+ * const stream = await llm.stream(input);
157
+ * let full: AIMessageChunk | undefined;
158
+ * for await (const chunk of stream) {
159
+ * full = !full ? chunk : concat(full, chunk);
160
+ * }
161
+ * console.log(full);
162
+ * ```
163
+ *
164
+ * ```txt
165
+ * AIMessageChunk {
166
+ * "content": "\"J'adore programmer\" \n",
167
+ * "additional_kwargs": {},
168
+ * "response_metadata": {
169
+ * "finishReason": "stop"
170
+ * },
171
+ * "tool_calls": [],
172
+ * "tool_call_chunks": [],
173
+ * "invalid_tool_calls": [],
174
+ * "usage_metadata": {
175
+ * "input_tokens": 9,
176
+ * "output_tokens": 8,
177
+ * "total_tokens": 17
178
+ * }
179
+ * }
180
+ * ```
181
+ * </details>
182
+ *
183
+ * <br />
184
+ *
185
+ * <details>
186
+ * <summary><strong>Bind tools</strong></summary>
187
+ *
188
+ * ```typescript
189
+ * import { z } from 'zod';
190
+ *
191
+ * const GetWeather = {
192
+ * name: "GetWeather",
193
+ * description: "Get the current weather 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 GetPopulation = {
200
+ * name: "GetPopulation",
201
+ * description: "Get the current population in a given location",
202
+ * schema: z.object({
203
+ * location: z.string().describe("The city and state, e.g. San Francisco, CA")
204
+ * }),
205
+ * }
206
+ *
207
+ * const llmWithTools = llm.bindTools([GetWeather, GetPopulation]);
208
+ * const aiMsg = await llmWithTools.invoke(
209
+ * "Which city is hotter today and which is bigger: LA or NY?"
210
+ * );
211
+ * console.log(aiMsg.tool_calls);
212
+ * ```
213
+ *
214
+ * ```txt
215
+ * [
216
+ * {
217
+ * name: 'GetPopulation',
218
+ * args: { location: 'New York City, NY' },
219
+ * id: '33c1c1f47e2f492799c77d2800a43912',
220
+ * type: 'tool_call'
221
+ * }
222
+ * ]
223
+ * ```
224
+ * </details>
225
+ *
226
+ * <br />
227
+ *
228
+ * <details>
229
+ * <summary><strong>Structured Output</strong></summary>
230
+ *
231
+ * ```typescript
232
+ * import { z } from 'zod';
233
+ *
234
+ * const Joke = z.object({
235
+ * setup: z.string().describe("The setup of the joke"),
236
+ * punchline: z.string().describe("The punchline to the joke"),
237
+ * rating: z.number().optional().describe("How funny the joke is, from 1 to 10")
238
+ * }).describe('Joke to tell user.');
239
+ *
240
+ * const structuredLlm = llm.withStructuredOutput(Joke, { name: "Joke" });
241
+ * const jokeResult = await structuredLlm.invoke("Tell me a joke about cats");
242
+ * console.log(jokeResult);
243
+ * ```
244
+ *
245
+ * ```txt
246
+ * {
247
+ * setup: 'What do you call a cat that loves to bowl?',
248
+ * punchline: 'An alley cat!'
249
+ * }
250
+ * ```
251
+ * </details>
252
+ *
253
+ * <br />
254
+ *
255
+ * <details>
256
+ * <summary><strong>Usage Metadata</strong></summary>
257
+ *
258
+ * ```typescript
259
+ * const aiMsgForMetadata = await llm.invoke(input);
260
+ * console.log(aiMsgForMetadata.usage_metadata);
261
+ * ```
262
+ *
263
+ * ```txt
264
+ * { input_tokens: 9, output_tokens: 8, total_tokens: 17 }
265
+ * ```
266
+ * </details>
267
+ *
268
+ * <br />
269
+ *
270
+ * <details>
271
+ * <summary><strong>Stream Usage Metadata</strong></summary>
272
+ *
273
+ * ```typescript
274
+ * const streamForMetadata = await llm.stream(
275
+ * input,
276
+ * {
277
+ * streamUsage: true
278
+ * }
279
+ * );
280
+ * let fullForMetadata: AIMessageChunk | undefined;
281
+ * for await (const chunk of streamForMetadata) {
282
+ * fullForMetadata = !fullForMetadata ? chunk : concat(fullForMetadata, chunk);
283
+ * }
284
+ * console.log(fullForMetadata?.usage_metadata);
285
+ * ```
286
+ *
287
+ * ```txt
288
+ * { input_tokens: 9, output_tokens: 8, total_tokens: 17 }
289
+ * ```
290
+ * </details>
291
+ *
292
+ * <br />
293
+ */
294
+ declare class ChatVertexAI extends ChatGoogle {
295
+ lc_namespace: string[];
296
+ static lc_name(): string;
297
+ constructor(fields?: ChatVertexAIInput);
298
+ }
299
+ //#endregion
300
+ export { ChatVertexAI, ChatVertexAIInput };
301
+ //# 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-webauth\";\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 declare class ChatVertexAI extends ChatGoogle {\n lc_namespace: string[];\n static lc_name(): string;\n constructor(fields?: ChatVertexAIInput);\n}\n"],"mappings":";;;;;;AAIA;AA+RqBG,UA/RJD,iBAAAA,SAA0BF,eA+RV,CAAA;;;AAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAA/BG,YAAAA,SAAqBF,UAAAA;;;uBAGjBC"}
@@ -1,9 +1,11 @@
1
- import { type ChatGoogleInput, ChatGoogle } from "@langchain/google-webauth";
1
+ import { ChatGoogle, ChatGoogleInput } from "@langchain/google-webauth";
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 in web environments.
9
11
  *
@@ -289,8 +291,11 @@ export interface ChatVertexAIInput extends ChatGoogleInput {
289
291
  *
290
292
  * <br />
291
293
  */
292
- export declare class ChatVertexAI extends ChatGoogle {
293
- lc_namespace: string[];
294
- static lc_name(): string;
295
- constructor(fields?: ChatVertexAIInput);
294
+ declare class ChatVertexAI extends ChatGoogle {
295
+ lc_namespace: string[];
296
+ static lc_name(): string;
297
+ constructor(fields?: ChatVertexAIInput);
296
298
  }
299
+ //#endregion
300
+ export { ChatVertexAI, ChatVertexAIInput };
301
+ //# 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-webauth\";\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 declare class ChatVertexAI extends ChatGoogle {\n lc_namespace: string[];\n static lc_name(): string;\n constructor(fields?: ChatVertexAIInput);\n}\n"],"mappings":";;;;;;AAIA;AA+RqBG,UA/RJD,iBAAAA,SAA0BF,eA+RV,CAAA;;;AAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAA/BG,YAAAA,SAAqBF,UAAAA;;;uBAGjBC"}