langchain 0.0.209 → 0.0.210

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 (114) hide show
  1. package/dist/agents/agent.d.ts +8 -8
  2. package/dist/agents/chat/index.cjs +1 -1
  3. package/dist/agents/chat/index.d.ts +7 -7
  4. package/dist/agents/chat/index.js +1 -1
  5. package/dist/agents/chat_convo/index.d.ts +6 -6
  6. package/dist/agents/chat_convo/outputParser.cjs +3 -3
  7. package/dist/agents/chat_convo/outputParser.d.ts +5 -5
  8. package/dist/agents/chat_convo/outputParser.js +3 -3
  9. package/dist/agents/executor.cjs +6 -6
  10. package/dist/agents/executor.d.ts +5 -5
  11. package/dist/agents/executor.js +1 -1
  12. package/dist/agents/helpers.d.ts +3 -3
  13. package/dist/agents/initialize.d.ts +5 -5
  14. package/dist/agents/load.d.ts +4 -4
  15. package/dist/agents/mrkl/index.d.ts +8 -8
  16. package/dist/agents/openai/index.d.ts +6 -6
  17. package/dist/agents/structured_chat/index.d.ts +6 -6
  18. package/dist/agents/structured_chat/outputParser.d.ts +2 -2
  19. package/dist/agents/toolkits/aws_sfn.d.ts +2 -2
  20. package/dist/agents/toolkits/conversational_retrieval/openai_functions.d.ts +2 -2
  21. package/dist/agents/toolkits/conversational_retrieval/tool.d.ts +2 -2
  22. package/dist/agents/toolkits/json/json.d.ts +4 -4
  23. package/dist/agents/toolkits/openapi/openapi.d.ts +5 -5
  24. package/dist/agents/toolkits/sql/sql.d.ts +5 -5
  25. package/dist/agents/toolkits/vectorstore/vectorstore.d.ts +12 -12
  26. package/dist/agents/toolkits/zapier/zapier.d.ts +2 -2
  27. package/dist/agents/xml/index.d.ts +5 -5
  28. package/dist/base_language/index.d.ts +1 -1
  29. package/dist/chains/api/api_chain.d.ts +2 -2
  30. package/dist/chains/chat_vector_db_chain.d.ts +5 -5
  31. package/dist/chains/combine_docs_chain.d.ts +1 -1
  32. package/dist/chains/constitutional_ai/constitutional_chain.d.ts +2 -2
  33. package/dist/chains/conversational_retrieval_chain.cjs +2 -2
  34. package/dist/chains/conversational_retrieval_chain.d.ts +8 -8
  35. package/dist/chains/conversational_retrieval_chain.js +2 -2
  36. package/dist/chains/graph_qa/cypher.d.ts +4 -4
  37. package/dist/chains/llm_chain.cjs +2 -2
  38. package/dist/chains/llm_chain.d.ts +8 -5
  39. package/dist/chains/llm_chain.js +1 -1
  40. package/dist/chains/query_constructor/index.d.ts +3 -3
  41. package/dist/chains/question_answering/load.d.ts +7 -7
  42. package/dist/chains/retrieval_qa.d.ts +5 -5
  43. package/dist/chains/router/llm_router.d.ts +2 -2
  44. package/dist/chains/router/multi_prompt.d.ts +3 -3
  45. package/dist/chains/router/multi_retrieval_qa.cjs +1 -1
  46. package/dist/chains/router/multi_retrieval_qa.d.ts +7 -7
  47. package/dist/chains/router/multi_retrieval_qa.js +1 -1
  48. package/dist/chains/sql_db/sql_db_chain.d.ts +3 -3
  49. package/dist/chains/summarization/load.d.ts +4 -4
  50. package/dist/chains/vector_db_qa.d.ts +5 -5
  51. package/dist/embeddings/cache_backed.cjs +2 -2
  52. package/dist/embeddings/cache_backed.d.ts +4 -4
  53. package/dist/embeddings/cache_backed.js +1 -1
  54. package/dist/evaluation/agents/trajectory.d.ts +4 -4
  55. package/dist/evaluation/base.d.ts +4 -4
  56. package/dist/evaluation/comparison/pairwise.d.ts +4 -4
  57. package/dist/evaluation/criteria/criteria.d.ts +4 -4
  58. package/dist/evaluation/embedding_distance/base.d.ts +4 -4
  59. package/dist/evaluation/loader.d.ts +4 -4
  60. package/dist/evaluation/qa/eval_chain.d.ts +2 -2
  61. package/dist/experimental/autogpt/agent.d.ts +3 -3
  62. package/dist/experimental/autogpt/prompt.d.ts +2 -2
  63. package/dist/experimental/babyagi/agent.d.ts +5 -5
  64. package/dist/experimental/chains/violation_of_expectations/violation_of_expectations_chain.d.ts +4 -4
  65. package/dist/experimental/chat_models/anthropic_functions.d.ts +2 -2
  66. package/dist/experimental/generative_agents/generative_agent.d.ts +3 -3
  67. package/dist/experimental/generative_agents/generative_agent_memory.d.ts +5 -5
  68. package/dist/experimental/hubs/makersuite/googlemakersuitehub.d.ts +1 -1
  69. package/dist/experimental/plan_and_execute/agent_executor.d.ts +4 -4
  70. package/dist/llms/load.cjs +2 -2
  71. package/dist/llms/load.d.ts +1 -1
  72. package/dist/llms/load.js +1 -1
  73. package/dist/memory/buffer_token_memory.d.ts +3 -3
  74. package/dist/memory/entity_memory.d.ts +3 -3
  75. package/dist/memory/summary.d.ts +3 -3
  76. package/dist/memory/vector_store.d.ts +3 -3
  77. package/dist/output_parsers/fix.d.ts +2 -2
  78. package/dist/retrievers/contextual_compression.cjs +2 -2
  79. package/dist/retrievers/contextual_compression.d.ts +5 -5
  80. package/dist/retrievers/contextual_compression.js +1 -1
  81. package/dist/retrievers/document_compressors/chain_extract.cjs +2 -2
  82. package/dist/retrievers/document_compressors/chain_extract.d.ts +6 -6
  83. package/dist/retrievers/document_compressors/chain_extract.js +1 -1
  84. package/dist/retrievers/document_compressors/embeddings_filter.d.ts +5 -5
  85. package/dist/retrievers/document_compressors/index.d.ts +3 -3
  86. package/dist/retrievers/hyde.d.ts +3 -3
  87. package/dist/retrievers/multi_query.cjs +2 -2
  88. package/dist/retrievers/multi_query.d.ts +4 -4
  89. package/dist/retrievers/multi_query.js +1 -1
  90. package/dist/retrievers/multi_vector.cjs +2 -2
  91. package/dist/retrievers/multi_vector.d.ts +4 -4
  92. package/dist/retrievers/multi_vector.js +1 -1
  93. package/dist/retrievers/parent_document.d.ts +4 -4
  94. package/dist/retrievers/remote/base.cjs +2 -2
  95. package/dist/retrievers/remote/base.d.ts +1 -1
  96. package/dist/retrievers/remote/base.js +1 -1
  97. package/dist/retrievers/self_query/index.cjs +2 -2
  98. package/dist/retrievers/self_query/index.d.ts +1 -1
  99. package/dist/retrievers/self_query/index.js +1 -1
  100. package/dist/retrievers/time_weighted.cjs +2 -2
  101. package/dist/retrievers/time_weighted.d.ts +9 -9
  102. package/dist/retrievers/time_weighted.js +1 -1
  103. package/dist/schema/runnable/base.d.ts +1 -1
  104. package/dist/tools/convert_to_openai.d.ts +4 -4
  105. package/dist/tools/render.d.ts +3 -3
  106. package/dist/tools/sql.d.ts +2 -2
  107. package/dist/tools/vectorstore.d.ts +6 -6
  108. package/dist/tools/webbrowser.cjs +4 -4
  109. package/dist/tools/webbrowser.d.ts +4 -4
  110. package/dist/tools/webbrowser.js +1 -1
  111. package/dist/util/googlevertexai-connection.d.ts +1 -1
  112. package/dist/vectorstores/memory.d.ts +5 -5
  113. package/dist/vectorstores/mongo.d.ts +4 -4
  114. package/package.json +4 -4
