@blaxel/langgraph 0.2.50-dev.215 → 0.2.50

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 (35) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/.tsbuildinfo +1 -1
  3. package/dist/cjs/model/cohere.js +74 -0
  4. package/dist/cjs/model/google-genai.js +75 -12
  5. package/dist/cjs/model.js +1 -1
  6. package/dist/cjs/types/model/google-genai.d.ts +20 -3
  7. package/dist/esm/.tsbuildinfo +1 -1
  8. package/dist/esm/model/cohere.js +74 -0
  9. package/dist/esm/model/google-genai.js +74 -11
  10. package/dist/esm/model.js +1 -1
  11. package/package.json +3 -2
  12. package/dist/cjs/model/google-genai/chat_models.js +0 -766
  13. package/dist/cjs/model/google-genai/embeddings.js +0 -111
  14. package/dist/cjs/model/google-genai/index.js +0 -18
  15. package/dist/cjs/model/google-genai/output_parsers.js +0 -51
  16. package/dist/cjs/model/google-genai/types.js +0 -2
  17. package/dist/cjs/model/google-genai/utils/common.js +0 -390
  18. package/dist/cjs/model/google-genai/utils/tools.js +0 -110
  19. package/dist/cjs/model/google-genai/utils/zod_to_genai_parameters.js +0 -46
  20. package/dist/cjs/types/model/google-genai/chat_models.d.ts +0 -557
  21. package/dist/cjs/types/model/google-genai/embeddings.d.ts +0 -94
  22. package/dist/cjs/types/model/google-genai/index.d.ts +0 -2
  23. package/dist/cjs/types/model/google-genai/output_parsers.d.ts +0 -20
  24. package/dist/cjs/types/model/google-genai/types.d.ts +0 -3
  25. package/dist/cjs/types/model/google-genai/utils/common.d.ts +0 -22
  26. package/dist/cjs/types/model/google-genai/utils/tools.d.ts +0 -10
  27. package/dist/cjs/types/model/google-genai/utils/zod_to_genai_parameters.d.ts +0 -13
  28. package/dist/esm/model/google-genai/chat_models.js +0 -762
  29. package/dist/esm/model/google-genai/embeddings.js +0 -107
  30. package/dist/esm/model/google-genai/index.js +0 -2
  31. package/dist/esm/model/google-genai/output_parsers.js +0 -47
  32. package/dist/esm/model/google-genai/types.js +0 -1
  33. package/dist/esm/model/google-genai/utils/common.js +0 -381
  34. package/dist/esm/model/google-genai/utils/tools.js +0 -107
  35. package/dist/esm/model/google-genai/utils/zod_to_genai_parameters.js +0 -41
