langchain 0.0.147 → 0.0.148

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 (110) hide show
  1. package/chat_models/googlevertexai/web.cjs +1 -0
  2. package/chat_models/googlevertexai/web.d.ts +1 -0
  3. package/chat_models/googlevertexai/web.js +1 -0
  4. package/chat_models/googlevertexai.cjs +1 -1
  5. package/chat_models/googlevertexai.d.ts +1 -1
  6. package/chat_models/googlevertexai.js +1 -1
  7. package/dist/chains/constitutional_ai/constitutional_principle.cjs +272 -1
  8. package/dist/chains/constitutional_ai/constitutional_principle.js +272 -1
  9. package/dist/chat_models/{googlevertexai.cjs → googlevertexai/common.cjs} +14 -26
  10. package/dist/chat_models/{googlevertexai.d.ts → googlevertexai/common.d.ts} +13 -22
  11. package/dist/chat_models/{googlevertexai.js → googlevertexai/common.js} +12 -24
  12. package/dist/chat_models/googlevertexai/index.cjs +36 -0
  13. package/dist/chat_models/googlevertexai/index.d.ts +21 -0
  14. package/dist/chat_models/googlevertexai/index.js +31 -0
  15. package/dist/chat_models/googlevertexai/web.cjs +33 -0
  16. package/dist/chat_models/googlevertexai/web.d.ts +19 -0
  17. package/dist/chat_models/googlevertexai/web.js +28 -0
  18. package/dist/document_loaders/web/notionapi.cjs +93 -70
  19. package/dist/document_loaders/web/notionapi.d.ts +33 -1
  20. package/dist/document_loaders/web/notionapi.js +89 -71
  21. package/dist/embeddings/googlevertexai.cjs +5 -1
  22. package/dist/embeddings/googlevertexai.d.ts +2 -1
  23. package/dist/embeddings/googlevertexai.js +5 -1
  24. package/dist/evaluation/agents/index.cjs +17 -0
  25. package/dist/evaluation/agents/index.d.ts +1 -0
  26. package/dist/evaluation/agents/index.js +1 -0
  27. package/dist/evaluation/agents/prompt.cjs +132 -0
  28. package/dist/evaluation/agents/prompt.d.ts +6 -0
  29. package/dist/evaluation/agents/prompt.js +129 -0
  30. package/dist/evaluation/agents/trajectory.cjs +189 -0
  31. package/dist/evaluation/agents/trajectory.d.ts +54 -0
  32. package/dist/evaluation/agents/trajectory.js +184 -0
  33. package/dist/evaluation/base.cjs +274 -0
  34. package/dist/evaluation/base.d.ts +232 -0
  35. package/dist/evaluation/base.js +263 -0
  36. package/dist/evaluation/comparison/index.cjs +17 -0
  37. package/dist/evaluation/comparison/index.d.ts +1 -0
  38. package/dist/evaluation/comparison/index.js +1 -0
  39. package/dist/evaluation/comparison/pairwise.cjs +244 -0
  40. package/dist/evaluation/comparison/pairwise.d.ts +50 -0
  41. package/dist/evaluation/comparison/pairwise.js +238 -0
  42. package/dist/evaluation/comparison/prompt.cjs +74 -0
  43. package/dist/evaluation/comparison/prompt.d.ts +21 -0
  44. package/dist/evaluation/comparison/prompt.js +71 -0
  45. package/dist/evaluation/criteria/criteria.cjs +259 -0
  46. package/dist/evaluation/criteria/criteria.d.ts +73 -0
  47. package/dist/evaluation/criteria/criteria.js +253 -0
  48. package/dist/evaluation/criteria/index.cjs +17 -0
  49. package/dist/evaluation/criteria/index.d.ts +1 -0
  50. package/dist/evaluation/criteria/index.js +1 -0
  51. package/dist/evaluation/criteria/prompt.cjs +36 -0
  52. package/dist/evaluation/criteria/prompt.d.ts +12 -0
  53. package/dist/evaluation/criteria/prompt.js +33 -0
  54. package/dist/evaluation/embedding_distance/base.cjs +163 -0
  55. package/dist/evaluation/embedding_distance/base.d.ts +78 -0
  56. package/dist/evaluation/embedding_distance/base.js +156 -0
  57. package/dist/evaluation/embedding_distance/index.cjs +17 -0
  58. package/dist/evaluation/embedding_distance/index.d.ts +1 -0
  59. package/dist/evaluation/embedding_distance/index.js +1 -0
  60. package/dist/evaluation/index.cjs +6 -0
  61. package/dist/evaluation/index.d.ts +6 -0
  62. package/dist/evaluation/index.js +6 -0
  63. package/dist/evaluation/loader.cjs +60 -0
  64. package/dist/evaluation/loader.d.ts +27 -0
  65. package/dist/evaluation/loader.js +56 -0
  66. package/dist/evaluation/types.cjs +2 -0
  67. package/dist/evaluation/types.d.ts +35 -0
  68. package/dist/evaluation/types.js +1 -0
  69. package/dist/experimental/multimodal_embeddings/googlevertexai.cjs +5 -1
  70. package/dist/experimental/multimodal_embeddings/googlevertexai.d.ts +2 -1
  71. package/dist/experimental/multimodal_embeddings/googlevertexai.js +5 -1
  72. package/dist/llms/{googlevertexai.js → googlevertexai/common.cjs} +21 -17
  73. package/dist/llms/{googlevertexai.d.ts → googlevertexai/common.d.ts} +13 -23
  74. package/dist/llms/{googlevertexai.cjs → googlevertexai/common.js} +17 -21
  75. package/dist/llms/googlevertexai/index.cjs +34 -0
  76. package/dist/llms/googlevertexai/index.d.ts +26 -0
  77. package/dist/llms/googlevertexai/index.js +30 -0
  78. package/dist/llms/googlevertexai/web.cjs +31 -0
  79. package/dist/llms/googlevertexai/web.d.ts +24 -0
  80. package/dist/llms/googlevertexai/web.js +27 -0
  81. package/dist/load/import_constants.cjs +2 -0
  82. package/dist/load/import_constants.js +2 -0
  83. package/dist/load/import_map.cjs +2 -1
  84. package/dist/load/import_map.d.ts +1 -0
  85. package/dist/load/import_map.js +1 -0
  86. package/dist/load/serializable.cjs +23 -4
  87. package/dist/load/serializable.js +23 -4
  88. package/dist/retrievers/multi_query.cjs +140 -0
  89. package/dist/retrievers/multi_query.d.ts +33 -0
  90. package/dist/retrievers/multi_query.js +136 -0
  91. package/dist/types/googlevertexai-types.d.ts +11 -4
  92. package/dist/util/googlevertexai-connection.cjs +14 -15
  93. package/dist/util/googlevertexai-connection.d.ts +7 -7
  94. package/dist/util/googlevertexai-connection.js +14 -15
  95. package/dist/util/googlevertexai-webauth.cjs +56 -0
  96. package/dist/util/googlevertexai-webauth.d.ts +25 -0
  97. package/dist/util/googlevertexai-webauth.js +52 -0
  98. package/dist/vectorstores/googlevertexai.cjs +9 -8
  99. package/dist/vectorstores/googlevertexai.d.ts +8 -7
  100. package/dist/vectorstores/googlevertexai.js +9 -8
  101. package/llms/googlevertexai/web.cjs +1 -0
  102. package/llms/googlevertexai/web.d.ts +1 -0
  103. package/llms/googlevertexai/web.js +1 -0
  104. package/llms/googlevertexai.cjs +1 -1
  105. package/llms/googlevertexai.d.ts +1 -1
  106. package/llms/googlevertexai.js +1 -1
  107. package/package.json +32 -3
  108. package/retrievers/multi_query.cjs +1 -0
  109. package/retrievers/multi_query.d.ts +1 -0
  110. package/retrievers/multi_query.js +1 -0