@@ -1,11 +1,11 @@
1
1
  import type { OpenAIClient } from "@langchain/openai";
2
- import { StructuredTool } from "./base.js";
2
+ import type { StructuredToolInterface } from "@langchain/core/tools";
3
3
  /**
4
4
  * Formats a `StructuredTool` instance into a format that is compatible
5
5
  * with OpenAI's ChatCompletionFunctions. It uses the `zodToJsonSchema`
6
6
  * function to convert the schema of the `StructuredTool` into a JSON
7
7
  * schema, which is then used as the parameters for the OpenAI function.
8
8
  */
9
- export declare function formatToOpenAIFunction(tool: StructuredTool): OpenAIClient.Chat.ChatCompletionCreateParams.Function;
10
- export declare function formatToOpenAITool(tool: StructuredTool): OpenAIClient.Chat.ChatCompletionTool;
11
- export declare function formatToOpenAIAssistantTool(tool: StructuredTool): OpenAIClient.Beta.AssistantCreateParams.AssistantToolsFunction;
9
+ export declare function formatToOpenAIFunction(tool: StructuredToolInterface): OpenAIClient.Chat.ChatCompletionCreateParams.Function;
10
+ export declare function formatToOpenAITool(tool: StructuredToolInterface): OpenAIClient.Chat.ChatCompletionTool;
11
+ export declare function formatToOpenAIAssistantTool(tool: StructuredToolInterface): OpenAIClient.Beta.AssistantCreateParams.AssistantToolsFunction;
@@ -1,4 +1,4 @@
1
- import { StructuredTool } from "./base.js";
1
+ import { StructuredToolInterface } from "@langchain/core/tools";
2
2
  /**
3
3
  * Render the tool name and description in plain text.
4
4
  *
@@ -10,7 +10,7 @@ import { StructuredTool } from "./base.js";
10
10
  * @param tools
11
11
  * @returns a string of all tools and their descriptions
12
12
  */
