@langchain/google-genai 0.2.18 → 1.0.1

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 (59) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/LICENSE +6 -6
  3. package/README.md +8 -8
  4. package/dist/_virtual/rolldown_runtime.cjs +25 -0
  5. package/dist/chat_models.cjs +688 -847
  6. package/dist/chat_models.cjs.map +1 -0
  7. package/dist/chat_models.d.cts +575 -0
  8. package/dist/chat_models.d.cts.map +1 -0
  9. package/dist/chat_models.d.ts +190 -157
  10. package/dist/chat_models.d.ts.map +1 -0
  11. package/dist/chat_models.js +686 -842
  12. package/dist/chat_models.js.map +1 -0
  13. package/dist/embeddings.cjs +97 -151
  14. package/dist/embeddings.cjs.map +1 -0
  15. package/dist/embeddings.d.cts +104 -0
  16. package/dist/embeddings.d.cts.map +1 -0
  17. package/dist/embeddings.d.ts +76 -70
  18. package/dist/embeddings.d.ts.map +1 -0
  19. package/dist/embeddings.js +93 -144
  20. package/dist/embeddings.js.map +1 -0
  21. package/dist/index.cjs +5 -18
  22. package/dist/index.d.cts +3 -0
  23. package/dist/index.d.ts +3 -2
  24. package/dist/index.js +4 -2
  25. package/dist/output_parsers.cjs +47 -75
  26. package/dist/output_parsers.cjs.map +1 -0
  27. package/dist/output_parsers.js +47 -72
  28. package/dist/output_parsers.js.map +1 -0
  29. package/dist/profiles.cjs +345 -0
  30. package/dist/profiles.cjs.map +1 -0
  31. package/dist/profiles.js +344 -0
  32. package/dist/profiles.js.map +1 -0
  33. package/dist/types.d.cts +8 -0
  34. package/dist/types.d.cts.map +1 -0
  35. package/dist/types.d.ts +7 -2
  36. package/dist/types.d.ts.map +1 -0
  37. package/dist/utils/common.cjs +356 -549
  38. package/dist/utils/common.cjs.map +1 -0
  39. package/dist/utils/common.js +357 -545
  40. package/dist/utils/common.js.map +1 -0
  41. package/dist/utils/tools.cjs +65 -102
  42. package/dist/utils/tools.cjs.map +1 -0
  43. package/dist/utils/tools.js +64 -99
  44. package/dist/utils/tools.js.map +1 -0
  45. package/dist/utils/zod_to_genai_parameters.cjs +31 -49
  46. package/dist/utils/zod_to_genai_parameters.cjs.map +1 -0
  47. package/dist/utils/zod_to_genai_parameters.js +29 -45
  48. package/dist/utils/zod_to_genai_parameters.js.map +1 -0
  49. package/package.json +45 -51
  50. package/dist/output_parsers.d.ts +0 -20
  51. package/dist/types.cjs +0 -2
  52. package/dist/types.js +0 -1
  53. package/dist/utils/common.d.ts +0 -22
  54. package/dist/utils/tools.d.ts +0 -10
  55. package/dist/utils/zod_to_genai_parameters.d.ts +0 -14
  56. package/index.cjs +0 -1
  57. package/index.d.cts +0 -1
  58. package/index.d.ts +0 -1
  59. package/index.js +0 -1
@@ -1,127 +1,131 @@
1
- import { GenerateContentRequest, SafetySetting, Part as GenerativeAIPart, ModelParams, RequestOptions, type CachedContent, Schema } from "@google/generative-ai";
2
- import { CallbackManagerForLLMRun } from "@langchain/core/callbacks/manager";
1
+ import { GoogleGenerativeAIToolType } from "./types.js";
2
+ import * as _google_generative_ai0 from "@google/generative-ai";
3
+ import { CachedContent, GenerateContentRequest, ModelParams, Part, RequestOptions, SafetySetting, Schema } from "@google/generative-ai";
4
+ import { BaseChatModel, BaseChatModelCallOptions, BaseChatModelParams, LangSmithParams } from "@langchain/core/language_models/chat_models";
5
+ import { Runnable } from "@langchain/core/runnables";
6
+ import { InteropZodType } from "@langchain/core/utils/types";
3
7
  import { AIMessageChunk, BaseMessage } from "@langchain/core/messages";
4
8
  import { ChatGenerationChunk, ChatResult } from "@langchain/core/outputs";
5
- import { BaseChatModel, type BaseChatModelCallOptions, type LangSmithParams, type BaseChatModelParams } from "@langchain/core/language_models/chat_models";
6
9
  import { BaseLanguageModelInput, StructuredOutputMethodOptions } from "@langchain/core/language_models/base";
