langchain 0.0.212 → 0.0.214

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 (138) hide show
  1. package/README.md +1 -1
  2. package/chains/combine_documents.cjs +1 -0
  3. package/chains/combine_documents.d.ts +1 -0
  4. package/chains/combine_documents.js +1 -0
  5. package/chains/history_aware_retriever.cjs +1 -0
  6. package/chains/history_aware_retriever.d.ts +1 -0
  7. package/chains/history_aware_retriever.js +1 -0
  8. package/chains/retrieval.cjs +1 -0
  9. package/chains/retrieval.d.ts +1 -0
  10. package/chains/retrieval.js +1 -0
  11. package/dist/agents/agent.cjs +1 -0
  12. package/dist/agents/agent.js +1 -0
  13. package/dist/agents/executor.cjs +21 -3
  14. package/dist/agents/executor.d.ts +1 -0
  15. package/dist/agents/executor.js +21 -3
  16. package/dist/agents/format_scratchpad/openai_functions.cjs +22 -1
  17. package/dist/agents/format_scratchpad/openai_functions.d.ts +10 -0
  18. package/dist/agents/format_scratchpad/openai_functions.js +21 -1
  19. package/dist/agents/index.cjs +11 -4
  20. package/dist/agents/index.d.ts +6 -3
  21. package/dist/agents/index.js +5 -3
  22. package/dist/agents/initialize.cjs +1 -1
  23. package/dist/agents/initialize.d.ts +1 -1
  24. package/dist/agents/initialize.js +1 -1
  25. package/dist/agents/openai/output_parser.cjs +20 -196
  26. package/dist/agents/openai/output_parser.d.ts +2 -111
  27. package/dist/agents/openai/output_parser.js +6 -193
  28. package/dist/agents/{openai → openai_functions}/index.cjs +80 -2
  29. package/dist/agents/{openai → openai_functions}/index.d.ts +77 -3
  30. package/dist/agents/{openai → openai_functions}/index.js +78 -1
  31. package/dist/agents/openai_functions/output_parser.cjs +102 -0
  32. package/dist/agents/openai_functions/output_parser.d.ts +56 -0
  33. package/dist/agents/openai_functions/output_parser.js +98 -0
  34. package/dist/agents/openai_tools/index.cjs +83 -0
  35. package/dist/agents/openai_tools/index.d.ts +82 -0
  36. package/dist/agents/openai_tools/index.js +79 -0
  37. package/dist/agents/openai_tools/output_parser.cjs +102 -0
  38. package/dist/agents/openai_tools/output_parser.d.ts +57 -0
  39. package/dist/agents/openai_tools/output_parser.js +98 -0
  40. package/dist/agents/react/index.cjs +77 -0
  41. package/dist/agents/react/index.d.ts +62 -0
  42. package/dist/agents/react/index.js +73 -0
  43. package/dist/agents/react/output_parser.cjs +0 -1
  44. package/dist/agents/react/output_parser.d.ts +0 -1
  45. package/dist/agents/react/output_parser.js +0 -1
  46. package/dist/agents/structured_chat/index.cjs +87 -1
  47. package/dist/agents/structured_chat/index.d.ts +73 -0
  48. package/dist/agents/structured_chat/index.js +85 -0
  49. package/dist/agents/toolkits/conversational_retrieval/token_buffer_memory.cjs +1 -1
  50. package/dist/agents/toolkits/conversational_retrieval/token_buffer_memory.js +1 -1
  51. package/dist/agents/toolkits/conversational_retrieval/tool.cjs +1 -0
  52. package/dist/agents/toolkits/conversational_retrieval/tool.d.ts +1 -0
  53. package/dist/agents/toolkits/conversational_retrieval/tool.js +1 -0
  54. package/dist/agents/toolkits/json/json.cjs +2 -0
  55. package/dist/agents/toolkits/json/json.d.ts +2 -0
  56. package/dist/agents/toolkits/json/json.js +2 -0
  57. package/dist/agents/toolkits/openapi/openapi.cjs +2 -0
  58. package/dist/agents/toolkits/openapi/openapi.d.ts +2 -0
  59. package/dist/agents/toolkits/openapi/openapi.js +2 -0
  60. package/dist/agents/toolkits/vectorstore/vectorstore.cjs +2 -0
  61. package/dist/agents/toolkits/vectorstore/vectorstore.d.ts +2 -0
  62. package/dist/agents/toolkits/vectorstore/vectorstore.js +2 -0
  63. package/dist/agents/xml/index.cjs +77 -1
  64. package/dist/agents/xml/index.d.ts +67 -0
  65. package/dist/agents/xml/index.js +75 -0
  66. package/dist/callbacks/index.cjs +1 -4
  67. package/dist/callbacks/index.d.ts +1 -2
  68. package/dist/callbacks/index.js +1 -2
  69. package/dist/chains/combine_documents/base.cjs +16 -0
  70. package/dist/chains/combine_documents/base.d.ts +13 -0
  71. package/dist/chains/combine_documents/base.js +12 -0
  72. package/dist/chains/combine_documents/index.cjs +5 -0
  73. package/dist/chains/combine_documents/index.d.ts +1 -0
  74. package/dist/chains/combine_documents/index.js +1 -0
  75. package/dist/chains/combine_documents/reduce.cjs +5 -2
  76. package/dist/chains/combine_documents/reduce.js +4 -1
  77. package/dist/chains/combine_documents/stuff.cjs +42 -0
  78. package/dist/chains/combine_documents/stuff.d.ts +28 -0
  79. package/dist/chains/combine_documents/stuff.js +38 -0
  80. package/dist/chains/conversational_retrieval_chain.cjs +3 -3
  81. package/dist/chains/conversational_retrieval_chain.js +1 -1
  82. package/dist/chains/history_aware_retriever.cjs +55 -0
  83. package/dist/chains/history_aware_retriever.d.ts +55 -0
  84. package/dist/chains/history_aware_retriever.js +51 -0
  85. package/dist/chains/openai_functions/structured_output.cjs +63 -21
  86. package/dist/chains/openai_functions/structured_output.d.ts +25 -17
  87. package/dist/chains/openai_functions/structured_output.js +62 -20
  88. package/dist/chains/retrieval.cjs +60 -0
  89. package/dist/chains/retrieval.d.ts +65 -0
  90. package/dist/chains/retrieval.js +56 -0
  91. package/dist/experimental/autogpt/prompt.cjs +1 -1
  92. package/dist/experimental/autogpt/prompt.d.ts +1 -1
  93. package/dist/experimental/autogpt/prompt.js +1 -1
  94. package/dist/load/import_map.cjs +7 -3
  95. package/dist/load/import_map.d.ts +4 -0
  96. package/dist/load/import_map.js +4 -0
  97. package/dist/output_parsers/json.cjs +2 -78
  98. package/dist/output_parsers/json.d.ts +1 -1
  99. package/dist/output_parsers/json.js +1 -77
  100. package/dist/output_parsers/openai_functions.d.ts +1 -1
  101. package/dist/retrievers/multi_vector.cjs +11 -2
  102. package/dist/retrievers/multi_vector.d.ts +5 -3
  103. package/dist/retrievers/multi_vector.js +11 -2
  104. package/dist/retrievers/parent_document.cjs +1 -2
  105. package/dist/retrievers/parent_document.d.ts +1 -1
  106. package/dist/retrievers/parent_document.js +1 -2
  107. package/dist/retrievers/remote/chatgpt-plugin.cjs +5 -4
  108. package/dist/retrievers/remote/chatgpt-plugin.d.ts +5 -2
  109. package/dist/retrievers/remote/chatgpt-plugin.js +3 -2
  110. package/dist/retrievers/remote/index.cjs +2 -2
  111. package/dist/retrievers/remote/index.d.ts +1 -1
  112. package/dist/retrievers/remote/index.js +1 -1
  113. package/dist/retrievers/remote/remote-retriever.cjs +3 -2
  114. package/dist/retrievers/remote/remote-retriever.d.ts +3 -1
  115. package/dist/retrievers/remote/remote-retriever.js +2 -1
  116. package/dist/retrievers/vespa.cjs +15 -78
  117. package/dist/retrievers/vespa.d.ts +1 -54
  118. package/dist/retrievers/vespa.js +1 -76
  119. package/dist/schema/runnable/config.d.ts +1 -1
  120. package/dist/tools/retriever.cjs +17 -0
  121. package/dist/tools/retriever.d.ts +10 -0
  122. package/dist/tools/retriever.js +13 -0
  123. package/dist/util/entrypoint_deprecation.cjs +18 -0
  124. package/dist/util/entrypoint_deprecation.d.ts +5 -0
  125. package/dist/util/entrypoint_deprecation.js +14 -0
  126. package/package.json +36 -4
  127. package/tools/retriever.cjs +1 -0
  128. package/tools/retriever.d.ts +1 -0
  129. package/tools/retriever.js +1 -0
  130. package/dist/callbacks/handlers/tracer_langchain_v1.cjs +0 -17
  131. package/dist/callbacks/handlers/tracer_langchain_v1.d.ts +0 -1
  132. package/dist/callbacks/handlers/tracer_langchain_v1.js +0 -1
  133. package/dist/retrievers/remote/base.cjs +0 -68
  134. package/dist/retrievers/remote/base.d.ts +0 -60
  135. package/dist/retrievers/remote/base.js +0 -64
  136. /package/dist/agents/{openai → openai_functions}/prompt.cjs +0 -0
  137. /package/dist/agents/{openai → openai_functions}/prompt.d.ts +0 -0
  138. /package/dist/agents/{openai → openai_functions}/prompt.js +0 -0