13
- export declare function renderTextDescription(tools: StructuredTool[]): string;
13
+ export declare function renderTextDescription(tools: StructuredToolInterface[]): string;
14
14
  /**
15
15
  * Render the tool name, description, and args in plain text.
16
16
  * Output will be in the format of:'
@@ -22,4 +22,4 @@ export declare function renderTextDescription(tools: StructuredTool[]): string;
22
22
  * @param tools
23
23
  * @returns a string of all tools, their descriptions and a stringified version of their schemas
24
24
  */
25
- export declare function renderTextDescriptionAndArgs(tools: StructuredTool[]): string;
25
+ export declare function renderTextDescriptionAndArgs(tools: StructuredToolInterface[]): string;
@@ -1,7 +1,7 @@
1
+ import type { BaseLanguageModelInterface } from "@langchain/core/language_models/base";
1
2
  import { Tool } from "./base.js";
2
3
  import { LLMChain } from "../chains/llm_chain.js";
3
4
  import type { SqlDatabase } from "../sql_db.js";
4
- import { BaseLanguageModel } from "../base_language/index.js";
5
5
  /**
6
6
  * Interface for SQL tools. It has a `db` property which is a SQL
7
7
  * database.
@@ -59,7 +59,7 @@ export declare class ListTablesSqlTool extends Tool implements SqlTool {
59
59
  */
60
60
  type QueryCheckerToolArgs = {
61
61
  llmChain?: LLMChain;
62
- llm?: BaseLanguageModel;
62
+ llm?: BaseLanguageModelInterface;
63
63
  _chainType?: never;
64
64
  };
65
65
  /**
@@ -1,13 +1,13 @@
1
- import { VectorStore } from "../vectorstores/base.js";
2
- import { BaseLanguageModel } from "../base_language/index.js";
1
+ import type { BaseLanguageModelInterface } from "@langchain/core/language_models/base";
2
+ import type { VectorStoreInterface } from "@langchain/core/vectorstores";
3
3
  import { VectorDBQAChain } from "../chains/vector_db_qa.js";
4
4
  import { Tool } from "./base.js";
5
5
  /**
6
6
  * Interface for tools that interact with a Vector Store.
7
7
  */