@@ -0,0 +1,56 @@
1
+ import { CriteriaEvalChain, LabeledCriteriaEvalChain, } from "./criteria/index.js";
2
+ import { ChatOpenAI } from "../chat_models/openai.js";
3
+ import { LabeledPairwiseStringEvalChain, PairwiseStringEvalChain, } from "./comparison/index.js";
4
+ import { EmbeddingDistanceEvalChain, PairwiseEmbeddingDistanceEvalChain, } from "./embedding_distance/index.js";
5
+ import { TrajectoryEvalChain } from "./agents/index.js";
6
+ import { BaseChatModel } from "../chat_models/base.js";
7
+ /**
8
+ * Load the requested evaluation chain specified by a string
9
+ * @param type The type of evaluator to load.
10
+ * @param options
11
+ * - llm The language model to use for the evaluator.
12
+ * - criteria The criteria to use for the evaluator.
13
+ * - agentTools A list of tools available to the agent,for TrajectoryEvalChain.
14
+ */
15
+ export async function loadEvaluator(type, options) {
16
+ const { llm, chainOptions, criteria, agentTools } = options || {};
17
+ const llm_ = llm ??
18
+ new ChatOpenAI({
19
+ modelName: "gpt-4",
20
+ temperature: 0.0,
21
+ });
22
+ let evaluator;
23
+ switch (type) {
24
+ case "criteria":
25
+ evaluator = await CriteriaEvalChain.fromLLM(llm_, criteria, chainOptions);
26
+ break;
27
+ case "labeled_criteria":
28
+ evaluator = await LabeledCriteriaEvalChain.fromLLM(llm_, criteria, chainOptions);
29
+ break;
30
+ case "pairwise_string":
31
+ evaluator = await PairwiseStringEvalChain.fromLLM(llm_, criteria, chainOptions);
32
+ break;
33
+ case "labeled_pairwise_string":
34
+ evaluator = await LabeledPairwiseStringEvalChain.fromLLM(llm_, criteria, chainOptions);
35
+ break;
36
+ case "trajectory":
37
+ // eslint-disable-next-line no-instanceof/no-instanceof
38
+ if (!(llm_ instanceof BaseChatModel)) {
39
+ throw new Error("LLM must be an instance of a base chat model.");
40
+ }
41
+ evaluator = await TrajectoryEvalChain.fromLLM(llm_, agentTools, chainOptions);
42
+ break;
43
+ case "embedding_distance":
44
+ evaluator = new EmbeddingDistanceEvalChain({
45
+ embedding: options?.embedding,
46
+ distanceMetric: options?.distanceMetric,
47
+ });
48
+ break;
49
+ case "pairwise_embedding_distance":
50
+ evaluator = new PairwiseEmbeddingDistanceEvalChain({});
51
+ break;
52
+ default:
53
+ throw new Error(`Unknown type: ${type}`);
54
+ }
55
+ return evaluator;
56
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,35 @@
1
+ import { AgentTrajectoryEvaluator, LLMPairwiseStringEvaluator, LLMStringEvaluator, PairwiseStringEvaluator, StringEvaluator } from "./base.js";
2
+ export interface EvaluatorType {
3
+ /**
4
+ * The criteria evaluator, which evaluates a model based on a
5
+ * custom set of criteria without any reference labels.
6
+ * */
7
+ criteria: LLMStringEvaluator;
8
+ /**
9
+ * The labeled criteria evaluator, which evaluates a model based on a
10
+ * custom set of criteria, with a reference label.
11
+ * */
12
+ labeled_criteria: LLMStringEvaluator;
13
+ /**
14
+ * The pairwise string evaluator, which predicts the preferred prediction from
15
+ * between two models.
16
+ */
17
+ pairwise_string: LLMPairwiseStringEvaluator;
18
+ /**
19
+ * The labeled pairwise string evaluator, which predicts the preferred prediction
20
+ * from between two models based on a ground truth reference label.
21
+ * */
22
+ labeled_pairwise_string: LLMPairwiseStringEvaluator;
23
+ /**
24
+ * The agent trajectory evaluator, which grades the agent's intermediate steps.
25
+ */
26
+ trajectory: AgentTrajectoryEvaluator;
27
+ /**
28
+ * Compare a prediction to a reference label using embedding distance.
29
+ * */
30
+ embedding_distance: StringEvaluator;
31
+ /**
32
+ * Compare two predictions using embedding distance.
33
+ * */
34
+ pairwise_embedding_distance: PairwiseStringEvaluator;
35
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GoogleVertexAIMultimodalEmbeddings = void 0;
4
+ const google_auth_library_1 = require("google-auth-library");
4
5
  const base_js_1 = require("../../embeddings/base.cjs");
5
6
  const googlevertexai_connection_js_1 = require("../../util/googlevertexai-connection.cjs");
6
7
  /**
@@ -24,7 +25,10 @@ class GoogleVertexAIMultimodalEmbeddings extends base_js_1.Embeddings {
24
25
  value: void 0
25
26
  });
26
27
  this.model = fields?.model ?? this.model;
27
- this.connection = new googlevertexai_connection_js_1.GoogleVertexAILLMConnection({ ...fields, ...this }, this.caller);
28
+ this.connection = new googlevertexai_connection_js_1.GoogleVertexAILLMConnection({ ...fields, ...this }, this.caller, new google_auth_library_1.GoogleAuth({
29
+ scopes: "https://www.googleapis.com/auth/cloud-platform",
30
+ ...fields?.authOptions,
31
+ }));
28
32
  }
29
33
  /**
30
34
  * Converts media (text or image) to an instance that can be used for
@@ -1,11 +1,12 @@
1
1
  /// <reference types="node" resolution-mode="require"/>
2
+ import { GoogleAuthOptions } from "google-auth-library";
2
3
  import { Embeddings, EmbeddingsParams } from "../../embeddings/base.js";
3
4
  import { GoogleVertexAIBaseLLMInput, GoogleVertexAIBasePrediction, GoogleVertexAILLMResponse } from "../../types/googlevertexai-types.js";
4
5
  /**
5
6
  * Parameters for the GoogleVertexAIMultimodalEmbeddings class, extending
6
7
  * both EmbeddingsParams and GoogleVertexAIConnectionParams.
7
8
  */
8
- export interface GoogleVertexAIMultimodalEmbeddingsParams extends EmbeddingsParams, GoogleVertexAIBaseLLMInput {
9
+ export interface GoogleVertexAIMultimodalEmbeddingsParams extends EmbeddingsParams, GoogleVertexAIBaseLLMInput<GoogleAuthOptions> {
9
10
  }
10
11
  /**
11
12
  * An instance of media (text or image) that can be used for generating
@@ -1,3 +1,4 @@
1
+ import { GoogleAuth } from "google-auth-library";
1
2
  import { Embeddings } from "../../embeddings/base.js";
2
3
  import { GoogleVertexAILLMConnection } from "../../util/googlevertexai-connection.js";
3
4
  /**
@@ -21,7 +22,10 @@ export class GoogleVertexAIMultimodalEmbeddings extends Embeddings {
21
22
  value: void 0
22
23
  });
23
24
  this.model = fields?.model ?? this.model;
24
- this.connection = new GoogleVertexAILLMConnection({ ...fields, ...this }, this.caller);
25
+ this.connection = new GoogleVertexAILLMConnection({ ...fields, ...this }, this.caller, new GoogleAuth({
26
+ scopes: "https://www.googleapis.com/auth/cloud-platform",
27
+ ...fields?.authOptions,
28
+ }));
25
29
  }
26
30
  /**
27
31
  * Converts media (text or image) to an instance that can be used for
@@ -1,22 +1,26 @@
1
- import { BaseLLM } from "./base.js";
2
- import { GoogleVertexAILLMConnection } from "../util/googlevertexai-connection.js";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseGoogleVertexAI = void 0;
4
+ const base_js_1 = require("../base.cjs");
3
5
  /**
4
- * Enables calls to the Google Cloud's Vertex AI API to access
5
- * Large Language Models.
6
- *
7
- * To use, you will need to have one of the following authentication
8
- * methods in place:
9
- * - You are logged into an account permitted to the Google Cloud project
10
- * using Vertex AI.
11
- * - You are running this on a machine using a service account permitted to
12
- * the Google Cloud project using Vertex AI.
13
- * - The `GOOGLE_APPLICATION_CREDENTIALS` environment variable is set to the
14
- * path of a credentials file for a service account permitted to the
15
- * Google Cloud project using Vertex AI.
6
+ * Base class for Google Vertex AI LLMs.
7
+ * Implemented subclasses must provide a GoogleVertexAILLMConnection
8
+ * with an appropriate auth client.
16
9
  */
17
- export class GoogleVertexAI extends BaseLLM {
10
+ class BaseGoogleVertexAI extends base_js_1.BaseLLM {
11
+ get lc_aliases() {
12
+ return {
13
+ model: "model_name",
14
+ };
15
+ }
18
16
  constructor(fields) {
19
17
  super(fields ?? {});
18
+ Object.defineProperty(this, "lc_serializable", {
19
+ enumerable: true,
20
+ configurable: true,
21
+ writable: true,
22
+ value: true
23
+ });
20
24
  Object.defineProperty(this, "model", {
21
25
  enumerable: true,
22
26
  configurable: true,
@@ -65,10 +69,9 @@ export class GoogleVertexAI extends BaseLLM {
65
69
  this.maxOutputTokens = fields?.maxOutputTokens ?? this.maxOutputTokens;
66
70
  this.topP = fields?.topP ?? this.topP;
67
71
  this.topK = fields?.topK ?? this.topK;
68
- this.connection = new GoogleVertexAILLMConnection({ ...fields, ...this }, this.caller);
69
72
  }
70
73
  _llmType() {
71
- return "googlevertexai";
74
+ return "vertexai";
72
75
  }
73
76
  async _generate(prompts, options) {
74
77
  const generations = await Promise.all(prompts.map((prompt) => this._generatePrompt(prompt, options)));
@@ -129,3 +132,4 @@ export class GoogleVertexAI extends BaseLLM {
129
132
  return result?.data?.predictions[0];
130
133
  }
131
134
  }
135
+ exports.BaseGoogleVertexAI = BaseGoogleVertexAI;
@@ -1,11 +1,8 @@
1
- import { BaseLLM } from "./base.js";
2
- import { Generation, LLMResult } from "../schema/index.js";
3
- import { GoogleVertexAIBaseLLMInput, GoogleVertexAIBasePrediction, GoogleVertexAILLMResponse } from "../types/googlevertexai-types.js";
4
- /**
5
- * Interface representing the input to the Google Vertex AI model.
6
- */
7
- export interface GoogleVertexAITextInput extends GoogleVertexAIBaseLLMInput {
8
- }
1
+ import { BaseLLM } from "../base.js";
2
+ import { Generation, LLMResult } from "../../schema/index.js";
3
+ import { GoogleVertexAILLMConnection } from "../../util/googlevertexai-connection.js";
4
+ import { GoogleVertexAIBaseLLMInput, GoogleVertexAIBasePrediction, GoogleVertexAILLMResponse } from "../../types/googlevertexai-types.js";
5
+ import { BaseLanguageModelCallOptions } from "../../base_language/index.js";
9
6
  /**
10
7
  * Interface representing the instance of text input to the Google Vertex
11
8
  * AI model.
@@ -32,27 +29,20 @@ interface TextPrediction extends GoogleVertexAIBasePrediction {
32
29
  content: string;
33
30
  }
34
31
  /**
35
- * Enables calls to the Google Cloud's Vertex AI API to access
36
- * Large Language Models.
37
- *
38
- * To use, you will need to have one of the following authentication
39
- * methods in place:
40
- * - You are logged into an account permitted to the Google Cloud project
41
- * using Vertex AI.
42
- * - You are running this on a machine using a service account permitted to
43
- * the Google Cloud project using Vertex AI.
44
- * - The `GOOGLE_APPLICATION_CREDENTIALS` environment variable is set to the
45
- * path of a credentials file for a service account permitted to the
46
- * Google Cloud project using Vertex AI.
32
+ * Base class for Google Vertex AI LLMs.
33
+ * Implemented subclasses must provide a GoogleVertexAILLMConnection
34
+ * with an appropriate auth client.
47
35
  */
48
- export declare class GoogleVertexAI extends BaseLLM implements GoogleVertexAITextInput {
36
+ export declare class BaseGoogleVertexAI<AuthOptions> extends BaseLLM implements GoogleVertexAIBaseLLMInput<AuthOptions> {
37
+ lc_serializable: boolean;
49
38
  model: string;
50
39
  temperature: number;
51
40
  maxOutputTokens: number;
52
41
  topP: number;
53
42
  topK: number;
54
- private connection;
55
- constructor(fields?: GoogleVertexAITextInput);
43
+ protected connection: GoogleVertexAILLMConnection<BaseLanguageModelCallOptions, GoogleVertexAILLMInstance, TextPrediction, AuthOptions>;
44
+ get lc_aliases(): Record<string, string>;
45
+ constructor(fields?: GoogleVertexAIBaseLLMInput<AuthOptions>);
56
46
  _llmType(): string;
57
47
  _generate(prompts: string[], options: this["ParsedCallOptions"]): Promise<LLMResult>;
58
48
  _generatePrompt(prompt: string, options: this["ParsedCallOptions"]): Promise<Generation[]>;
@@ -1,25 +1,23 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GoogleVertexAI = void 0;
4
- const base_js_1 = require("./base.cjs");
5
- const googlevertexai_connection_js_1 = require("../util/googlevertexai-connection.cjs");
1
+ import { BaseLLM } from "../base.js";
6
2
  /**
7
- * Enables calls to the Google Cloud's Vertex AI API to access
8
- * Large Language Models.
9
- *
10
- * To use, you will need to have one of the following authentication
11
- * methods in place:
12
- * - You are logged into an account permitted to the Google Cloud project
13
- * using Vertex AI.
14
- * - You are running this on a machine using a service account permitted to
15
- * the Google Cloud project using Vertex AI.
16
- * - The `GOOGLE_APPLICATION_CREDENTIALS` environment variable is set to the
17
- * path of a credentials file for a service account permitted to the
18
- * Google Cloud project using Vertex AI.
3
+ * Base class for Google Vertex AI LLMs.
4
+ * Implemented subclasses must provide a GoogleVertexAILLMConnection
5
+ * with an appropriate auth client.
19
6
  */
20
- class GoogleVertexAI extends base_js_1.BaseLLM {
7
+ export class BaseGoogleVertexAI extends BaseLLM {
8
+ get lc_aliases() {
9
+ return {
10
+ model: "model_name",
11
+ };
12
+ }
21
13
  constructor(fields) {
22
14
  super(fields ?? {});
15
+ Object.defineProperty(this, "lc_serializable", {
16
+ enumerable: true,
17
+ configurable: true,
18
+ writable: true,
19
+ value: true
20
+ });
23
21
  Object.defineProperty(this, "model", {
24
22
  enumerable: true,
25
23
  configurable: true,
@@ -68,10 +66,9 @@ class GoogleVertexAI extends base_js_1.BaseLLM {
68
66
  this.maxOutputTokens = fields?.maxOutputTokens ?? this.maxOutputTokens;
69
67
  this.topP = fields?.topP ?? this.topP;
70
68
  this.topK = fields?.topK ?? this.topK;
71
- this.connection = new googlevertexai_connection_js_1.GoogleVertexAILLMConnection({ ...fields, ...this }, this.caller);
72
69
  }
73
70
  _llmType() {
74
- return "googlevertexai";
71
+ return "vertexai";
75
72
  }
76
73
  async _generate(prompts, options) {
77
74
  const generations = await Promise.all(prompts.map((prompt) => this._generatePrompt(prompt, options)));
@@ -132,4 +129,3 @@ class GoogleVertexAI extends base_js_1.BaseLLM {
132
129
  return result?.data?.predictions[0];
133
130
  }
134
131
  }
135
- exports.GoogleVertexAI = GoogleVertexAI;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GoogleVertexAI = void 0;
4
+ const google_auth_library_1 = require("google-auth-library");
5
+ const googlevertexai_connection_js_1 = require("../../util/googlevertexai-connection.cjs");
6
+ const common_js_1 = require("./common.cjs");
7
+ /**
8
+ * Enables calls to the Google Cloud's Vertex AI API to access
9
+ * Large Language Models.
10
+ *
11
+ * To use, you will need to have one of the following authentication
12
+ * methods in place:
13
+ * - You are logged into an account permitted to the Google Cloud project
14
+ * using Vertex AI.
15
+ * - You are running this on a machine using a service account permitted to
16
+ * the Google Cloud project using Vertex AI.
17
+ * - The `GOOGLE_APPLICATION_CREDENTIALS` environment variable is set to the
18
+ * path of a credentials file for a service account permitted to the
19
+ * Google Cloud project using Vertex AI.
20
+ */
21
+ class GoogleVertexAI extends common_js_1.BaseGoogleVertexAI {
22
+ static lc_name() {
23
+ return "VertexAI";
24
+ }
25
+ constructor(fields) {
26
+ super(fields);
27
+ const client = new google_auth_library_1.GoogleAuth({
28
+ scopes: "https://www.googleapis.com/auth/cloud-platform",
29
+ ...fields?.authOptions,
30
+ });
31
+ this.connection = new googlevertexai_connection_js_1.GoogleVertexAILLMConnection({ ...fields, ...this }, this.caller, client);
32
+ }
33
+ }
34
+ exports.GoogleVertexAI = GoogleVertexAI;
@@ -0,0 +1,26 @@
1
+ import { GoogleAuthOptions } from "google-auth-library";
2
+ import { GoogleVertexAIBaseLLMInput } from "../../types/googlevertexai-types.js";
3
+ import { BaseGoogleVertexAI } from "./common.js";
4
+ /**
5
+ * Interface representing the input to the Google Vertex AI model.
6
+ */
7
+ export interface GoogleVertexAITextInput extends GoogleVertexAIBaseLLMInput<GoogleAuthOptions> {
8
+ }
9
+ /**
10
+ * Enables calls to the Google Cloud's Vertex AI API to access
11
+ * Large Language Models.
12
+ *
13
+ * To use, you will need to have one of the following authentication
14
+ * methods in place:
15
+ * - You are logged into an account permitted to the Google Cloud project
16
+ * using Vertex AI.
17
+ * - You are running this on a machine using a service account permitted to
18
+ * the Google Cloud project using Vertex AI.
19
+ * - The `GOOGLE_APPLICATION_CREDENTIALS` environment variable is set to the
20
+ * path of a credentials file for a service account permitted to the
21
+ * Google Cloud project using Vertex AI.
22
+ */
23
+ export declare class GoogleVertexAI extends BaseGoogleVertexAI<GoogleAuthOptions> {
24
+ static lc_name(): string;
25
+ constructor(fields?: GoogleVertexAITextInput);
26
+ }
@@ -0,0 +1,30 @@
1
+ import { GoogleAuth } from "google-auth-library";
2
+ import { GoogleVertexAILLMConnection } from "../../util/googlevertexai-connection.js";
3
+ import { BaseGoogleVertexAI } from "./common.js";
4
+ /**
5
+ * Enables calls to the Google Cloud's Vertex AI API to access
6
+ * Large Language Models.
7
+ *
8
+ * To use, you will need to have one of the following authentication
9
+ * methods in place:
10
+ * - You are logged into an account permitted to the Google Cloud project
11
+ * using Vertex AI.
12
+ * - You are running this on a machine using a service account permitted to
13
+ * the Google Cloud project using Vertex AI.
14
+ * - The `GOOGLE_APPLICATION_CREDENTIALS` environment variable is set to the
15
+ * path of a credentials file for a service account permitted to the
16
+ * Google Cloud project using Vertex AI.
17
+ */
18
+ export class GoogleVertexAI extends BaseGoogleVertexAI {
19
+ static lc_name() {
20
+ return "VertexAI";
21
+ }
22
+ constructor(fields) {
23
+ super(fields);
24
+ const client = new GoogleAuth({
25
+ scopes: "https://www.googleapis.com/auth/cloud-platform",
26
+ ...fields?.authOptions,
27
+ });
28
+ this.connection = new GoogleVertexAILLMConnection({ ...fields, ...this }, this.caller, client);
29
+ }
30
+ }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GoogleVertexAI = void 0;
4
+ const googlevertexai_webauth_js_1 = require("../../util/googlevertexai-webauth.cjs");
5
+ const googlevertexai_connection_js_1 = require("../../util/googlevertexai-connection.cjs");
6
+ const common_js_1 = require("./common.cjs");
7
+ /**
8
+ * Enables calls to the Google Cloud's Vertex AI API to access
9
+ * Large Language Models.
10
+ *
11
+ * This entrypoint and class are intended to be used in web environments like Edge
12
+ * functions where you do not have access to the file system. It supports passing
13
+ * service account credentials directly as a "GOOGLE_VERTEX_AI_WEB_CREDENTIALS"
14
+ * environment variable or directly as "authOptions.credentials".
15
+ */
16
+ class GoogleVertexAI extends common_js_1.BaseGoogleVertexAI {
17
+ static lc_name() {
18
+ return "VertexAI";
19
+ }
20
+ get lc_secrets() {
21
+ return {
22
+ "authOptions.credentials": "GOOGLE_VERTEX_AI_WEB_CREDENTIALS",
23
+ };
24
+ }
25
+ constructor(fields) {
26
+ super(fields);
27
+ const client = new googlevertexai_webauth_js_1.WebGoogleAuth(fields?.authOptions);
28
+ this.connection = new googlevertexai_connection_js_1.GoogleVertexAILLMConnection({ ...fields, ...this }, this.caller, client);
29
+ }
30
+ }
31
+ exports.GoogleVertexAI = GoogleVertexAI;
@@ -0,0 +1,24 @@
1
+ import { WebGoogleAuthOptions } from "../../util/googlevertexai-webauth.js";
2
+ import { GoogleVertexAIBaseLLMInput } from "../../types/googlevertexai-types.js";
3
+ import { BaseGoogleVertexAI } from "./common.js";
4
+ /**
5
+ * Interface representing the input to the Google Vertex AI model.
6
+ */
7
+ export interface GoogleVertexAITextInput extends GoogleVertexAIBaseLLMInput<WebGoogleAuthOptions> {
8
+ }
9
+ /**
10
+ * Enables calls to the Google Cloud's Vertex AI API to access
11
+ * Large Language Models.
12
+ *
13
+ * This entrypoint and class are intended to be used in web environments like Edge
14
+ * functions where you do not have access to the file system. It supports passing
15
+ * service account credentials directly as a "GOOGLE_VERTEX_AI_WEB_CREDENTIALS"
16
+ * environment variable or directly as "authOptions.credentials".
17
+ */
18
+ export declare class GoogleVertexAI extends BaseGoogleVertexAI<WebGoogleAuthOptions> {
19
+ static lc_name(): string;
20
+ get lc_secrets(): {
21
+ [key: string]: string;
22
+ };
23
+ constructor(fields?: GoogleVertexAITextInput);
24
+ }
@@ -0,0 +1,27 @@
1
+ import { WebGoogleAuth, } from "../../util/googlevertexai-webauth.js";
2
+ import { GoogleVertexAILLMConnection } from "../../util/googlevertexai-connection.js";
3
+ import { BaseGoogleVertexAI } from "./common.js";
4
+ /**
5
+ * Enables calls to the Google Cloud's Vertex AI API to access
6
+ * Large Language Models.
7
+ *
8
+ * This entrypoint and class are intended to be used in web environments like Edge
9
+ * functions where you do not have access to the file system. It supports passing
10
+ * service account credentials directly as a "GOOGLE_VERTEX_AI_WEB_CREDENTIALS"
11
+ * environment variable or directly as "authOptions.credentials".
12
+ */
13
+ export class GoogleVertexAI extends BaseGoogleVertexAI {
14
+ static lc_name() {
15
+ return "VertexAI";
16
+ }
17
+ get lc_secrets() {
18
+ return {
19
+ "authOptions.credentials": "GOOGLE_VERTEX_AI_WEB_CREDENTIALS",
20
+ };
21
+ }
22
+ constructor(fields) {
23
+ super(fields);
24
+ const client = new WebGoogleAuth(fields?.authOptions);
25
+ this.connection = new GoogleVertexAILLMConnection({ ...fields, ...this }, this.caller, client);
26
+ }
27
+ }
@@ -27,6 +27,7 @@ exports.optionalImportEntrypoints = [
27
27
  "langchain/llms/raycast",
28
28
  "langchain/llms/replicate",
29
29
  "langchain/llms/googlevertexai",
30
+ "langchain/llms/googlevertexai/web",
30
31
  "langchain/llms/googlepalm",
31
32
  "langchain/llms/sagemaker_endpoint",
32
33
  "langchain/llms/bedrock",
@@ -93,6 +94,7 @@ exports.optionalImportEntrypoints = [
93
94
  "langchain/document_transformers/html_to_text",
94
95
  "langchain/document_transformers/mozilla_readability",
95
96
  "langchain/chat_models/googlevertexai",
97
+ "langchain/chat_models/googlevertexai/web",
96
98
  "langchain/chat_models/googlepalm",
97
99
  "langchain/sql_db",
98
100
  "langchain/callbacks/handlers/llmonitor",
@@ -24,6 +24,7 @@ export const optionalImportEntrypoints = [
24
24
  "langchain/llms/raycast",
25
25
  "langchain/llms/replicate",
26
26
  "langchain/llms/googlevertexai",
27
+ "langchain/llms/googlevertexai/web",
27
28
  "langchain/llms/googlepalm",
28
29
  "langchain/llms/sagemaker_endpoint",
29
30
  "langchain/llms/bedrock",
@@ -90,6 +91,7 @@ export const optionalImportEntrypoints = [
90
91
  "langchain/document_transformers/html_to_text",
91
92
  "langchain/document_transformers/mozilla_readability",
92
93
  "langchain/chat_models/googlevertexai",
94
+ "langchain/chat_models/googlevertexai/web",
93
95
  "langchain/chat_models/googlepalm",
94
96
  "langchain/sql_db",
95
97
  "langchain/callbacks/handlers/llmonitor",
@@ -25,7 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  };
26
26
  Object.defineProperty(exports, "__esModule", { value: true });
27
27
  exports.retrievers__document_compressors = exports.retrievers__contextual_compression = exports.retrievers__databerry = exports.retrievers__remote = exports.output_parsers = exports.callbacks = exports.schema__storage = exports.schema__runnable = exports.schema__retriever = exports.schema__query_constructor = exports.schema__output_parser = exports.schema__document = exports.schema = exports.chat_models__minimax = exports.chat_models__ollama = exports.chat_models__baiduwenxin = exports.chat_models__anthropic = exports.chat_models__openai = exports.chat_models__base = exports.document_transformers__openai_functions = exports.document_loaders__web__sort_xyz_blockchain = exports.document_loaders__web__serpapi = exports.document_loaders__base = exports.document = exports.memory = exports.text_splitter = exports.vectorstores__xata = exports.vectorstores__vectara = exports.vectorstores__prisma = exports.vectorstores__memory = exports.vectorstores__base = exports.prompts = exports.llms__ollama = exports.llms__aleph_alpha = exports.llms__ai21 = exports.llms__openai = exports.llms__base = exports.embeddings__minimax = exports.embeddings__openai = exports.embeddings__ollama = exports.embeddings__fake = exports.embeddings__cache_backed = exports.embeddings__base = exports.chains__openai_functions = exports.chains = exports.tools = exports.base_language = exports.agents__toolkits = exports.agents = exports.load__serializable = void 0;
28
- exports.evaluation = exports.experimental__plan_and_execute = exports.experimental__generative_agents = exports.experimental__babyagi = exports.experimental__autogpt = exports.util__math = exports.storage__in_memory = exports.stores__message__in_memory = exports.stores__file__in_memory = exports.stores__doc__in_memory = exports.cache = exports.retrievers__vespa = exports.retrievers__score_threshold = exports.retrievers__hyde = exports.retrievers__document_compressors__chain_extract = exports.retrievers__time_weighted = exports.retrievers__parent_document = exports.retrievers__multi_vector = void 0;
28
+ exports.evaluation = exports.experimental__plan_and_execute = exports.experimental__generative_agents = exports.experimental__babyagi = exports.experimental__autogpt = exports.util__math = exports.storage__in_memory = exports.stores__message__in_memory = exports.stores__file__in_memory = exports.stores__doc__in_memory = exports.cache = exports.retrievers__vespa = exports.retrievers__score_threshold = exports.retrievers__hyde = exports.retrievers__document_compressors__chain_extract = exports.retrievers__time_weighted = exports.retrievers__parent_document = exports.retrievers__multi_vector = exports.retrievers__multi_query = void 0;
29
29
  exports.load__serializable = __importStar(require("../load/serializable.cjs"));
30
30
  exports.agents = __importStar(require("../agents/index.cjs"));
31
31
  exports.agents__toolkits = __importStar(require("../agents/toolkits/index.cjs"));
@@ -76,6 +76,7 @@ exports.retrievers__remote = __importStar(require("../retrievers/remote/index.cj
76
76
  exports.retrievers__databerry = __importStar(require("../retrievers/databerry.cjs"));
77
77
  exports.retrievers__contextual_compression = __importStar(require("../retrievers/contextual_compression.cjs"));
78
78
  exports.retrievers__document_compressors = __importStar(require("../retrievers/document_compressors/index.cjs"));
79
+ exports.retrievers__multi_query = __importStar(require("../retrievers/multi_query.cjs"));
79
80
  exports.retrievers__multi_vector = __importStar(require("../retrievers/multi_vector.cjs"));
80
81
  exports.retrievers__parent_document = __importStar(require("../retrievers/parent_document.cjs"));
81
82
  exports.retrievers__time_weighted = __importStar(require("../retrievers/time_weighted.cjs"));
@@ -48,6 +48,7 @@ export * as retrievers__remote from "../retrievers/remote/index.js";
48
48
  export * as retrievers__databerry from "../retrievers/databerry.js";
49
49
  export * as retrievers__contextual_compression from "../retrievers/contextual_compression.js";
50
50
  export * as retrievers__document_compressors from "../retrievers/document_compressors/index.js";
51
+ export * as retrievers__multi_query from "../retrievers/multi_query.js";
51
52
  export * as retrievers__multi_vector from "../retrievers/multi_vector.js";
52
53
  export * as retrievers__parent_document from "../retrievers/parent_document.js";
53
54
  export * as retrievers__time_weighted from "../retrievers/time_weighted.js";
@@ -49,6 +49,7 @@ export * as retrievers__remote from "../retrievers/remote/index.js";
49
49
  export * as retrievers__databerry from "../retrievers/databerry.js";
50
50
  export * as retrievers__contextual_compression from "../retrievers/contextual_compression.js";
51
51
  export * as retrievers__document_compressors from "../retrievers/document_compressors/index.js";
52
+ export * as retrievers__multi_query from "../retrievers/multi_query.js";
52
53
  export * as retrievers__multi_vector from "../retrievers/multi_vector.js";
53
54
  export * as retrievers__parent_document from "../retrievers/parent_document.js";
54
55
  export * as retrievers__time_weighted from "../retrievers/time_weighted.js";
@@ -138,11 +138,30 @@ class Serializable {
138
138
  }
139
139
  // include all secrets used, even if not in kwargs,
140
140
  // will be replaced with sentinel value in replaceSecrets
141
- for (const key in secrets) {
142
- if (key in this && this[key] !== undefined) {
143
- kwargs[key] = this[key] || kwargs[key];
141
+ Object.keys(secrets).forEach((keyPath) => {
142
+ // eslint-disable-next-line @typescript-eslint/no-this-alias, @typescript-eslint/no-explicit-any
143
+ let read = this;
144
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
145
+ let write = kwargs;
146
+ const [last, ...partsReverse] = keyPath.split(".").reverse();
147
+ for (const key of partsReverse.reverse()) {
148
+ if (!(key in read) || read[key] === undefined)
149
+ return;
150
+ if (!(key in write) || write[key] === undefined) {
151
+ if (typeof read[key] === "object" && read[key] != null) {
152
+ write[key] = {};
153
+ }
154
+ else if (Array.isArray(read[key])) {
155
+ write[key] = [];
156
+ }
157
+ }
158
+ read = read[key];
159
+ write = write[key];
144
160
  }
145
- }
161
+ if (last in read && read[last] !== undefined) {
162
+ write[last] = write[last] || read[last];
163
+ }
164
+ });
146
165
  return {
147
166
  lc: 1,
148
167
  type: "constructor",