@@ -1,80 +1,17 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VespaRetriever = void 0;
4
- const document_js_1 = require("../document.cjs");
5
- const base_js_1 = require("./remote/base.cjs");
6
- /**
7
- * Class responsible for retrieving data from Vespa. It extends the
8
- * `RemoteRetriever` class and includes methods for creating the JSON body
9
- * for a query and processing the JSON response from Vespa.
10
- * @example
11
- * ```typescript
12
- * const retriever = new VespaRetriever({
13
- * url: "https:
14
- * auth: false,
15
- * query_body: {
16
- * yql: "select content from paragraph where userQuery()",
17
- * hits: 5,
18
- * ranking: "documentation",
19
- * locale: "en-us",
20
- * },
21
- * content_field: "content",
22
- * });
23
- * const result = await retriever.getRelevantDocuments("what is vespa?");
24
- * ```
25
- */
26
- class VespaRetriever extends base_js_1.RemoteRetriever {
27
- static lc_name() {
28
- return "VespaRetriever";
29
- }
30
- constructor(fields) {
31
- super(fields);
32
- Object.defineProperty(this, "lc_namespace", {
33
- enumerable: true,
34
- configurable: true,
35
- writable: true,
36
- value: ["langchain", "retrievers", "vespa"]
37
- });
38
- Object.defineProperty(this, "query_body", {
39
- enumerable: true,
40
- configurable: true,
41
- writable: true,
42
- value: void 0
43
- });
44
- Object.defineProperty(this, "content_field", {
45
- enumerable: true,
46
- configurable: true,
47
- writable: true,
48
- value: void 0
49
- });
50
- this.query_body = fields.query_body;
51
- this.content_field = fields.content_field;
52
- this.url = `${this.url}/search/?`;
53
- }
54
- /**
55
- * Method that takes a query string as input and returns a JSON object
56
- * that includes the query and the original `query_body`.
57
- * @param query The query string to be sent to Vespa.
58
- * @returns A JSON object that includes the query and the original `query_body`.
59
- */
60
- createJsonBody(query) {
61
- return {
62
- ...this.query_body,
63
- query,
64
- };
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
65
7
  }
66
- /**
67
- * Method that processes the JSON response from Vespa into an array of
68
- * `Document` instances. Each `Document` instance includes the content
69
- * from the specified `content_field` and the document's ID.
70
- * @param json The JSON response from Vespa.
71
- * @returns An array of `Document` instances.
72
- */
73
- processJsonResponse(json) {
74
- return json.root.children.map((doc) => new document_js_1.Document({
75
- pageContent: doc.fields[this.content_field],
76
- metadata: { id: doc.id },
77
- }));
78
- }
79
- }
80
- exports.VespaRetriever = VespaRetriever;
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("@langchain/community/retrievers/vespa"), exports);
@@ -1,54 +1 @@
1
- import { Document } from "../document.js";
2
- import { RemoteRetriever, RemoteRetrieverValues, RemoteRetrieverParams } from "./remote/base.js";
3
- export interface VespaRetrieverParams extends RemoteRetrieverParams {
4
- /**
5
- * The body of the query to send to Vespa
6
- */
7
- query_body: object;
8
- /**
9
- * The name of the field the content resides in
10
- */
11
- content_field: string;
12
- }
13
- /**
14
- * Class responsible for retrieving data from Vespa. It extends the
15
- * `RemoteRetriever` class and includes methods for creating the JSON body
16
- * for a query and processing the JSON response from Vespa.
17
- * @example
18
- * ```typescript
19
- * const retriever = new VespaRetriever({
20
- * url: "https:
21
- * auth: false,
22
- * query_body: {
23
- * yql: "select content from paragraph where userQuery()",
24
- * hits: 5,
25
- * ranking: "documentation",
26
- * locale: "en-us",
27
- * },
28
- * content_field: "content",
29
- * });
30
- * const result = await retriever.getRelevantDocuments("what is vespa?");
31
- * ```
32
- */
33
- export declare class VespaRetriever extends RemoteRetriever {
34
- static lc_name(): string;
35
- lc_namespace: string[];
36
- query_body: object;
37
- content_field: string;
38
- constructor(fields: VespaRetrieverParams);
39
- /**
40
- * Method that takes a query string as input and returns a JSON object
41
- * that includes the query and the original `query_body`.
42
- * @param query The query string to be sent to Vespa.
43
- * @returns A JSON object that includes the query and the original `query_body`.
44
- */
45
- createJsonBody(query: string): RemoteRetrieverValues;
46
- /**
47
- * Method that processes the JSON response from Vespa into an array of
48
- * `Document` instances. Each `Document` instance includes the content
49
- * from the specified `content_field` and the document's ID.
50
- * @param json The JSON response from Vespa.
51
- * @returns An array of `Document` instances.
52
- */
53
- processJsonResponse(json: RemoteRetrieverValues): Document[];
54
- }
1
+ export * from "@langchain/community/retrievers/vespa";
@@ -1,76 +1 @@
1
- import { Document } from "../document.js";
2
- import { RemoteRetriever, } from "./remote/base.js";
3
- /**
4
- * Class responsible for retrieving data from Vespa. It extends the
5
- * `RemoteRetriever` class and includes methods for creating the JSON body
6
- * for a query and processing the JSON response from Vespa.
7
- * @example
8
- * ```typescript
9
- * const retriever = new VespaRetriever({
10
- * url: "https:
11
- * auth: false,
12
- * query_body: {
13
- * yql: "select content from paragraph where userQuery()",
14
- * hits: 5,
15
- * ranking: "documentation",
16
- * locale: "en-us",
17
- * },
18
- * content_field: "content",
19
- * });
20
- * const result = await retriever.getRelevantDocuments("what is vespa?");
21
- * ```
22
- */
23
- export class VespaRetriever extends RemoteRetriever {
24
- static lc_name() {
25
- return "VespaRetriever";
26
- }
27
- constructor(fields) {
28
- super(fields);
29
- Object.defineProperty(this, "lc_namespace", {
30
- enumerable: true,
31
- configurable: true,
32
- writable: true,
33
- value: ["langchain", "retrievers", "vespa"]
34
- });
35
- Object.defineProperty(this, "query_body", {
36
- enumerable: true,
37
- configurable: true,
38
- writable: true,
39
- value: void 0
40
- });
41
- Object.defineProperty(this, "content_field", {
42
- enumerable: true,
43
- configurable: true,
44
- writable: true,
45
- value: void 0
46
- });
47
- this.query_body = fields.query_body;
48
- this.content_field = fields.content_field;
49
- this.url = `${this.url}/search/?`;
50
- }
51
- /**
52
- * Method that takes a query string as input and returns a JSON object
53
- * that includes the query and the original `query_body`.
54
- * @param query The query string to be sent to Vespa.
55
- * @returns A JSON object that includes the query and the original `query_body`.
56
- */
57
- createJsonBody(query) {
58
- return {
59
- ...this.query_body,
60
- query,
61
- };
62
- }
63
- /**
64
- * Method that processes the JSON response from Vespa into an array of
65
- * `Document` instances. Each `Document` instance includes the content
66
- * from the specified `content_field` and the document's ID.
67
- * @param json The JSON response from Vespa.
68
- * @returns An array of `Document` instances.
69
- */
70
- processJsonResponse(json) {
71
- return json.root.children.map((doc) => new Document({
72
- pageContent: doc.fields[this.content_field],
73
- metadata: { id: doc.id },
74
- }));
75
- }
76
- }
1
+ export * from "@langchain/community/retrievers/vespa";
@@ -1 +1 @@
1
- export { getCallbackMangerForConfig, RunnableConfig, } from "@langchain/core/runnables";
1
+ export { RunnableConfig } from "@langchain/core/runnables";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createRetrieverTool = void 0;
4
+ const zod_1 = require("zod");
5
+ const dynamic_1 = require("@langchain/community/tools/dynamic");
6
+ const document_js_1 = require("../util/document.cjs");
7
+ function createRetrieverTool(retriever, input) {
8
+ const func = async ({ query }, runManager) => {
9
+ const docs = await retriever.getRelevantDocuments(query, runManager?.getChild("retriever"));
10
+ return (0, document_js_1.formatDocumentsAsString)(docs);
11
+ };
12
+ const schema = zod_1.z.object({
13
+ query: zod_1.z.string().describe("query to look up in retriever"),
14
+ });
15
+ return new dynamic_1.DynamicStructuredTool({ ...input, func, schema });
16
+ }
17
+ exports.createRetrieverTool = createRetrieverTool;
@@ -0,0 +1,10 @@
1
+ import type { BaseRetrieverInterface } from "@langchain/core/retrievers";
2
+ import { z } from "zod";
3
+ import { DynamicStructuredTool, type DynamicStructuredToolInput } from "@langchain/community/tools/dynamic";
4
+ export declare function createRetrieverTool(retriever: BaseRetrieverInterface, input: Omit<DynamicStructuredToolInput, "func" | "schema">): DynamicStructuredTool<z.ZodObject<{
5
+ query: z.ZodString;
6
+ }, "strip", z.ZodTypeAny, {
7
+ query: string;
8
+ }, {
9
+ query: string;
10
+ }>>;
@@ -0,0 +1,13 @@
1
+ import { z } from "zod";
2
+ import { DynamicStructuredTool, } from "@langchain/community/tools/dynamic";
3
+ import { formatDocumentsAsString } from "../util/document.js";
4
+ export function createRetrieverTool(retriever, input) {
5
+ const func = async ({ query }, runManager) => {
6
+ const docs = await retriever.getRelevantDocuments(query, runManager?.getChild("retriever"));
7
+ return formatDocumentsAsString(docs);
8
+ };
9
+ const schema = z.object({
10
+ query: z.string().describe("query to look up in retriever"),
11
+ });
12
+ return new DynamicStructuredTool({ ...input, func, schema });
13
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.logVersion010MigrationWarning = void 0;
4
+ function logVersion010MigrationWarning({ oldEntrypointName, newEntrypointName, newPackageName = "@langchain/community", }) {
5
+ /* #__PURE__ */ console.warn([
6
+ `[WARNING]: Importing from "langchain/${oldEntrypointName}" is deprecated.\n`,
7
+ `Instead, please add the "${newPackageName}" package to your project with e.g.`,
8
+ ``,
9
+ ` $ npm install ${newPackageName}`,
10
+ ``,
11
+ `and import from "${newPackageName}${newEntrypointName === undefined
12
+ ? `/${oldEntrypointName}`
13
+ : newEntrypointName}".`,
14
+ ``,
15
+ `This will be mandatory after the next "langchain" minor version bump to 0.2.`,
16
+ ].join("\n"));
17
+ }
18
+ exports.logVersion010MigrationWarning = logVersion010MigrationWarning;
@@ -0,0 +1,5 @@
1
+ export declare function logVersion010MigrationWarning({ oldEntrypointName, newEntrypointName, newPackageName, }: {
2
+ oldEntrypointName: string;
3
+ newEntrypointName?: string;
4
+ newPackageName?: string;
5
+ }): void;
@@ -0,0 +1,14 @@
1
+ export function logVersion010MigrationWarning({ oldEntrypointName, newEntrypointName, newPackageName = "@langchain/community", }) {
2
+ /* #__PURE__ */ console.warn([
3
+ `[WARNING]: Importing from "langchain/${oldEntrypointName}" is deprecated.\n`,
4
+ `Instead, please add the "${newPackageName}" package to your project with e.g.`,
5
+ ``,
6
+ ` $ npm install ${newPackageName}`,
7
+ ``,
8
+ `and import from "${newPackageName}${newEntrypointName === undefined
9
+ ? `/${oldEntrypointName}`
10
+ : newEntrypointName}".`,
11
+ ``,
12
+ `This will be mandatory after the next "langchain" minor version bump to 0.2.`,
13
+ ].join("\n"));
14
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langchain",
3
- "version": "0.0.212",
3
+ "version": "0.0.214",
4
4
  "description": "Typescript bindings for langchain",
5
5
  "type": "module",
6
6
  "engines": {
@@ -79,6 +79,9 @@
79
79
  "tools/render.cjs",
80
80
  "tools/render.js",
81
81
  "tools/render.d.ts",
82
+ "tools/retriever.cjs",
83
+ "tools/retriever.js",
84
+ "tools/retriever.d.ts",
82
85
  "tools/sql.cjs",
83
86
  "tools/sql.js",
84
87
  "tools/sql.d.ts",
@@ -97,9 +100,15 @@
97
100
  "chains.cjs",
98
101
  "chains.js",
99
102
  "chains.d.ts",
103
+ "chains/combine_documents.cjs",
104
+ "chains/combine_documents.js",
105
+ "chains/combine_documents.d.ts",
100
106
  "chains/combine_documents/reduce.cjs",
101
107
  "chains/combine_documents/reduce.js",
102
108
  "chains/combine_documents/reduce.d.ts",
109
+ "chains/history_aware_retriever.cjs",
110
+ "chains/history_aware_retriever.js",
111
+ "chains/history_aware_retriever.d.ts",
103
112
  "chains/load.cjs",
104
113
  "chains/load.js",
105
114
  "chains/load.d.ts",
@@ -112,6 +121,9 @@
112
121
  "chains/query_constructor/ir.cjs",
113
122
  "chains/query_constructor/ir.js",
114
123
  "chains/query_constructor/ir.d.ts",
124
+ "chains/retrieval.cjs",
125
+ "chains/retrieval.js",
126
+ "chains/retrieval.d.ts",
115
127
  "chains/sql_db.cjs",
116
128
  "chains/sql_db.js",
117
129
  "chains/sql_db.d.ts",
@@ -1178,9 +1190,9 @@
1178
1190
  },
1179
1191
  "dependencies": {
1180
1192
  "@anthropic-ai/sdk": "^0.9.1",
1181
- "@langchain/community": "~0.0.8",
1182
- "@langchain/core": "~0.1.3",
1183
- "@langchain/openai": "~0.0.7",
1193
+ "@langchain/community": "~0.0.13",
1194
+ "@langchain/core": "~0.1.5",
1195
+ "@langchain/openai": "~0.0.9",
1184
1196
  "binary-extensions": "^2.2.0",
1185
1197
  "expr-eval": "^2.0.2",
1186
1198
  "js-tiktoken": "^1.0.7",
@@ -1329,6 +1341,11 @@
1329
1341
  "import": "./tools/render.js",
1330
1342
  "require": "./tools/render.cjs"
1331
1343
  },
1344
+ "./tools/retriever": {
1345
+ "types": "./tools/retriever.d.ts",
1346
+ "import": "./tools/retriever.js",
1347
+ "require": "./tools/retriever.cjs"
1348
+ },
1332
1349
  "./tools/sql": {
1333
1350
  "types": "./tools/sql.d.ts",
1334
1351
  "import": "./tools/sql.js",
@@ -1359,11 +1376,21 @@
1359
1376
  "import": "./chains.js",
1360
1377
  "require": "./chains.cjs"
1361
1378
  },
1379
+ "./chains/combine_documents": {
1380
+ "types": "./chains/combine_documents.d.ts",
1381
+ "import": "./chains/combine_documents.js",
1382
+ "require": "./chains/combine_documents.cjs"
1383
+ },
1362
1384
  "./chains/combine_documents/reduce": {
1363
1385
  "types": "./chains/combine_documents/reduce.d.ts",
1364
1386
  "import": "./chains/combine_documents/reduce.js",
1365
1387
  "require": "./chains/combine_documents/reduce.cjs"
1366
1388
  },
1389
+ "./chains/history_aware_retriever": {
1390
+ "types": "./chains/history_aware_retriever.d.ts",
1391
+ "import": "./chains/history_aware_retriever.js",
1392
+ "require": "./chains/history_aware_retriever.cjs"
1393
+ },
1367
1394
  "./chains/load": {
1368
1395
  "types": "./chains/load.d.ts",
1369
1396
  "import": "./chains/load.js",
@@ -1384,6 +1411,11 @@
1384
1411
  "import": "./chains/query_constructor/ir.js",
1385
1412
  "require": "./chains/query_constructor/ir.cjs"
1386
1413
  },
1414
+ "./chains/retrieval": {
1415
+ "types": "./chains/retrieval.d.ts",
1416
+ "import": "./chains/retrieval.js",
1417
+ "require": "./chains/retrieval.cjs"
1418
+ },
1387
1419
  "./chains/sql_db": {
1388
1420
  "types": "./chains/sql_db.d.ts",
1389
1421
  "import": "./chains/sql_db.js",
@@ -0,0 +1 @@
1
+ module.exports = require('../dist/tools/retriever.cjs');
@@ -0,0 +1 @@
1
+ export * from '../dist/tools/retriever.js'
@@ -0,0 +1 @@
1
+ export * from '../dist/tools/retriever.js'
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("@langchain/core/tracers/tracer_langchain_v1"), exports);
@@ -1 +0,0 @@
1
- export * from "@langchain/core/tracers/tracer_langchain_v1";
@@ -1 +0,0 @@
1
- export * from "@langchain/core/tracers/tracer_langchain_v1";
@@ -1,68 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RemoteRetriever = void 0;
4
- const retrievers_1 = require("@langchain/core/retrievers");
5
- const async_caller_js_1 = require("../../util/async_caller.cjs");
6
- /**
7
- * Abstract class for interacting with a remote server to retrieve
8
- * relevant documents based on a given query.
9
- */
10
- class RemoteRetriever extends retrievers_1.BaseRetriever {
11
- get lc_secrets() {
12
- return {
13
- "auth.bearer": "REMOTE_RETRIEVER_AUTH_BEARER",
14
- };
15
- }
16
- constructor(fields) {
17
- super(fields);
18
- Object.defineProperty(this, "url", {
19
- enumerable: true,
20
- configurable: true,
21
- writable: true,
22
- value: void 0
23
- });
24
- Object.defineProperty(this, "auth", {
25
- enumerable: true,
26
- configurable: true,
27
- writable: true,
28
- value: void 0
29
- });
30
- Object.defineProperty(this, "headers", {
31
- enumerable: true,
32
- configurable: true,
33
- writable: true,
34
- value: void 0
35
- });
36
- Object.defineProperty(this, "asyncCaller", {
37
- enumerable: true,
38
- configurable: true,
39
- writable: true,
40
- value: void 0
41
- });
42
- const { url, auth, ...rest } = fields;
43
- this.url = url;
44
- this.auth = auth;
45
- this.headers = {
46
- Accept: "application/json",
47
- "Content-Type": "application/json",
48
- ...(this.auth && this.auth.bearer
49
- ? { Authorization: `Bearer ${this.auth.bearer}` }
50
- : {}),
51
- };
52
- this.asyncCaller = new async_caller_js_1.AsyncCaller(rest);
53
- }
54
- async _getRelevantDocuments(query) {
55
- const body = this.createJsonBody(query);
56
- const response = await this.asyncCaller.call(() => fetch(this.url, {
57
- method: "POST",
58
- headers: this.headers,
59
- body: JSON.stringify(body),
60
- }));
61
- if (!response.ok) {
62
- throw new Error(`Failed to retrieve documents from ${this.url}: ${response.status} ${response.statusText}`);
63
- }
64
- const json = await response.json();
65
- return this.processJsonResponse(json);
66
- }
67
- }
68
- exports.RemoteRetriever = RemoteRetriever;
@@ -1,60 +0,0 @@
1
- import { BaseRetriever, type BaseRetrieverInput } from "@langchain/core/retrievers";
2
- import { AsyncCaller, AsyncCallerParams } from "../../util/async_caller.js";
3
- import { Document } from "../../document.js";
4
- /**
5
- * Type for the authentication method used by the RemoteRetriever. It can
6
- * either be false (no authentication) or an object with a bearer token.
7
- */
8
- export type RemoteRetrieverAuth = false | {
9
- bearer: string;
10
- };
11
- /**
12
- * Type for the JSON response values from the remote server.
13
- */
14
- export type RemoteRetrieverValues = Record<string, any>;
15
- /**
16
- * Interface for the parameters required to initialize a RemoteRetriever
17
- * instance.
18
- */
19
- export interface RemoteRetrieverParams extends AsyncCallerParams, BaseRetrieverInput {
20
- /**
21
- * The URL of the remote retriever server
22
- */
23
- url: string;
24
- /**
25
- * The authentication method to use, currently implemented is
26
- * - false: no authentication
27
- * - { bearer: string }: Bearer token authentication
28
- */
29
- auth: RemoteRetrieverAuth;
30
- }
31
- /**
32
- * Abstract class for interacting with a remote server to retrieve
33
- * relevant documents based on a given query.
34
- */
35
- export declare abstract class RemoteRetriever extends BaseRetriever implements RemoteRetrieverParams {
36
- get lc_secrets(): {
37
- [key: string]: string;
38
- } | undefined;
39
- url: string;
40
- auth: RemoteRetrieverAuth;
41
- headers: Record<string, string>;
42
- asyncCaller: AsyncCaller;
43
- constructor(fields: RemoteRetrieverParams);
44
- /**
45
- * Abstract method that should be implemented by subclasses to create the
46
- * JSON body of the request based on the given query.
47
- * @param query The query based on which the JSON body of the request is created.
48
- * @returns The JSON body of the request.
49
- */
50
- abstract createJsonBody(query: string): RemoteRetrieverValues;
51
- /**
52
- * Abstract method that should be implemented by subclasses to process the
53
- * JSON response from the server and convert it into an array of Document
54
- * instances.
55
- * @param json The JSON response from the server.
56
- * @returns An array of Document instances.
57
- */
58
- abstract processJsonResponse(json: RemoteRetrieverValues): Document[];
59
- _getRelevantDocuments(query: string): Promise<Document[]>;
60
- }
@@ -1,64 +0,0 @@
1
- import { BaseRetriever, } from "@langchain/core/retrievers";
2
- import { AsyncCaller } from "../../util/async_caller.js";
3
- /**
4
- * Abstract class for interacting with a remote server to retrieve
5
- * relevant documents based on a given query.
6
- */
7
- export class RemoteRetriever extends BaseRetriever {
8
- get lc_secrets() {
9
- return {
10
- "auth.bearer": "REMOTE_RETRIEVER_AUTH_BEARER",
11
- };
12
- }
13
- constructor(fields) {
14
- super(fields);
15
- Object.defineProperty(this, "url", {
16
- enumerable: true,
17
- configurable: true,
18
- writable: true,
19
- value: void 0
20
- });
21
- Object.defineProperty(this, "auth", {
22
- enumerable: true,
23
- configurable: true,
24
- writable: true,
25
- value: void 0
26
- });
27
- Object.defineProperty(this, "headers", {
28
- enumerable: true,
29
- configurable: true,
30
- writable: true,
31
- value: void 0
32
- });
33
- Object.defineProperty(this, "asyncCaller", {
34
- enumerable: true,
35
- configurable: true,
36
- writable: true,
37
- value: void 0
38
- });
39
- const { url, auth, ...rest } = fields;
40
- this.url = url;
41
- this.auth = auth;
42
- this.headers = {
43
- Accept: "application/json",
44
- "Content-Type": "application/json",
45
- ...(this.auth && this.auth.bearer
46
- ? { Authorization: `Bearer ${this.auth.bearer}` }
47
- : {}),
48
- };
49
- this.asyncCaller = new AsyncCaller(rest);
50
- }
51
- async _getRelevantDocuments(query) {
52
- const body = this.createJsonBody(query);
53
- const response = await this.asyncCaller.call(() => fetch(this.url, {
54
- method: "POST",
55
- headers: this.headers,
56
- body: JSON.stringify(body),
57
- }));
58
- if (!response.ok) {
59
- throw new Error(`Failed to retrieve documents from ${this.url}: ${response.status} ${response.statusText}`);
60
- }
61
- const json = await response.json();
62
- return this.processJsonResponse(json);
63
- }
64
- }