8
8
  interface VectorStoreTool {
9
- vectorStore: VectorStore;
10
- llm: BaseLanguageModel;
9
+ vectorStore: VectorStoreInterface;
10
+ llm: BaseLanguageModelInterface;
11
11
  }
12
12
  /**
13
13
  * A tool for the VectorDBQA chain to interact with a Vector Store. It is
@@ -16,8 +16,8 @@ interface VectorStoreTool {
16
16
  */
17
17
  export declare class VectorStoreQATool extends Tool implements VectorStoreTool {
18
18
  static lc_name(): string;
19
- vectorStore: VectorStore;
20
- llm: BaseLanguageModel;
19
+ vectorStore: VectorStoreInterface;
20
+ llm: BaseLanguageModelInterface;
21
21
  name: string;
22
22
  description: string;
23
23
  chain: VectorDBQAChain;
@@ -27,15 +27,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.WebBrowser = exports.getText = exports.parseInputs = void 0;
30
+ const documents_1 = require("@langchain/core/documents");
30
31
  const axios_1 = __importDefault(require("axios"));
31
32
  const cheerio = __importStar(require("cheerio"));
32
33
  const env_js_1 = require("../util/env.cjs");
33
34
  const text_splitter_js_1 = require("../text_splitter.cjs");
34
35
  const memory_js_1 = require("../vectorstores/memory.cjs");
35
- const document_js_1 = require("../document.cjs");
36
36
  const base_js_1 = require("./base.cjs");
37
37
  const axios_fetch_adapter_js_1 = __importDefault(require("../util/axios-fetch-adapter.cjs"));
38
- const document_js_2 = require("../util/document.cjs");
38
+ const document_js_1 = require("../util/document.cjs");
39
39
  const parseInputs = (inputs) => {
40
40
  const [baseUrl, task] = inputs.split(",").map((input) => {
41
41
  let t = input.trim();
@@ -237,13 +237,13 @@ class WebBrowser extends base_js_1.Tool {
237
237
  }
238
238
  // search term well embed and grab top 4
239
239
  else {
240
- const docs = texts.map((pageContent) => new document_js_1.Document({
240
+ const docs = texts.map((pageContent) => new documents_1.Document({
241
241
  pageContent,
242
242
  metadata: [],
243
243
  }));
244
244
  const vectorStore = await memory_js_1.MemoryVectorStore.fromDocuments(docs, this.embeddings);
245
245
  const results = await vectorStore.similaritySearch(task, 4, undefined, runManager?.getChild("vectorstore"));
246
- context = (0, document_js_2.formatDocumentsAsString)(results);
246
+ context = (0, document_js_1.formatDocumentsAsString)(results);
247
247
  }
248
248
  const input = `Text:${context}\n\nI need ${doSummary ? "a summary" : task} from the above text, also provide up to 5 markdown links from within that would be of interest (always including URL and text). Links should be provided, if present, in markdown syntax as a list under the heading "Relevant Links:".`;
249
249
  return this.model.predict(input, undefined, runManager?.getChild());
@@ -1,9 +1,9 @@
1
+ import type { BaseLanguageModelInterface } from "@langchain/core/language_models/base";
2
+ import type { EmbeddingsInterface } from "@langchain/core/embeddings";
1
3
  import { AxiosRequestConfig } from "axios";
2
- import { BaseLanguageModel } from "../base_language/index.js";
3
4
  import { TextSplitter } from "../text_splitter.js";
4
5
  import { Tool, ToolParams } from "./base.js";
5
6
  import { CallbackManager, CallbackManagerForToolRun } from "../callbacks/manager.js";
6
- import { Embeddings } from "../embeddings/base.js";
7
7
  export declare const parseInputs: (inputs: string) => [string, string];
8
8
  export declare const getText: (html: string, baseUrl: string, summary: boolean) => string;
9
9
  type Headers = Record<string, any>;
@@ -14,8 +14,8 @@ type Headers = Record<string, any>;
14
14
  * callback manager, and a text splitter.
15
15
  */
16
16
  export interface WebBrowserArgs extends ToolParams {
17
- model: BaseLanguageModel;
18
- embeddings: Embeddings;
17
+ model: BaseLanguageModelInterface;
18
+ embeddings: EmbeddingsInterface;
19
19
  headers?: Headers;
20
20
  axiosConfig?: Omit<AxiosRequestConfig, "url">;
21
21
  /** @deprecated */
@@ -1,9 +1,9 @@
1
+ import { Document } from "@langchain/core/documents";
1
2
  import axiosMod from "axios";
2
3
  import * as cheerio from "cheerio";
3
4
  import { isNode } from "../util/env.js";
4
5
  import { RecursiveCharacterTextSplitter, } from "../text_splitter.js";
5
6
  import { MemoryVectorStore } from "../vectorstores/memory.js";
6
- import { Document } from "../document.js";
7
7
  import { Tool } from "./base.js";
8
8
  import fetchAdapter from "../util/axios-fetch-adapter.js";
9
9
  import { formatDocumentsAsString } from "../util/document.js";
@@ -1,4 +1,4 @@
1
- import { BaseLanguageModelCallOptions } from "../base_language/index.js";
1
+ import { BaseLanguageModelCallOptions } from "@langchain/core/language_models/base";
2
2
  import { AsyncCaller, AsyncCallerCallOptions } from "./async_caller.js";
3
3
  import type { GoogleVertexAIBaseLLMInput, GoogleVertexAIBasePrediction, GoogleVertexAIConnectionParams, GoogleVertexAILLMPredictions, GoogleVertexAIModelParams, GoogleResponse, GoogleAbstractedClient, GoogleAbstractedClientOpsMethod } from "../types/googlevertexai-types.js";
4
4
  export declare abstract class GoogleConnection<CallOptions extends AsyncCallerCallOptions, ResponseType extends GoogleResponse> {
@@ -1,6 +1,6 @@
1
1
  import { similarity as ml_distance_similarity } from "ml-distance";
2
2
  import { VectorStore } from "@langchain/core/vectorstores";
3
- import { Embeddings } from "@langchain/core/embeddings";
3
+ import type { EmbeddingsInterface } from "@langchain/core/embeddings";
4
4
  import { Document } from "@langchain/core/documents";
5
5
  /**
6
6
  * Interface representing a vector in memory. It includes the content
@@ -30,7 +30,7 @@ export declare class MemoryVectorStore extends VectorStore {
30
30
  memoryVectors: MemoryVector[];
31
31
  similarity: typeof ml_distance_similarity.cosine;
32
32
  _vectorstoreType(): string;
33
- constructor(embeddings: Embeddings, { similarity, ...rest }?: MemoryVectorStoreArgs);
33
+ constructor(embeddings: EmbeddingsInterface, { similarity, ...rest }?: MemoryVectorStoreArgs);
34
34
  /**
35
35
  * Method to add documents to the memory vector store. It extracts the
36
36
  * text from each document, generates embeddings for them, and adds the
@@ -69,7 +69,7 @@ export declare class MemoryVectorStore extends VectorStore {
69
69
  * @param dbConfig Optional `MemoryVectorStoreArgs` to configure the `MemoryVectorStore` instance.
70
70
  * @returns Promise that resolves with a new `MemoryVectorStore` instance.
71
71
  */
72
- static fromTexts(texts: string[], metadatas: object[] | object, embeddings: Embeddings, dbConfig?: MemoryVectorStoreArgs): Promise<MemoryVectorStore>;
72
+ static fromTexts(texts: string[], metadatas: object[] | object, embeddings: EmbeddingsInterface, dbConfig?: MemoryVectorStoreArgs): Promise<MemoryVectorStore>;
73
73
  /**
74
74
  * Static method to create a `MemoryVectorStore` instance from an array of
75
75
  * `Document` instances. It adds the documents to the store.
@@ -78,7 +78,7 @@ export declare class MemoryVectorStore extends VectorStore {
78
78
  * @param dbConfig Optional `MemoryVectorStoreArgs` to configure the `MemoryVectorStore` instance.
79
79
  * @returns Promise that resolves with a new `MemoryVectorStore` instance.
80
80
  */
81
- static fromDocuments(docs: Document[], embeddings: Embeddings, dbConfig?: MemoryVectorStoreArgs): Promise<MemoryVectorStore>;
81
+ static fromDocuments(docs: Document[], embeddings: EmbeddingsInterface, dbConfig?: MemoryVectorStoreArgs): Promise<MemoryVectorStore>;
82
82
  /**
83
83
  * Static method to create a `MemoryVectorStore` instance from an existing
84
84
  * index. It creates a new `MemoryVectorStore` instance without adding any
@@ -87,6 +87,6 @@ export declare class MemoryVectorStore extends VectorStore {
87
87
  * @param dbConfig Optional `MemoryVectorStoreArgs` to configure the `MemoryVectorStore` instance.
88
88
  * @returns Promise that resolves with a new `MemoryVectorStore` instance.
89
89
  */
90
- static fromExistingIndex(embeddings: Embeddings, dbConfig?: MemoryVectorStoreArgs): Promise<MemoryVectorStore>;
90
+ static fromExistingIndex(embeddings: EmbeddingsInterface, dbConfig?: MemoryVectorStoreArgs): Promise<MemoryVectorStore>;
91
91
  }
92
92
  export {};
@@ -1,6 +1,6 @@
1
+ import type { EmbeddingsInterface } from "@langchain/core/embeddings";
1
2
  import type { MongoClient, Collection, Document as MongoDocument } from "mongodb";
2
3
  import { VectorStore } from "./base.js";
3
- import { Embeddings } from "../embeddings/base.js";
4
4
  import { Document } from "../document.js";
5
5
  /** @deprecated use `MongoDBAtlasVectorSearch` instead. */
6
6
  export type MongoLibArgs = {
@@ -22,7 +22,7 @@ export declare class MongoVectorStore extends VectorStore {
22
22
  client: MongoClient;
23
23
  indexName: string;
24
24
  _vectorstoreType(): string;
25
- constructor(embeddings: Embeddings, args: MongoLibArgs);
25
+ constructor(embeddings: EmbeddingsInterface, args: MongoLibArgs);
26
26
  /**
27
27
  * Method that adds documents to the MongoDB collection. It first converts
28
28
  * the documents into vectors using the `embedDocuments` method of the
@@ -62,7 +62,7 @@ export declare class MongoVectorStore extends VectorStore {
62
62
  * @param dbConfig Configuration for the MongoDB database.
63
63
  * @returns Promise that resolves to a new MongoVectorStore instance.
64
64
  */
65
- static fromTexts(texts: string[], metadatas: object[] | object, embeddings: Embeddings, dbConfig: MongoLibArgs): Promise<MongoVectorStore>;
65
+ static fromTexts(texts: string[], metadatas: object[] | object, embeddings: EmbeddingsInterface, dbConfig: MongoLibArgs): Promise<MongoVectorStore>;
66
66
  /**
67
67
  * Static method that creates a `MongoVectorStore` instance from an array
68
68
  * of Document instances. It creates a new `MongoVectorStore` instance,
@@ -72,5 +72,5 @@ export declare class MongoVectorStore extends VectorStore {
72
72
  * @param dbConfig Configuration for the MongoDB database.
73
73
  * @returns Promise that resolves to a new MongoVectorStore instance.
74
74
  */
75
- static fromDocuments(docs: Document[], embeddings: Embeddings, dbConfig: MongoLibArgs): Promise<MongoVectorStore>;
75
+ static fromDocuments(docs: Document[], embeddings: EmbeddingsInterface, dbConfig: MongoLibArgs): Promise<MongoVectorStore>;
76
76
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langchain",
3
- "version": "0.0.209",
3
+ "version": "0.0.210",
4
4
  "description": "Typescript bindings for langchain",
5
5
  "type": "module",
6
6
  "engines": {
@@ -1178,9 +1178,9 @@
1178
1178
  },
1179
1179
  "dependencies": {
1180
1180
  "@anthropic-ai/sdk": "^0.9.1",
1181
- "@langchain/community": "~0.0.7",
1182
- "@langchain/core": "~0.1.2",
1183
- "@langchain/openai": "~0.0.6",
1181
+ "@langchain/community": "~0.0.8",
1182
+ "@langchain/core": "~0.1.3",
1183
+ "@langchain/openai": "~0.0.7",
1184
1184
  "binary-extensions": "^2.2.0",
1185
1185
  "expr-eval": "^2.0.2",
1186
1186
  "js-tiktoken": "^1.0.7",