@@ -1,46 +0,0 @@
1
- "use strict";
2
- /* eslint-disable @typescript-eslint/no-unused-vars */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.removeAdditionalProperties = removeAdditionalProperties;
5
- exports.zodToGenerativeAIParameters = zodToGenerativeAIParameters;
6
- exports.jsonSchemaToGeminiParameters = jsonSchemaToGeminiParameters;
7
- const zod_to_json_schema_1 = require("zod-to-json-schema");
8
- function removeAdditionalProperties(
9
- // eslint-disable @typescript-eslint/no-explicit-any
10
- obj) {
11
- if (typeof obj === "object" && obj !== null) {
12
- const newObj = { ...obj };
13
- if ("additionalProperties" in newObj) {
14
- delete newObj.additionalProperties;
15
- }
16
- if ("$schema" in newObj) {
17
- delete newObj.$schema;
18
- }
19
- for (const key in newObj) {
20
- if (key in newObj) {
21
- if (Array.isArray(newObj[key])) {
22
- newObj[key] = newObj[key].map(removeAdditionalProperties);
23
- }
24
- else if (typeof newObj[key] === "object" && newObj[key] !== null) {
25
- newObj[key] = removeAdditionalProperties(newObj[key]);
26
- }
27
- }
28
- }
29
- return newObj;
30
- }
31
- return obj;
32
- }
33
- function zodToGenerativeAIParameters(zodObj) {
34
- // GenerativeAI doesn't accept either the $schema or additionalProperties
35
- // attributes, so we need to explicitly remove them.
36
- const jsonSchema = removeAdditionalProperties((0, zod_to_json_schema_1.zodToJsonSchema)(zodObj));
37
- const { $schema, ...rest } = jsonSchema;
38
- return rest;
39
- }
40
- function jsonSchemaToGeminiParameters(schema) {
41
- // Gemini doesn't accept either the $schema or additionalProperties
42
- // attributes, so we need to explicitly remove them.
43
- const jsonSchema = removeAdditionalProperties(schema);
44
- const { $schema, ...rest } = jsonSchema;
45
- return rest;
46
- }
@@ -1,557 +0,0 @@
1
- import { GenerateContentRequest, Part as GenerativeAIPart, GenerativeModel, ModelParams, RequestOptions, SafetySetting, type CachedContent } from "@google/generative-ai";
2
- import { CallbackManagerForLLMRun } from "@langchain/core/callbacks/manager";
3
- import { BaseLanguageModelInput, StructuredOutputMethodOptions } from "@langchain/core/language_models/base";
4
- import { BaseChatModel, type BaseChatModelCallOptions, type BaseChatModelParams, type LangSmithParams } from "@langchain/core/language_models/chat_models";
5
- import { AIMessageChunk, BaseMessage } from "@langchain/core/messages";
6
- import { ChatGenerationChunk, ChatResult } from "@langchain/core/outputs";
7
- import { Runnable } from "@langchain/core/runnables";
8
- import type { z } from "zod";
9
- import { GoogleGenerativeAIToolType } from "./types.js";
10
- export type BaseMessageExamplePair = {
11
- input: BaseMessage;
12
- output: BaseMessage;
13
- };
14
- export interface GoogleGenerativeAIChatCallOptions extends BaseChatModelCallOptions {
15
- tools?: GoogleGenerativeAIToolType[];
16
- /**
17
- * Allowed functions to call when the mode is "any".
18
- * If empty, any one of the provided functions are called.
19
- */
20
- allowedFunctionNames?: string[];
21
- /**
22
- * Whether or not to include usage data, like token counts
23
- * in the streamed response chunks.
24
- * @default true
25
- */
26
- streamUsage?: boolean;
27
- }
28
- /**
29
- * An interface defining the input to the ChatGoogleGenerativeAI class.
30
- */
31
- export interface GoogleGenerativeAIChatInput extends BaseChatModelParams, Pick<GoogleGenerativeAIChatCallOptions, "streamUsage"> {
32
- /**
33
- * @deprecated Use "model" instead.
34
- *
35
- * Model Name to use
36
- *
37
- * Alias for `model`
38
- *
39
- * Note: The format must follow the pattern - `{model}`
40
- */
41
- modelName?: string;
42
- /**
43
- * Model Name to use
44
- *
45
- * Note: The format must follow the pattern - `{model}`
46
- */
47
- model?: string;
48
- /**
49
- * Custom headers to send to the API
50
- */
51
- customHeaders?: Record<string, string>;
52
- /**
53
- * Controls the randomness of the output.
54
- *
55
- * Values can range from [0.0,1.0], inclusive. A value closer to 1.0
56
- * will produce responses that are more varied and creative, while
57
- * a value closer to 0.0 will typically result in less surprising
58
- * responses from the model.
59
- *
60
- * Note: The default value varies by model
61
- */
62
- temperature?: number;
63
- /**
64
- * Maximum number of tokens to generate in the completion.
65
- */
66
- maxOutputTokens?: number;
67
- /**
68
- * Top-p changes how the model selects tokens for output.
69
- *
70
- * Tokens are selected from most probable to least until the sum
71
- * of their probabilities equals the top-p value.
72
- *
73
- * For example, if tokens A, B, and C have a probability of
74
- * .3, .2, and .1 and the top-p value is .5, then the model will
75
- * select either A or B as the next token (using temperature).
76
- *
77
- * Note: The default value varies by model
78
- */
79
- topP?: number;
80
- /**
81
- * Top-k changes how the model selects tokens for output.
82
- *
83
- * A top-k of 1 means the selected token is the most probable among
84
- * all tokens in the model's vocabulary (also called greedy decoding),
85
- * while a top-k of 3 means that the next token is selected from
86
- * among the 3 most probable tokens (using temperature).
87
- *
88
- * Note: The default value varies by model
89
- */
90
- topK?: number;
91
- /**
92
- * The set of character sequences (up to 5) that will stop output generation.
93
- * If specified, the API will stop at the first appearance of a stop
94
- * sequence.
95
- *
96
- * Note: The stop sequence will not be included as part of the response.
97
- * Note: stopSequences is only supported for Gemini models
98
- */
99
- stopSequences?: string[];
100
- /**
101
- * A list of unique `SafetySetting` instances for blocking unsafe content. The API will block
102
- * any prompts and responses that fail to meet the thresholds set by these settings. If there
103
- * is no `SafetySetting` for a given `SafetyCategory` provided in the list, the API will use
104
- * the default safety setting for that category.
105
- */
106
- safetySettings?: SafetySetting[];
107
- /**
108
- * Google API key to use
109
- */
110
- apiKey?: string;
111
- /**
112
- * Google API version to use
113
- */
114
- apiVersion?: string;
115
- /**
116
- * Google API base URL to use
117
- */
118
- baseUrl?: string;
119
- /** Whether to stream the results or not */
120
- streaming?: boolean;
121
- /**
122
- * Whether or not to force the model to respond with JSON.
123
- * Available for `gemini-1.5` models and later.
124
- * @default false
125
- */
126
- json?: boolean;
127
- /**
128
- * Whether or not model supports system instructions.
129
- * The following models support system instructions:
130
- * - All Gemini 1.5 Pro model versions
131
- * - All Gemini 1.5 Flash model versions
132
- * - Gemini 1.0 Pro version gemini-1.0-pro-002
133
- */
134
- convertSystemMessageToHumanContent?: boolean | undefined;
135
- }
136
- /**
137
- * Google Generative AI chat model integration.
138
- *
139
- * Setup:
140
- * Install `@langchain/google-genai` and set an environment variable named `GOOGLE_API_KEY`.
141
- *
142
- * ```bash
143
- * pnpm install @langchain/google-genai
144
- * export GOOGLE_API_KEY="your-api-key"
145
- * ```
146
- *
147
- * ## [Constructor args](https://api.js.langchain.com/classes/langchain_google_genai.ChatGoogleGenerativeAI.html#constructor)
148
- *
149
- * ## [Runtime args](https://api.js.langchain.com/interfaces/langchain_google_genai.GoogleGenerativeAIChatCallOptions.html)
150
- *
151
- * Runtime args can be passed as the second argument to any of the base runnable methods `.invoke`. `.stream`, `.batch`, etc.
152
- * They can also be passed via `.bind`, or the second arg in `.bindTools`, like shown in the examples below:
153
- *
154
- * ```typescript
155
- * // When calling `.bind`, call options should be passed via the first argument
156
- * const llmWithArgsBound = llm.bind({
157
- * stop: ["\n"],
158
- * tools: [...],
159
- * });
160
- *
161
- * // When calling `.bindTools`, call options should be passed via the second argument
162
- * const llmWithTools = llm.bindTools(
163
- * [...],
164
- * {
165
- * stop: ["\n"],
166
- * }
167
- * );
168
- * ```
169
- *
170
- * ## Examples
171
- *
172
- * <details open>
173
- * <summary><strong>Instantiate</strong></summary>
174
- *
175
- * ```typescript
176
- * import { ChatGoogleGenerativeAI } from '@langchain/google-genai';
177
- *
178
- * const llm = new ChatGoogleGenerativeAI({
179
- * model: "gemini-1.5-flash",
180
- * temperature: 0,
181
- * maxRetries: 2,
182
- * // apiKey: "...",
183
- * // other params...
184
- * });
185
- * ```
186
- * </details>
187
- *
188
- * <br />
189
- *
190
- * <details>
191
- * <summary><strong>Invoking</strong></summary>
192
- *
193
- * ```typescript
194
- * const input = `Translate "I love programming" into French.`;
195
- *
196
- * // Models also accept a list of chat messages or a formatted prompt
197
- * const result = await llm.invoke(input);
198
- * console.log(result);
199
- * ```
200
- *
201
- * ```txt
202
- * AIMessage {
203
- * "content": "There are a few ways to translate \"I love programming\" into French, depending on the level of formality and nuance you want to convey:\n\n**Formal:**\n\n* **J'aime la programmation.** (This is the most literal and formal translation.)\n\n**Informal:**\n\n* **J'adore programmer.** (This is a more enthusiastic and informal translation.)\n* **J'aime beaucoup programmer.** (This is a slightly less enthusiastic but still informal translation.)\n\n**More specific:**\n\n* **J'aime beaucoup coder.** (This specifically refers to writing code.)\n* **J'aime beaucoup développer des logiciels.** (This specifically refers to developing software.)\n\nThe best translation will depend on the context and your intended audience. \n",
204
- * "response_metadata": {
205
- * "finishReason": "STOP",
206
- * "index": 0,
207
- * "safetyRatings": [
208
- * {
209
- * "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
210
- * "probability": "NEGLIGIBLE"
211
- * },
212
- * {
213
- * "category": "HARM_CATEGORY_HATE_SPEECH",
214
- * "probability": "NEGLIGIBLE"
215
- * },
216
- * {
217
- * "category": "HARM_CATEGORY_HARASSMENT",
218
- * "probability": "NEGLIGIBLE"
219
- * },
220
- * {
221
- * "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
222
- * "probability": "NEGLIGIBLE"
223
- * }
224
- * ]
225
- * },
226
- * "usage_metadata": {
227
- * "input_tokens": 10,
228
- * "output_tokens": 149,
229
- * "total_tokens": 159
230
- * }
231
- * }
232
- * ```
233
- * </details>
234
- *
235
- * <br />
236
- *
237
- * <details>
238
- * <summary><strong>Streaming Chunks</strong></summary>
239
- *
240
- * ```typescript
241
- * for await (const chunk of await llm.stream(input)) {
242
- * console.log(chunk);
243
- * }
244
- * ```
245
- *
246
- * ```txt
247
- * AIMessageChunk {
248
- * "content": "There",
249
- * "response_metadata": {
250
- * "index": 0
251
- * }
252
- * "usage_metadata": {
253
- * "input_tokens": 10,
254
- * "output_tokens": 1,
255
- * "total_tokens": 11
256
- * }
257
- * }
258
- * AIMessageChunk {
259
- * "content": " are a few ways to translate \"I love programming\" into French, depending on",
260
- * }
261
- * AIMessageChunk {
262
- * "content": " the level of formality and nuance you want to convey:\n\n**Formal:**\n\n",
263
- * }
264
- * AIMessageChunk {
265
- * "content": "* **J'aime la programmation.** (This is the most literal and formal translation.)\n\n**Informal:**\n\n* **J'adore programmer.** (This",
266
- * }
267
- * AIMessageChunk {
268
- * "content": " is a more enthusiastic and informal translation.)\n* **J'aime beaucoup programmer.** (This is a slightly less enthusiastic but still informal translation.)\n\n**More",
269
- * }
270
- * AIMessageChunk {
271
- * "content": " specific:**\n\n* **J'aime beaucoup coder.** (This specifically refers to writing code.)\n* **J'aime beaucoup développer des logiciels.** (This specifically refers to developing software.)\n\nThe best translation will depend on the context and",
272
- * }
273
- * AIMessageChunk {
274
- * "content": " your intended audience. \n",
275
- * }
276
- * ```
277
- * </details>
278
- *
279
- * <br />
280
- *
281
- * <details>
282
- * <summary><strong>Aggregate Streamed Chunks</strong></summary>
283
- *
284
- * ```typescript
285
- * import { AIMessageChunk } from '@langchain/core/messages';
286
- * import { concat } from '@langchain/core/utils/stream';
287
- *
288
- * const stream = await llm.stream(input);
289
- * let full: AIMessageChunk | undefined;
290
- * for await (const chunk of stream) {
291
- * full = !full ? chunk : concat(full, chunk);
292
- * }
293
- * console.log(full);
294
- * ```
295
- *
296
- * ```txt
297
- * AIMessageChunk {
298
- * "content": "There are a few ways to translate \"I love programming\" into French, depending on the level of formality and nuance you want to convey:\n\n**Formal:**\n\n* **J'aime la programmation.** (This is the most literal and formal translation.)\n\n**Informal:**\n\n* **J'adore programmer.** (This is a more enthusiastic and informal translation.)\n* **J'aime beaucoup programmer.** (This is a slightly less enthusiastic but still informal translation.)\n\n**More specific:**\n\n* **J'aime beaucoup coder.** (This specifically refers to writing code.)\n* **J'aime beaucoup développer des logiciels.** (This specifically refers to developing software.)\n\nThe best translation will depend on the context and your intended audience. \n",
299
- * "usage_metadata": {
300
- * "input_tokens": 10,
301
- * "output_tokens": 277,
302
- * "total_tokens": 287
303
- * }
304
- * }
305
- * ```
306
- * </details>
307
- *
308
- * <br />
309
- *
310
- * <details>
311
- * <summary><strong>Bind tools</strong></summary>
312
- *
313
- * ```typescript
314
- * import { z } from 'zod';
315
- *
316
- * const GetWeather = {
317
- * name: "GetWeather",
318
- * description: "Get the current weather in a given location",
319
- * schema: z.object({
320
- * location: z.string().describe("The city and state, e.g. San Francisco, CA")
321
- * }),
322
- * }
323
- *
324
- * const GetPopulation = {
325
- * name: "GetPopulation",
326
- * description: "Get the current population in a given location",
327
- * schema: z.object({
328
- * location: z.string().describe("The city and state, e.g. San Francisco, CA")
329
- * }),
330
- * }
331
- *
332
- * const llmWithTools = llm.bindTools([GetWeather, GetPopulation]);
333
- * const aiMsg = await llmWithTools.invoke(
334
- * "Which city is hotter today and which is bigger: LA or NY?"
335
- * );
336
- * console.log(aiMsg.tool_calls);
337
- * ```
338
- *
339
- * ```txt
340
- * [
341
- * {
342
- * name: 'GetWeather',
343
- * args: { location: 'Los Angeles, CA' },
344
- * type: 'tool_call'
345
- * },
346
- * {
347
- * name: 'GetWeather',
348
- * args: { location: 'New York, NY' },
349
- * type: 'tool_call'
350
- * },
351
- * {
352
- * name: 'GetPopulation',
353
- * args: { location: 'Los Angeles, CA' },
354
- * type: 'tool_call'
355
- * },
356
- * {
357
- * name: 'GetPopulation',
358
- * args: { location: 'New York, NY' },
359
- * type: 'tool_call'
360
- * }
361
- * ]
362
- * ```
363
- * </details>
364
- *
365
- * <br />
366
- *
367
- * <details>
368
- * <summary><strong>Structured Output</strong></summary>
369
- *
370
- * ```typescript
371
- * const Joke = z.object({
372
- * setup: z.string().describe("The setup of the joke"),
373
- * punchline: z.string().describe("The punchline to the joke"),
374
- * rating: z.number().optional().describe("How funny the joke is, from 1 to 10")
375
- * }).describe('Joke to tell user.');
376
- *
377
- * const structuredLlm = llm.withStructuredOutput(Joke, { name: "Joke" });
378
- * const jokeResult = await structuredLlm.invoke("Tell me a joke about cats");
379
- * console.log(jokeResult);
380
- * ```
381
- *
382
- * ```txt
383
- * {
384
- * setup: "Why don\\'t cats play poker?",
385
- * punchline: "Why don\\'t cats play poker? Because they always have an ace up their sleeve!"
386
- * }
387
- * ```
388
- * </details>
389
- *
390
- * <br />
391
- *
392
- * <details>
393
- * <summary><strong>Multimodal</strong></summary>
394
- *
395
- * ```typescript
396
- * import { HumanMessage } from '@langchain/core/messages';
397
- *
398
- * const imageUrl = "https://example.com/image.jpg";
399
- * const imageData = await fetch(imageUrl).then(res => res.arrayBuffer());
400
- * const base64Image = Buffer.from(imageData).toString('base64');
401
- *
402
- * const message = new HumanMessage({
403
- * content: [
404
- * { type: "text", text: "describe the weather in this image" },
405
- * {
406
- * type: "image_url",
407
- * image_url: { url: `data:image/jpeg;base64,${base64Image}` },
408
- * },
409
- * ]
410
- * });
411
- *
412
- * const imageDescriptionAiMsg = await llm.invoke([message]);
413
- * console.log(imageDescriptionAiMsg.content);
414
- * ```
415
- *
416
- * ```txt
417
- * The weather in the image appears to be clear and sunny. The sky is mostly blue with a few scattered white clouds, indicating fair weather. The bright sunlight is casting shadows on the green, grassy hill, suggesting it is a pleasant day with good visibility. There are no signs of rain or stormy conditions.
418
- * ```
419
- * </details>
420
- *
421
- * <br />
422
- *
423
- * <details>
424
- * <summary><strong>Usage Metadata</strong></summary>
425
- *
426
- * ```typescript
427
- * const aiMsgForMetadata = await llm.invoke(input);
428
- * console.log(aiMsgForMetadata.usage_metadata);
429
- * ```
430
- *
431
- * ```txt
432
- * { input_tokens: 10, output_tokens: 149, total_tokens: 159 }
433
- * ```
434
- * </details>
435
- *
436
- * <br />
437
- *
438
- * <details>
439
- * <summary><strong>Response Metadata</strong></summary>
440
- *
441
- * ```typescript
442
- * const aiMsgForResponseMetadata = await llm.invoke(input);
443
- * console.log(aiMsgForResponseMetadata.response_metadata);
444
- * ```
445
- *
446
- * ```txt
447
- * {
448
- * finishReason: 'STOP',
449
- * index: 0,
450
- * safetyRatings: [
451
- * {
452
- * category: 'HARM_CATEGORY_SEXUALLY_EXPLICIT',
453
- * probability: 'NEGLIGIBLE'
454
- * },
455
- * {
456
- * category: 'HARM_CATEGORY_HATE_SPEECH',
457
- * probability: 'NEGLIGIBLE'
458
- * },
459
- * { category: 'HARM_CATEGORY_HARASSMENT', probability: 'NEGLIGIBLE' },
460
- * {
461
- * category: 'HARM_CATEGORY_DANGEROUS_CONTENT',
462
- * probability: 'NEGLIGIBLE'
463
- * }
464
- * ]
465
- * }
466
- * ```
467
- * </details>
468
- *
469
- * <br />
470
- *
471
- * <details>
472
- * <summary><strong>Document Messages</strong></summary>
473
- *
474
- * This example will show you how to pass documents such as PDFs to Google
475
- * Generative AI through messages.
476
- *
477
- * ```typescript
478
- * const pdfPath = "/Users/my_user/Downloads/invoice.pdf";
479
- * const pdfBase64 = await fs.readFile(pdfPath, "base64");
480
- *
481
- * const response = await llm.invoke([
482
- * ["system", "Use the provided documents to answer the question"],
483
- * [
484
- * "user",
485
- * [
486
- * {
487
- * type: "application/pdf", // If the `type` field includes a single slash (`/`), it will be treated as inline data.
488
- * data: pdfBase64,
489
- * },
490
- * {
491
- * type: "text",
492
- * text: "Summarize the contents of this PDF",
493
- * },
494
- * ],
495
- * ],
496
- * ]);
497
- *
498
- * console.log(response.content);
499
- * ```
500
- *
501
- * ```txt
502
- * This is a billing invoice from Twitter Developers for X API Basic Access. The transaction date is January 7, 2025,
503
- * and the amount is $194.34, which has been paid. The subscription period is from January 7, 2025 21:02 to February 7, 2025 00:00 (UTC).
504
- * The tax is $0.00, with a tax rate of 0%. The total amount is $194.34. The payment was made using a Visa card ending in 7022,
505
- * expiring in 12/2026. The billing address is Brace Sproul, 1234 Main Street, San Francisco, CA, US 94103. The company being billed is
506
- * X Corp, located at 865 FM 1209 Building 2, Bastrop, TX, US 78602. Terms and conditions apply.
507
- * ```
508
- * </details>
509
- *
510
- * <br />
511
- */
512
- export declare class ChatGoogleGenerativeAI extends BaseChatModel<GoogleGenerativeAIChatCallOptions, AIMessageChunk> implements GoogleGenerativeAIChatInput {
513
- static lc_name(): string;
514
- lc_serializable: boolean;
515
- get lc_secrets(): {
516
- [key: string]: string;
517
- } | undefined;
518
- lc_namespace: string[];
519
- get lc_aliases(): {
520
- apiKey: string;
521
- };
522
- modelName: string;
523
- model: string;
524
- customHeaders?: Record<string, string>;
525
- temperature?: number;
526
- maxOutputTokens?: number;
527
- topP?: number;
528
- topK?: number;
529
- stopSequences: string[];
530
- safetySettings?: SafetySetting[];
531
- apiKey?: string;
532
- streaming: boolean;
533
- streamUsage: boolean;
534
- convertSystemMessageToHumanContent: boolean | undefined;
535
- baseUrl?: string;
536
- apiVersion?: string;
537
- client: GenerativeModel;
538
- get _isMultimodalModel(): boolean;
539
- constructor(fields?: GoogleGenerativeAIChatInput);
540
- initClient(fields?: GoogleGenerativeAIChatInput): GenerativeModel;
541
- useCachedContent(cachedContent: CachedContent, modelParams?: ModelParams, requestOptions?: RequestOptions): void;
542
- get useSystemInstruction(): boolean;
543
- get computeUseSystemInstruction(): boolean;
544
- getLsParams(options: this["ParsedCallOptions"]): LangSmithParams;
545
- _combineLLMOutput(): never[];
546
- _llmType(): string;
547
- bindTools(tools: GoogleGenerativeAIToolType[], kwargs?: Partial<GoogleGenerativeAIChatCallOptions>): Runnable<BaseLanguageModelInput, AIMessageChunk, GoogleGenerativeAIChatCallOptions>;
548
- invocationParams(options?: this["ParsedCallOptions"]): Omit<GenerateContentRequest, "contents">;
549
- _generate(messages: BaseMessage[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): Promise<ChatResult>;
550
- _streamResponseChunks(messages: BaseMessage[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatGenerationChunk>;
551
- completionWithRetry(request: string | GenerateContentRequest | (string | GenerativeAIPart)[], options?: this["ParsedCallOptions"]): Promise<import("@google/generative-ai").GenerateContentResult>;
552
- withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: z.ZodType<RunOutput> | Record<string, any>, config?: StructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;
553
- withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: z.ZodType<RunOutput> | Record<string, any>, config?: StructuredOutputMethodOptions<true>): Runnable<BaseLanguageModelInput, {
554
- raw: BaseMessage;
555
- parsed: RunOutput;
556
- }>;
557
- }
@@ -1,94 +0,0 @@
1
- import { TaskType } from "@google/generative-ai";
2
- import { Embeddings, EmbeddingsParams } from "@langchain/core/embeddings";
3
- /**
4
- * Interface that extends EmbeddingsParams and defines additional
5
- * parameters specific to the GoogleGenerativeAIEmbeddings class.
6
- */
7
- export interface GoogleGenerativeAIEmbeddingsParams extends EmbeddingsParams {
8
- /**
9
- * Model Name to use
10
- *
11
- * Alias for `model`
12
- *
13
- * Note: The format must follow the pattern - `{model}`
14
- */
15
- modelName?: string;
16
- /**
17
- * Model Name to use
18
- *
19
- * Note: The format must follow the pattern - `{model}`
20
- */
21
- model?: string;
22
- /**
23
- * Type of task for which the embedding will be used
24
- *
25
- * Note: currently only supported by `embedding-001` model
26
- */
27
- taskType?: TaskType;
28
- /**
29
- * An optional title for the text. Only applicable when TaskType is
30
- * `RETRIEVAL_DOCUMENT`
31
- *
32
- * Note: currently only supported by `embedding-001` model
33
- */
34
- title?: string;
35
- /**
36
- * Whether to strip new lines from the input text. Default to true
37
- */
38
- stripNewLines?: boolean;
39
- /**
40
- * Google API key to use
41
- */
42
- apiKey?: string;
43
- }
44
- /**
45
- * Class that extends the Embeddings class and provides methods for
46
- * generating embeddings using the Google Palm API.
47
- * @example
48
- * ```typescript
49
- * const model = new GoogleGenerativeAIEmbeddings({
50
- * apiKey: "<YOUR API KEY>",
51
- * modelName: "embedding-001",
52
- * });
53
- *
54
- * // Embed a single query
55
- * const res = await model.embedQuery(
56
- * "What would be a good company name for a company that makes colorful socks?"
57
- * );
58
- * console.log({ res });
59
- *
60
- * // Embed multiple documents
61
- * const documentRes = await model.embedDocuments(["Hello world", "Bye bye"]);
62
- * console.log({ documentRes });
63
- * ```
64
- */
65
- export declare class GoogleGenerativeAIEmbeddings extends Embeddings implements GoogleGenerativeAIEmbeddingsParams {
66
- apiKey?: string;
67
- modelName: string;
68
- model: string;
69
- taskType?: TaskType;
70
- title?: string;
71
- stripNewLines: boolean;
72
- maxBatchSize: number;
73
- private client;
74
- constructor(fields?: GoogleGenerativeAIEmbeddingsParams);
75
- private _convertToContent;
76
- protected _embedQueryContent(text: string): Promise<number[]>;
77
- protected _embedDocumentsContent(documents: string[]): Promise<number[][]>;
78
- /**
79
- * Method that takes a document as input and returns a promise that
80
- * resolves to an embedding for the document. It calls the _embedText
81
- * method with the document as the input.
82
- * @param document Document for which to generate an embedding.
83
- * @returns Promise that resolves to an embedding for the input document.
84
- */
85
- embedQuery(document: string): Promise<number[]>;
86
- /**
87
- * Method that takes an array of documents as input and returns a promise
88
- * that resolves to a 2D array of embeddings for each document. It calls
89
- * the _embedText method for each document in the array.
90
- * @param documents Array of documents for which to generate embeddings.
91
- * @returns Promise that resolves to a 2D array of embeddings for each input document.
92
- */
93
- embedDocuments(documents: string[]): Promise<number[][]>;
94
- }
@@ -1,2 +0,0 @@
1
- export * from "./chat_models.js";
2
- export * from "./embeddings.js";