7
- import { Runnable } from "@langchain/core/runnables";
8
- import { InteropZodType } from "@langchain/core/utils/types";
9
- import { GoogleGenerativeAIToolType } from "./types.js";
10
- export type BaseMessageExamplePair = {
11
- input: BaseMessage;
12
- output: BaseMessage;
10
+ import { CallbackManagerForLLMRun } from "@langchain/core/callbacks/manager";
11
+ import { ModelProfile } from "@langchain/core/language_models/profile";
12
+
13
+ //#region src/chat_models.d.ts
14
+ type BaseMessageExamplePair = {
15
+ input: BaseMessage;
16
+ output: BaseMessage;
13
17
  };
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
- * JSON schema to be returned by the model.
29
- */
30
- responseSchema?: Schema;
18
+ interface GoogleGenerativeAIChatCallOptions extends BaseChatModelCallOptions {
19
+ tools?: GoogleGenerativeAIToolType[];
20
+ /**
21
+ * Allowed functions to call when the mode is "any".
22
+ * If empty, any one of the provided functions are called.
23
+ */
24
+ allowedFunctionNames?: string[];
25
+ /**
26
+ * Whether or not to include usage data, like token counts
27
+ * in the streamed response chunks.
28
+ * @default true
29
+ */
30
+ streamUsage?: boolean;
31
+ /**
32
+ * JSON schema to be returned by the model.
33
+ */
34
+ responseSchema?: Schema;
31
35
  }
32
36
  /**
33
37
  * An interface defining the input to the ChatGoogleGenerativeAI class.
34
38
  */
35
- export interface GoogleGenerativeAIChatInput extends BaseChatModelParams, Pick<GoogleGenerativeAIChatCallOptions, "streamUsage"> {
36
- /**
37
- * Model Name to use
38
- *
39
- * Note: The format must follow the pattern - `{model}`
40
- */
41
- model: string;
42
- /**
43
- * Controls the randomness of the output.
44
- *
45
- * Values can range from [0.0,2.0], inclusive. A value closer to 2.0
46
- * will produce responses that are more varied and creative, while
47
- * a value closer to 0.0 will typically result in less surprising
48
- * responses from the model.
49
- *
50
- * Note: The default value varies by model
51
- */
52
- temperature?: number;
53
- /**
54
- * Maximum number of tokens to generate in the completion.
55
- */
56
- maxOutputTokens?: number;
57
- /**
58
- * Top-p changes how the model selects tokens for output.
59
- *
60
- * Tokens are selected from most probable to least until the sum
61
- * of their probabilities equals the top-p value.
62
- *
63
- * For example, if tokens A, B, and C have a probability of
64
- * .3, .2, and .1 and the top-p value is .5, then the model will
65
- * select either A or B as the next token (using temperature).
66
- *
67
- * Note: The default value varies by model
68
- */
69
- topP?: number;
70
- /**
71
- * Top-k changes how the model selects tokens for output.
72
- *
73
- * A top-k of 1 means the selected token is the most probable among
74
- * all tokens in the model's vocabulary (also called greedy decoding),
75
- * while a top-k of 3 means that the next token is selected from
76
- * among the 3 most probable tokens (using temperature).
77
- *
78
- * Note: The default value varies by model
79
- */
80
- topK?: number;
81
- /**
82
- * The set of character sequences (up to 5) that will stop output generation.
83
- * If specified, the API will stop at the first appearance of a stop
84
- * sequence.
85
- *
86
- * Note: The stop sequence will not be included as part of the response.
87
- * Note: stopSequences is only supported for Gemini models
88
- */
89
- stopSequences?: string[];
90
- /**
91
- * A list of unique `SafetySetting` instances for blocking unsafe content. The API will block
92
- * any prompts and responses that fail to meet the thresholds set by these settings. If there
93
- * is no `SafetySetting` for a given `SafetyCategory` provided in the list, the API will use
94
- * the default safety setting for that category.
95
- */
96
- safetySettings?: SafetySetting[];
97
- /**
98
- * Google API key to use
99
- */
100
- apiKey?: string;
101
- /**
102
- * Google API version to use
103
- */
104
- apiVersion?: string;
105
- /**
106
- * Google API base URL to use
107
- */
108
- baseUrl?: string;
109
- /** Whether to stream the results or not */
110
- streaming?: boolean;
111
- /**
112
- * Whether or not to force the model to respond with JSON.
113
- * Available for `gemini-1.5` models and later.
114
- * @default false
115
- */
116
- json?: boolean;
117
- /**
118
- * Whether or not model supports system instructions.
119
- * The following models support system instructions:
120
- * - All Gemini 1.5 Pro model versions
121
- * - All Gemini 1.5 Flash model versions
122
- * - Gemini 1.0 Pro version gemini-1.0-pro-002
123
- */
124
- convertSystemMessageToHumanContent?: boolean | undefined;
39
+ interface GoogleGenerativeAIChatInput extends BaseChatModelParams, Pick<GoogleGenerativeAIChatCallOptions, "streamUsage"> {
40
+ /**
41
+ * Model Name to use
42
+ *
43
+ * Note: The format must follow the pattern - `{model}`
44
+ */
45
+ model: string;
46
+ /**
47
+ * Controls the randomness of the output.
48
+ *
49
+ * Values can range from [0.0,2.0], inclusive. A value closer to 2.0
50
+ * will produce responses that are more varied and creative, while
51
+ * a value closer to 0.0 will typically result in less surprising
52
+ * responses from the model.
53
+ *
54
+ * Note: The default value varies by model
55
+ */
56
+ temperature?: number;
57
+ /**
58
+ * Maximum number of tokens to generate in the completion.
59
+ */
60
+ maxOutputTokens?: number;
61
+ /**
62
+ * Top-p changes how the model selects tokens for output.
63
+ *
64
+ * Tokens are selected from most probable to least until the sum
65
+ * of their probabilities equals the top-p value.
66
+ *
67
+ * For example, if tokens A, B, and C have a probability of
68
+ * .3, .2, and .1 and the top-p value is .5, then the model will
69
+ * select either A or B as the next token (using temperature).
70
+ *
71
+ * Note: The default value varies by model
72
+ */
73
+ topP?: number;
74
+ /**
75
+ * Top-k changes how the model selects tokens for output.
76
+ *
77
+ * A top-k of 1 means the selected token is the most probable among
78
+ * all tokens in the model's vocabulary (also called greedy decoding),
79
+ * while a top-k of 3 means that the next token is selected from
80
+ * among the 3 most probable tokens (using temperature).
81
+ *
82
+ * Note: The default value varies by model
83
+ */
84
+ topK?: number;
85
+ /**
86
+ * The set of character sequences (up to 5) that will stop output generation.
87
+ * If specified, the API will stop at the first appearance of a stop
88
+ * sequence.
89
+ *
90
+ * Note: The stop sequence will not be included as part of the response.
91
+ * Note: stopSequences is only supported for Gemini models
92
+ */
93
+ stopSequences?: string[];
94
+ /**
95
+ * A list of unique `SafetySetting` instances for blocking unsafe content. The API will block
96
+ * any prompts and responses that fail to meet the thresholds set by these settings. If there
97
+ * is no `SafetySetting` for a given `SafetyCategory` provided in the list, the API will use
98
+ * the default safety setting for that category.
99
+ */
100
+ safetySettings?: SafetySetting[];
101
+ /**
102
+ * Google API key to use
103
+ */
104
+ apiKey?: string;
105
+ /**
106
+ * Google API version to use
107
+ */
108
+ apiVersion?: string;
109
+ /**
110
+ * Google API base URL to use
111
+ */
112
+ baseUrl?: string;
113
+ /** Whether to stream the results or not */
114
+ streaming?: boolean;
115
+ /**
116
+ * Whether or not to force the model to respond with JSON.
117
+ * Available for `gemini-1.5` models and later.
118
+ * @default false
119
+ */
120
+ json?: boolean;
121
+ /**
122
+ * Whether or not model supports system instructions.
123
+ * The following models support system instructions:
124
+ * - All Gemini 1.5 Pro model versions
125
+ * - All Gemini 1.5 Flash model versions
126
+ * - Gemini 1.0 Pro version gemini-1.0-pro-002
127
+ */
128
+ convertSystemMessageToHumanContent?: boolean | undefined;
125
129
  }
126
130
  /**
127
131
  * Google Generative AI chat model integration.
@@ -498,45 +502,74 @@ export interface GoogleGenerativeAIChatInput extends BaseChatModelParams, Pick<G
498
502
  *
499
503
  * <br />
500
504
  */
501
- export declare class ChatGoogleGenerativeAI extends BaseChatModel<GoogleGenerativeAIChatCallOptions, AIMessageChunk> implements GoogleGenerativeAIChatInput {
502
- static lc_name(): string;
503
- lc_serializable: boolean;
504
- get lc_secrets(): {
505
- [key: string]: string;
506
- } | undefined;
507
- lc_namespace: string[];
508
- get lc_aliases(): {
509
- apiKey: string;
510
- };
511
- model: string;
512
- temperature?: number;
513
- maxOutputTokens?: number;
514
- topP?: number;
515
- topK?: number;
516
- stopSequences: string[];
517
- safetySettings?: SafetySetting[];
518
- apiKey?: string;
519
- streaming: boolean;
520
- json?: boolean;
521
- streamUsage: boolean;
522
- convertSystemMessageToHumanContent: boolean | undefined;
523
- private client;
524
- get _isMultimodalModel(): boolean;
525
- constructor(fields: GoogleGenerativeAIChatInput);
526
- useCachedContent(cachedContent: CachedContent, modelParams?: ModelParams, requestOptions?: RequestOptions): void;
527
- get useSystemInstruction(): boolean;
528
- get computeUseSystemInstruction(): boolean;
529
- getLsParams(options: this["ParsedCallOptions"]): LangSmithParams;
530
- _combineLLMOutput(): never[];
531
- _llmType(): string;
532
- bindTools(tools: GoogleGenerativeAIToolType[], kwargs?: Partial<GoogleGenerativeAIChatCallOptions>): Runnable<BaseLanguageModelInput, AIMessageChunk, GoogleGenerativeAIChatCallOptions>;
533
- invocationParams(options?: this["ParsedCallOptions"]): Omit<GenerateContentRequest, "contents">;
534
- _generate(messages: BaseMessage[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): Promise<ChatResult>;
535
- _streamResponseChunks(messages: BaseMessage[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatGenerationChunk>;
536
- completionWithRetry(request: string | GenerateContentRequest | (string | GenerativeAIPart)[], options?: this["ParsedCallOptions"]): Promise<import("@google/generative-ai").GenerateContentResult>;
537
- withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput> | Record<string, any>, config?: StructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;
538
- withStructuredOutput<RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput> | Record<string, any>, config?: StructuredOutputMethodOptions<true>): Runnable<BaseLanguageModelInput, {
539
- raw: BaseMessage;
540
- parsed: RunOutput;
541
- }>;
505
+ declare class ChatGoogleGenerativeAI extends BaseChatModel<GoogleGenerativeAIChatCallOptions, AIMessageChunk> implements GoogleGenerativeAIChatInput {
506
+ static lc_name(): string;
507
+ lc_serializable: boolean;
508
+ get lc_secrets(): {
509
+ [key: string]: string;
510
+ } | undefined;
511
+ lc_namespace: string[];
512
+ get lc_aliases(): {
513
+ apiKey: string;
514
+ };
515
+ model: string;
516
+ temperature?: number; // default value chosen based on model
517
+ maxOutputTokens?: number;
518
+ topP?: number; // default value chosen based on model
519
+ topK?: number; // default value chosen based on model
520
+ stopSequences: string[];
521
+ safetySettings?: SafetySetting[];
522
+ apiKey?: string;
523
+ streaming: boolean;
524
+ json?: boolean;
525
+ streamUsage: boolean;
526
+ convertSystemMessageToHumanContent: boolean | undefined;
527
+ private client;
528
+ get _isMultimodalModel(): boolean;
529
+ constructor(fields: GoogleGenerativeAIChatInput);
530
+ useCachedContent(cachedContent: CachedContent, modelParams?: ModelParams, requestOptions?: RequestOptions): void;
531
+ get useSystemInstruction(): boolean;
532
+ get computeUseSystemInstruction(): boolean;
533
+ getLsParams(options: this["ParsedCallOptions"]): LangSmithParams;
534
+ _combineLLMOutput(): never[];
535
+ _llmType(): string;
536
+ bindTools(tools: GoogleGenerativeAIToolType[], kwargs?: Partial<GoogleGenerativeAIChatCallOptions>): Runnable<BaseLanguageModelInput, AIMessageChunk, GoogleGenerativeAIChatCallOptions>;
537
+ invocationParams(options?: this["ParsedCallOptions"]): Omit<GenerateContentRequest, "contents">;
538
+ _generate(messages: BaseMessage[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): Promise<ChatResult>;
539
+ _streamResponseChunks(messages: BaseMessage[], options: this["ParsedCallOptions"], runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatGenerationChunk>;
540
+ completionWithRetry(request: string | GenerateContentRequest | (string | Part)[], options?: this["ParsedCallOptions"]): Promise<_google_generative_ai0.GenerateContentResult>;
541
+ /**
542
+ * Return profiling information for the model.
543
+ *
544
+ * Provides information about the model's capabilities and constraints,
545
+ * including token limits, multimodal support, and advanced features like
546
+ * tool calling and structured output.
547
+ *
548
+ * @returns {ModelProfile} An object describing the model's capabilities and constraints
549
+ *
550
+ * @example
551
+ * ```typescript
552
+ * const model = new ChatGoogleGenerativeAI({ model: "gemini-1.5-flash" });
553
+ * const profile = model.profile;
554
+ * console.log(profile.maxInputTokens); // 2000000
555
+ * console.log(profile.imageInputs); // true
556
+ * ```
557
+ */
558
+ get profile(): ModelProfile;
559
+ withStructuredOutput<
560
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
561
+ RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput>
562
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
563
+ | Record<string, any>, config?: StructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;
564
+ withStructuredOutput<
565
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
566
+ RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput>
567
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
568
+ | Record<string, any>, config?: StructuredOutputMethodOptions<true>): Runnable<BaseLanguageModelInput, {
569
+ raw: BaseMessage;
570
+ parsed: RunOutput;
571
+ }>;
542
572
  }
573
+ //#endregion
574
+ export { BaseMessageExamplePair, ChatGoogleGenerativeAI, GoogleGenerativeAIChatCallOptions, GoogleGenerativeAIChatInput };
575
+ //# sourceMappingURL=chat_models.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chat_models.d.ts","names":["GenerateContentRequest","SafetySetting","Part","GenerativeAIPart","ModelParams","RequestOptions","CachedContent","Schema","CallbackManagerForLLMRun","AIMessageChunk","BaseMessage","ChatGenerationChunk","ChatResult","BaseChatModel","BaseChatModelCallOptions","LangSmithParams","BaseChatModelParams","ModelProfile","BaseLanguageModelInput","StructuredOutputMethodOptions","Runnable","InteropZodType","GoogleGenerativeAIToolType","BaseMessageExamplePair","GoogleGenerativeAIChatCallOptions","GoogleGenerativeAIChatInput","Pick","ChatGoogleGenerativeAI","Partial","Omit","Promise","AsyncGenerator","_google_generative_ai0","GenerateContentResult","Record","RunOutput"],"sources":["../src/chat_models.d.ts"],"sourcesContent":["import { GenerateContentRequest, SafetySetting, Part as GenerativeAIPart, ModelParams, RequestOptions, type CachedContent, Schema } from \"@google/generative-ai\";\nimport { CallbackManagerForLLMRun } from \"@langchain/core/callbacks/manager\";\nimport { AIMessageChunk, BaseMessage } from \"@langchain/core/messages\";\nimport { ChatGenerationChunk, ChatResult } from \"@langchain/core/outputs\";\nimport { BaseChatModel, type BaseChatModelCallOptions, type LangSmithParams, type BaseChatModelParams } from \"@langchain/core/language_models/chat_models\";\nimport { ModelProfile } from \"@langchain/core/language_models/profile\";\nimport { BaseLanguageModelInput, StructuredOutputMethodOptions } from \"@langchain/core/language_models/base\";\nimport { Runnable } from \"@langchain/core/runnables\";\nimport { InteropZodType } from \"@langchain/core/utils/types\";\nimport { GoogleGenerativeAIToolType } from \"./types.js\";\nexport type BaseMessageExamplePair = {\n input: BaseMessage;\n output: BaseMessage;\n};\nexport interface GoogleGenerativeAIChatCallOptions extends BaseChatModelCallOptions {\n tools?: GoogleGenerativeAIToolType[];\n /**\n * Allowed functions to call when the mode is \"any\".\n * If empty, any one of the provided functions are called.\n */\n allowedFunctionNames?: string[];\n /**\n * Whether or not to include usage data, like token counts\n * in the streamed response chunks.\n * @default true\n */\n streamUsage?: boolean;\n /**\n * JSON schema to be returned by the model.\n */\n responseSchema?: Schema;\n}\n/**\n * An interface defining the input to the ChatGoogleGenerativeAI class.\n */\nexport interface GoogleGenerativeAIChatInput extends BaseChatModelParams, Pick<GoogleGenerativeAIChatCallOptions, \"streamUsage\"> {\n /**\n * Model Name to use\n *\n * Note: The format must follow the pattern - `{model}`\n */\n model: string;\n /**\n * Controls the randomness of the output.\n *\n * Values can range from [0.0,2.0], inclusive. A value closer to 2.0\n * will produce responses that are more varied and creative, while\n * a value closer to 0.0 will typically result in less surprising\n * responses from the model.\n *\n * Note: The default value varies by model\n */\n temperature?: number;\n /**\n * Maximum number of tokens to generate in the completion.\n */\n maxOutputTokens?: number;\n /**\n * Top-p changes how the model selects tokens for output.\n *\n * Tokens are selected from most probable to least until the sum\n * of their probabilities equals the top-p value.\n *\n * For example, if tokens A, B, and C have a probability of\n * .3, .2, and .1 and the top-p value is .5, then the model will\n * select either A or B as the next token (using temperature).\n *\n * Note: The default value varies by model\n */\n topP?: number;\n /**\n * Top-k changes how the model selects tokens for output.\n *\n * A top-k of 1 means the selected token is the most probable among\n * all tokens in the model's vocabulary (also called greedy decoding),\n * while a top-k of 3 means that the next token is selected from\n * among the 3 most probable tokens (using temperature).\n *\n * Note: The default value varies by model\n */\n topK?: number;\n /**\n * The set of character sequences (up to 5) that will stop output generation.\n * If specified, the API will stop at the first appearance of a stop\n * sequence.\n *\n * Note: The stop sequence will not be included as part of the response.\n * Note: stopSequences is only supported for Gemini models\n */\n stopSequences?: string[];\n /**\n * A list of unique `SafetySetting` instances for blocking unsafe content. The API will block\n * any prompts and responses that fail to meet the thresholds set by these settings. If there\n * is no `SafetySetting` for a given `SafetyCategory` provided in the list, the API will use\n * the default safety setting for that category.\n */\n safetySettings?: SafetySetting[];\n /**\n * Google API key to use\n */\n apiKey?: string;\n /**\n * Google API version to use\n */\n apiVersion?: string;\n /**\n * Google API base URL to use\n */\n baseUrl?: string;\n /** Whether to stream the results or not */\n streaming?: boolean;\n /**\n * Whether or not to force the model to respond with JSON.\n * Available for `gemini-1.5` models and later.\n * @default false\n */\n json?: boolean;\n /**\n * Whether or not model supports system instructions.\n * The following models support system instructions:\n * - All Gemini 1.5 Pro model versions\n * - All Gemini 1.5 Flash model versions\n * - Gemini 1.0 Pro version gemini-1.0-pro-002\n */\n convertSystemMessageToHumanContent?: boolean | undefined;\n}\n/**\n * Google Generative AI chat model integration.\n *\n * Setup:\n * Install `@langchain/google-genai` and set an environment variable named `GOOGLE_API_KEY`.\n *\n * ```bash\n * npm install @langchain/google-genai\n * export GOOGLE_API_KEY=\"your-api-key\"\n * ```\n *\n * ## [Constructor args](https://api.js.langchain.com/classes/langchain_google_genai.ChatGoogleGenerativeAI.html#constructor)\n *\n * ## [Runtime args](https://api.js.langchain.com/interfaces/langchain_google_genai.GoogleGenerativeAIChatCallOptions.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 * });\n *\n * // When calling `.bindTools`, call options should be passed via the second argument\n * const llmWithTools = llm.bindTools(\n * [...],\n * {\n * stop: [\"\\n\"],\n * }\n * );\n * ```\n *\n * ## Examples\n *\n * <details open>\n * <summary><strong>Instantiate</strong></summary>\n *\n * ```typescript\n * import { ChatGoogleGenerativeAI } from '@langchain/google-genai';\n *\n * const llm = new ChatGoogleGenerativeAI({\n * model: \"gemini-1.5-flash\",\n * temperature: 0,\n * maxRetries: 2,\n * // apiKey: \"...\",\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 * AIMessage {\n * \"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\",\n * \"response_metadata\": {\n * \"finishReason\": \"STOP\",\n * \"index\": 0,\n * \"safetyRatings\": [\n * {\n * \"category\": \"HARM_CATEGORY_SEXUALLY_EXPLICIT\",\n * \"probability\": \"NEGLIGIBLE\"\n * },\n * {\n * \"category\": \"HARM_CATEGORY_HATE_SPEECH\",\n * \"probability\": \"NEGLIGIBLE\"\n * },\n * {\n * \"category\": \"HARM_CATEGORY_HARASSMENT\",\n * \"probability\": \"NEGLIGIBLE\"\n * },\n * {\n * \"category\": \"HARM_CATEGORY_DANGEROUS_CONTENT\",\n * \"probability\": \"NEGLIGIBLE\"\n * }\n * ]\n * },\n * \"usage_metadata\": {\n * \"input_tokens\": 10,\n * \"output_tokens\": 149,\n * \"total_tokens\": 159\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\": \"There\",\n * \"response_metadata\": {\n * \"index\": 0\n * }\n * \"usage_metadata\": {\n * \"input_tokens\": 10,\n * \"output_tokens\": 1,\n * \"total_tokens\": 11\n * }\n * }\n * AIMessageChunk {\n * \"content\": \" are a few ways to translate \\\"I love programming\\\" into French, depending on\",\n * }\n * AIMessageChunk {\n * \"content\": \" the level of formality and nuance you want to convey:\\n\\n**Formal:**\\n\\n\",\n * }\n * AIMessageChunk {\n * \"content\": \"* **J'aime la programmation.** (This is the most literal and formal translation.)\\n\\n**Informal:**\\n\\n* **J'adore programmer.** (This\",\n * }\n * AIMessageChunk {\n * \"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\",\n * }\n * AIMessageChunk {\n * \"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\",\n * }\n * AIMessageChunk {\n * \"content\": \" your intended audience. \\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\": \"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\",\n * \"usage_metadata\": {\n * \"input_tokens\": 10,\n * \"output_tokens\": 277,\n * \"total_tokens\": 287\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: 'GetWeather',\n * args: { location: 'Los Angeles, CA' },\n * type: 'tool_call'\n * },\n * {\n * name: 'GetWeather',\n * args: { location: 'New York, NY' },\n * type: 'tool_call'\n * },\n * {\n * name: 'GetPopulation',\n * args: { location: 'Los Angeles, CA' },\n * type: 'tool_call'\n * },\n * {\n * name: 'GetPopulation',\n * args: { location: 'New York, NY' },\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 * 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: \"Why don\\\\'t cats play poker?\",\n * punchline: \"Why don\\\\'t cats play poker? Because they always have an ace up their sleeve!\"\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Multimodal</strong></summary>\n *\n * ```typescript\n * import { HumanMessage } from '@langchain/core/messages';\n *\n * const imageUrl = \"https://example.com/image.jpg\";\n * const imageData = await fetch(imageUrl).then(res => res.arrayBuffer());\n * const base64Image = Buffer.from(imageData).toString('base64');\n *\n * const message = new HumanMessage({\n * content: [\n * { type: \"text\", text: \"describe the weather in this image\" },\n * {\n * type: \"image_url\",\n * image_url: { url: `data:image/jpeg;base64,${base64Image}` },\n * },\n * ]\n * });\n *\n * const imageDescriptionAiMsg = await llm.invoke([message]);\n * console.log(imageDescriptionAiMsg.content);\n * ```\n *\n * ```txt\n * 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.\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: 10, output_tokens: 149, total_tokens: 159 }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Response Metadata</strong></summary>\n *\n * ```typescript\n * const aiMsgForResponseMetadata = await llm.invoke(input);\n * console.log(aiMsgForResponseMetadata.response_metadata);\n * ```\n *\n * ```txt\n * {\n * finishReason: 'STOP',\n * index: 0,\n * safetyRatings: [\n * {\n * category: 'HARM_CATEGORY_SEXUALLY_EXPLICIT',\n * probability: 'NEGLIGIBLE'\n * },\n * {\n * category: 'HARM_CATEGORY_HATE_SPEECH',\n * probability: 'NEGLIGIBLE'\n * },\n * { category: 'HARM_CATEGORY_HARASSMENT', probability: 'NEGLIGIBLE' },\n * {\n * category: 'HARM_CATEGORY_DANGEROUS_CONTENT',\n * probability: 'NEGLIGIBLE'\n * }\n * ]\n * }\n * ```\n * </details>\n *\n * <br />\n *\n * <details>\n * <summary><strong>Document Messages</strong></summary>\n *\n * This example will show you how to pass documents such as PDFs to Google\n * Generative AI through messages.\n *\n * ```typescript\n * const pdfPath = \"/Users/my_user/Downloads/invoice.pdf\";\n * const pdfBase64 = await fs.readFile(pdfPath, \"base64\");\n *\n * const response = await llm.invoke([\n * [\"system\", \"Use the provided documents to answer the question\"],\n * [\n * \"user\",\n * [\n * {\n * type: \"application/pdf\", // If the `type` field includes a single slash (`/`), it will be treated as inline data.\n * data: pdfBase64,\n * },\n * {\n * type: \"text\",\n * text: \"Summarize the contents of this PDF\",\n * },\n * ],\n * ],\n * ]);\n *\n * console.log(response.content);\n * ```\n *\n * ```txt\n * This is a billing invoice from Twitter Developers for X API Basic Access. The transaction date is January 7, 2025,\n * 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).\n * 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,\n * expiring in 12/2026. The billing address is Brace Sproul, 1234 Main Street, San Francisco, CA, US 94103. The company being billed is\n * X Corp, located at 865 FM 1209 Building 2, Bastrop, TX, US 78602. Terms and conditions apply.\n * ```\n * </details>\n *\n * <br />\n */\nexport declare class ChatGoogleGenerativeAI extends BaseChatModel<GoogleGenerativeAIChatCallOptions, AIMessageChunk> implements GoogleGenerativeAIChatInput {\n static lc_name(): string;\n lc_serializable: boolean;\n get lc_secrets(): {\n [key: string]: string;\n } | undefined;\n lc_namespace: string[];\n get lc_aliases(): {\n apiKey: string;\n };\n model: string;\n temperature?: number; // default value chosen based on model\n maxOutputTokens?: number;\n topP?: number; // default value chosen based on model\n topK?: number; // default value chosen based on model\n stopSequences: string[];\n safetySettings?: SafetySetting[];\n apiKey?: string;\n streaming: boolean;\n json?: boolean;\n streamUsage: boolean;\n convertSystemMessageToHumanContent: boolean | undefined;\n private client;\n get _isMultimodalModel(): boolean;\n constructor(fields: GoogleGenerativeAIChatInput);\n useCachedContent(cachedContent: CachedContent, modelParams?: ModelParams, requestOptions?: RequestOptions): void;\n get useSystemInstruction(): boolean;\n get computeUseSystemInstruction(): boolean;\n getLsParams(options: this[\"ParsedCallOptions\"]): LangSmithParams;\n _combineLLMOutput(): never[];\n _llmType(): string;\n bindTools(tools: GoogleGenerativeAIToolType[], kwargs?: Partial<GoogleGenerativeAIChatCallOptions>): Runnable<BaseLanguageModelInput, AIMessageChunk, GoogleGenerativeAIChatCallOptions>;\n invocationParams(options?: this[\"ParsedCallOptions\"]): Omit<GenerateContentRequest, \"contents\">;\n _generate(messages: BaseMessage[], options: this[\"ParsedCallOptions\"], runManager?: CallbackManagerForLLMRun): Promise<ChatResult>;\n _streamResponseChunks(messages: BaseMessage[], options: this[\"ParsedCallOptions\"], runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatGenerationChunk>;\n completionWithRetry(request: string | GenerateContentRequest | (string | GenerativeAIPart)[], options?: this[\"ParsedCallOptions\"]): Promise<import(\"@google/generative-ai\").GenerateContentResult>;\n /**\n * Return profiling information for the model.\n *\n * Provides information about the model's capabilities and constraints,\n * including token limits, multimodal support, and advanced features like\n * tool calling and structured output.\n *\n * @returns {ModelProfile} An object describing the model's capabilities and constraints\n *\n * @example\n * ```typescript\n * const model = new ChatGoogleGenerativeAI({ model: \"gemini-1.5-flash\" });\n * const profile = model.profile;\n * console.log(profile.maxInputTokens); // 2000000\n * console.log(profile.imageInputs); // true\n * ```\n */\n get profile(): ModelProfile;\n withStructuredOutput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>, config?: StructuredOutputMethodOptions<false>): Runnable<BaseLanguageModelInput, RunOutput>;\n withStructuredOutput<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput extends Record<string, any> = Record<string, any>>(outputSchema: InteropZodType<RunOutput>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>, config?: StructuredOutputMethodOptions<true>): Runnable<BaseLanguageModelInput, {\n raw: BaseMessage;\n parsed: RunOutput;\n }>;\n}\n"],"mappings":";;;;;;;;;;;;;KAUYuB,sBAAAA;SACDb;UACCA;AAFZ,CAAA;AAAkC,UAIjBc,iCAAAA,SAA0CV,wBAJzB,CAAA;EAAA,KACvBJ,CAAAA,EAICY,0BAJDZ,EAAAA;EAAW;AACC;AAEvB;;EAAkD,oBACtCY,CAAAA,EAAAA,MAAAA,EAAAA;EAA0B;;AAD6C;AAqBnF;;EAA4C,WAAmCE,CAAAA,EAAAA,OAAAA;EAAiC;;;EAAlC,cAAA,CAAA,EALzDjB,MAKyD;AAkd9E;;;;AAgBqBN,UAleJwB,2BAAAA,SAAoCT,mBAkehCf,EAleqDyB,IAkerDzB,CAle0DuB,iCAke1DvB,EAAAA,aAAAA,CAAAA,CAAAA;EAAa;;;;;EAYkC,KAG/CqB,EAAAA,MAAAA;EAA0B;;;;;;;;;;EAEiE,WAAWV,CAAAA,EAAAA,MAAAA;EAAU;;;EACT,eAAkBD,CAAAA,EAAAA,MAAAA;EAAmB;;;;;;;;;;;;EAwB/F,IAAmBO,CAAAA,EAAAA,MAAAA;EAAsB;;;;;;;;;;EAMnF,IACRiB,CAAAA,EAAAA,MAAAA;EAAS;;;AAjEkI;;;;;;;;;;;;mBArZtIlC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAqZA0B,sBAAAA,SAA+Bd,cAAcW,mCAAmCf,2BAA2BgB;;;;;;;;;;;;;;;;mBAgB3GxB;;;;;;;;sBAQGwB;kCACYnB,6BAA6BF,8BAA8BC;;;mDAG1CU;;;mBAGhCO,uCAAuCM,QAAQJ,qCAAqCJ,SAASF,wBAAwBT,gBAAgBe;yDAC/FK,KAAK7B;sBACxCU,gEAAgEF,2BAA2BsB,QAAQlB;kCACvFF,gEAAgEF,2BAA2BuB,eAAepB;wCACpGX,mCAAmCG,+CAA2D2B,QAA3CE,sBAAAA,CAAmFC,qBAAAA;;;;;;;;;;;;;;;;;;iBAkB7JhB;;;oBAGGiB,sBAAsBA,mCAAmCb,eAAec;;IAEvFD,8BAA8Bf,uCAAuCC,SAASF,wBAAwBiB;;;oBAGvFD,sBAAsBA,mCAAmCb,eAAec;;IAEvFD,8BAA8Bf,sCAAsCC,SAASF;SACvER;YACGyB"}