langchain 0.3.27 → 0.3.29
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.
- package/dist/agents/agent.cjs +36 -3
- package/dist/agents/format_scratchpad/log.cjs +1 -2
- package/dist/agents/format_scratchpad/log_to_message.cjs +1 -2
- package/dist/agents/format_scratchpad/openai_functions.cjs +2 -3
- package/dist/agents/format_scratchpad/tool_calling.cjs +2 -3
- package/dist/agents/format_scratchpad/xml.cjs +1 -2
- package/dist/agents/initialize.cjs +2 -2
- package/dist/agents/openai_functions/index.cjs +3 -3
- package/dist/agents/openai_tools/index.cjs +2 -2
- package/dist/agents/react/index.cjs +1 -2
- package/dist/agents/structured_chat/index.cjs +6 -4
- package/dist/agents/structured_chat/index.js +5 -3
- package/dist/agents/structured_chat/prompt.d.ts +1 -1
- package/dist/agents/tool_calling/index.cjs +1 -2
- package/dist/agents/tool_calling/output_parser.cjs +2 -2
- package/dist/agents/toolkits/conversational_retrieval/openai_functions.cjs +1 -2
- package/dist/agents/toolkits/conversational_retrieval/tool.cjs +1 -2
- package/dist/agents/toolkits/json/json.cjs +2 -2
- package/dist/agents/toolkits/openapi/openapi.cjs +2 -2
- package/dist/agents/toolkits/sql/sql.cjs +2 -2
- package/dist/agents/toolkits/vectorstore/vectorstore.cjs +3 -3
- package/dist/agents/xml/index.cjs +2 -2
- package/dist/chains/api/prompts.d.ts +1 -1
- package/dist/chains/base.cjs +42 -9
- package/dist/chains/base.d.ts +2 -2
- package/dist/chains/base.js +1 -1
- package/dist/chains/combine_documents/base.cjs +2 -2
- package/dist/chains/combine_documents/reduce.cjs +2 -3
- package/dist/chains/combine_documents/stuff.cjs +1 -2
- package/dist/chains/history_aware_retriever.cjs +1 -2
- package/dist/chains/openai_functions/base.cjs +5 -6
- package/dist/chains/openai_functions/base.d.ts +3 -4
- package/dist/chains/openai_functions/base.js +4 -4
- package/dist/chains/openai_functions/extraction.cjs +6 -7
- package/dist/chains/openai_functions/extraction.d.ts +4 -4
- package/dist/chains/openai_functions/extraction.js +4 -4
- package/dist/chains/openai_functions/openapi.cjs +4 -5
- package/dist/chains/openai_functions/openapi.d.ts +1 -1
- package/dist/chains/openai_functions/openapi.js +1 -1
- package/dist/chains/openai_functions/structured_output.cjs +7 -7
- package/dist/chains/openai_functions/structured_output.d.ts +7 -8
- package/dist/chains/openai_functions/structured_output.js +5 -5
- package/dist/chains/openai_functions/tagging.cjs +4 -5
- package/dist/chains/openai_functions/tagging.d.ts +2 -2
- package/dist/chains/openai_functions/tagging.js +2 -2
- package/dist/chains/query_constructor/index.cjs +3 -3
- package/dist/chains/query_constructor/index.d.ts +2 -2
- package/dist/chains/question_answering/load.cjs +4 -4
- package/dist/chains/retrieval.cjs +1 -2
- package/dist/chains/router/utils.cjs +1 -2
- package/dist/chains/sequential_chain.cjs +2 -1
- package/dist/chains/sequential_chain.js +2 -1
- package/dist/chains/sql_db/sql_db_chain.cjs +2 -2
- package/dist/chat_models/universal.cjs +54 -21
- package/dist/document_loaders/fs/buffer.cjs +34 -1
- package/dist/document_loaders/fs/buffer.d.ts +0 -3
- package/dist/document_loaders/fs/directory.cjs +35 -2
- package/dist/document_loaders/fs/directory.d.ts +0 -2
- package/dist/document_loaders/fs/text.cjs +34 -1
- package/dist/document_loaders/fs/text.d.ts +0 -1
- package/dist/document_transformers/openai_functions.cjs +5 -5
- package/dist/document_transformers/openai_functions.d.ts +3 -3
- package/dist/document_transformers/openai_functions.js +2 -2
- package/dist/evaluation/embedding_distance/base.cjs +3 -3
- package/dist/evaluation/loader.cjs +1 -2
- package/dist/experimental/autogpt/output_parser.cjs +2 -2
- package/dist/experimental/autogpt/prompt_generator.cjs +4 -4
- package/dist/experimental/autogpt/prompt_generator.js +3 -3
- package/dist/experimental/generative_agents/generative_agent.cjs +1 -1
- package/dist/experimental/generative_agents/generative_agent.js +1 -1
- package/dist/experimental/openai_assistant/index.cjs +8 -4
- package/dist/experimental/openai_assistant/index.d.ts +6 -6
- package/dist/experimental/openai_assistant/index.js +9 -5
- package/dist/experimental/openai_files/index.cjs +2 -2
- package/dist/experimental/openai_files/index.d.ts +6 -4
- package/dist/experimental/openai_files/index.js +2 -2
- package/dist/experimental/plan_and_execute/agent_executor.cjs +2 -2
- package/dist/hub/base.cjs +4 -5
- package/dist/hub/index.cjs +2 -2
- package/dist/hub/node.cjs +43 -10
- package/dist/index.cjs +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -1
- package/dist/load/import_map.cjs +17 -7
- package/dist/load/index.cjs +18 -9
- package/dist/output_parsers/expression_type_handlers/base.cjs +34 -1
- package/dist/output_parsers/openai_functions.d.ts +1 -1
- package/dist/output_parsers/router.d.ts +3 -3
- package/dist/output_parsers/structured.cjs +6 -5
- package/dist/output_parsers/structured.d.ts +9 -8
- package/dist/output_parsers/structured.js +6 -5
- package/dist/prompts/index.cjs +0 -1
- package/dist/prompts/index.d.ts +0 -1
- package/dist/prompts/index.js +1 -1
- package/dist/retrievers/hyde.cjs +2 -2
- package/dist/retrievers/parent_document.cjs +17 -7
- package/dist/smith/config.cjs +5 -6
- package/dist/smith/name_generation.cjs +1 -2
- package/dist/smith/runner_utils.cjs +1 -2
- package/dist/sql_db.cjs +35 -2
- package/dist/storage/encoder_backed.cjs +2 -2
- package/dist/storage/encoder_backed.d.ts +1 -1
- package/dist/storage/file_system.cjs +17 -7
- package/dist/storage/file_system.d.ts +1 -1
- package/dist/stores/file/node.cjs +17 -7
- package/dist/tools/convert_to_openai.cjs +5 -5
- package/dist/tools/convert_to_openai.js +4 -4
- package/dist/tools/fs.d.ts +3 -2
- package/dist/tools/render.cjs +6 -5
- package/dist/tools/render.js +5 -3
- package/dist/tools/retriever.cjs +1 -2
- package/dist/tools/webbrowser.cjs +17 -7
- package/dist/util/axios-fetch-adapter.cjs +1 -1
- package/dist/util/azure.cjs +1 -2
- package/dist/util/entrypoint_deprecation.cjs +2 -3
- package/dist/util/load.cjs +34 -1
- package/dist/util/ml-distance/distances.cjs +3 -4
- package/dist/util/ml-distance/similarities.cjs +1 -2
- package/dist/util/ml-distance-euclidean/euclidean.cjs +2 -3
- package/dist/util/openapi.cjs +17 -7
- package/dist/util/openapi.d.ts +32 -32
- package/dist/util/parse.cjs +17 -7
- package/dist/util/prompt-layer.d.ts +1 -1
- package/dist/util/set.cjs +3 -4
- package/dist/util/time.cjs +1 -2
- package/package.json +8 -9
package/dist/agents/agent.cjs
CHANGED
|
@@ -1,6 +1,40 @@
|
|
|
1
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Agent = exports.LLMSingleActionAgent = exports.RunnableAgent = exports.RunnableMultiActionAgent = exports.RunnableSingleActionAgent = exports.AgentRunnableSequence = exports.
|
|
36
|
+
exports.Agent = exports.LLMSingleActionAgent = exports.RunnableAgent = exports.RunnableMultiActionAgent = exports.RunnableSingleActionAgent = exports.AgentRunnableSequence = exports.BaseMultiActionAgent = exports.BaseSingleActionAgent = exports.BaseAgent = void 0;
|
|
37
|
+
exports.isRunnableAgent = isRunnableAgent;
|
|
4
38
|
const serializable_1 = require("@langchain/core/load/serializable");
|
|
5
39
|
const runnables_1 = require("@langchain/core/runnables");
|
|
6
40
|
/**
|
|
@@ -85,7 +119,6 @@ function isRunnableAgent(x) {
|
|
|
85
119
|
return (x.runnable !==
|
|
86
120
|
undefined);
|
|
87
121
|
}
|
|
88
|
-
exports.isRunnableAgent = isRunnableAgent;
|
|
89
122
|
// TODO: Remove in the future. Only for backwards compatibility.
|
|
90
123
|
// Allows for the creation of runnables with properties that will
|
|
91
124
|
// be passed to the agent executor constructor.
|
|
@@ -526,7 +559,7 @@ class Agent extends BaseSingleActionAgent {
|
|
|
526
559
|
static async deserialize(data) {
|
|
527
560
|
switch (data._type) {
|
|
528
561
|
case "zero-shot-react-description": {
|
|
529
|
-
const { ZeroShotAgent } = await
|
|
562
|
+
const { ZeroShotAgent } = await Promise.resolve().then(() => __importStar(require("./mrkl/index.cjs")));
|
|
530
563
|
return ZeroShotAgent.deserialize(data);
|
|
531
564
|
}
|
|
532
565
|
default:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formatLogToString =
|
|
3
|
+
exports.formatLogToString = formatLogToString;
|
|
4
4
|
/**
|
|
5
5
|
* Construct the scratchpad that lets the agent continue its thought process.
|
|
6
6
|
* @param intermediateSteps
|
|
@@ -13,4 +13,3 @@ function formatLogToString(intermediateSteps, observationPrefix = "Observation:
|
|
|
13
13
|
[action.log, `\n${observationPrefix}${observation}`, llmPrefix].join("\n"), "");
|
|
14
14
|
return formattedSteps;
|
|
15
15
|
}
|
|
16
|
-
exports.formatLogToString = formatLogToString;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formatLogToMessage =
|
|
3
|
+
exports.formatLogToMessage = formatLogToMessage;
|
|
4
4
|
const messages_1 = require("@langchain/core/messages");
|
|
5
5
|
const prompts_1 = require("@langchain/core/prompts");
|
|
6
6
|
function formatLogToMessage(intermediateSteps, templateToolResponse = "{observation}") {
|
|
@@ -19,4 +19,3 @@ function formatLogToMessage(intermediateSteps, templateToolResponse = "{observat
|
|
|
19
19
|
}
|
|
20
20
|
return thoughts;
|
|
21
21
|
}
|
|
22
|
-
exports.formatLogToMessage = formatLogToMessage;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.formatForOpenAIFunctions = formatForOpenAIFunctions;
|
|
4
|
+
exports.formatToOpenAIFunctionMessages = formatToOpenAIFunctionMessages;
|
|
4
5
|
const messages_1 = require("@langchain/core/messages");
|
|
5
6
|
const prompts_1 = require("@langchain/core/prompts");
|
|
6
7
|
const prompt_js_1 = require("../chat_convo/prompt.cjs");
|
|
@@ -23,7 +24,6 @@ function formatForOpenAIFunctions(steps) {
|
|
|
23
24
|
}
|
|
24
25
|
return thoughts;
|
|
25
26
|
}
|
|
26
|
-
exports.formatForOpenAIFunctions = formatForOpenAIFunctions;
|
|
27
27
|
/**
|
|
28
28
|
* Format a list of AgentSteps into a list of BaseMessage instances for
|
|
29
29
|
* agents that use OpenAI's API. Helpful for passing in previous agent
|
|
@@ -43,4 +43,3 @@ function formatToOpenAIFunctionMessages(steps) {
|
|
|
43
43
|
}
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
|
-
exports.formatToOpenAIFunctionMessages = formatToOpenAIFunctionMessages;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports._createToolMessage = _createToolMessage;
|
|
4
|
+
exports.formatToToolMessages = formatToToolMessages;
|
|
4
5
|
const messages_1 = require("@langchain/core/messages");
|
|
5
6
|
/**
|
|
6
7
|
* Convert agent action and observation into a function message.
|
|
@@ -15,7 +16,6 @@ function _createToolMessage(step) {
|
|
|
15
16
|
additional_kwargs: { name: step.action.tool },
|
|
16
17
|
});
|
|
17
18
|
}
|
|
18
|
-
exports._createToolMessage = _createToolMessage;
|
|
19
19
|
function formatToToolMessages(steps) {
|
|
20
20
|
return steps.flatMap(({ action, observation }) => {
|
|
21
21
|
if ("messageLog" in action && action.messageLog !== undefined) {
|
|
@@ -27,4 +27,3 @@ function formatToToolMessages(steps) {
|
|
|
27
27
|
}
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
|
-
exports.formatToToolMessages = formatToToolMessages;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formatXml =
|
|
3
|
+
exports.formatXml = formatXml;
|
|
4
4
|
function formatXml(intermediateSteps) {
|
|
5
5
|
let log = "";
|
|
6
6
|
for (const step of intermediateSteps) {
|
|
@@ -9,4 +9,3 @@ function formatXml(intermediateSteps) {
|
|
|
9
9
|
}
|
|
10
10
|
return log;
|
|
11
11
|
}
|
|
12
|
-
exports.formatXml = formatXml;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.initializeAgentExecutor = void 0;
|
|
4
|
+
exports.initializeAgentExecutorWithOptions = initializeAgentExecutorWithOptions;
|
|
4
5
|
const buffer_memory_js_1 = require("../memory/buffer_memory.cjs");
|
|
5
6
|
const index_js_1 = require("./chat/index.cjs");
|
|
6
7
|
const index_js_2 = require("./chat_convo/index.cjs");
|
|
@@ -133,4 +134,3 @@ async function initializeAgentExecutorWithOptions(tools, llm, options = {
|
|
|
133
134
|
}
|
|
134
135
|
}
|
|
135
136
|
}
|
|
136
|
-
exports.initializeAgentExecutorWithOptions = initializeAgentExecutorWithOptions;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.OpenAIAgent = void 0;
|
|
4
|
+
exports._formatIntermediateSteps = _formatIntermediateSteps;
|
|
5
|
+
exports.createOpenAIFunctionsAgent = createOpenAIFunctionsAgent;
|
|
4
6
|
const runnables_1 = require("@langchain/core/runnables");
|
|
5
7
|
const function_calling_1 = require("@langchain/core/utils/function_calling");
|
|
6
8
|
const messages_1 = require("@langchain/core/messages");
|
|
@@ -29,7 +31,6 @@ function _convertAgentStepToMessages(action, observation) {
|
|
|
29
31
|
function _formatIntermediateSteps(intermediateSteps) {
|
|
30
32
|
return intermediateSteps.flatMap(({ action, observation }) => _convertAgentStepToMessages(action, observation));
|
|
31
33
|
}
|
|
32
|
-
exports._formatIntermediateSteps = _formatIntermediateSteps;
|
|
33
34
|
/**
|
|
34
35
|
* Class representing an agent for the OpenAI chat model in LangChain. It
|
|
35
36
|
* extends the Agent class and provides additional functionality specific
|
|
@@ -245,4 +246,3 @@ async function createOpenAIFunctionsAgent({ llm, tools, prompt, streamRunnable,
|
|
|
245
246
|
});
|
|
246
247
|
return agent;
|
|
247
248
|
}
|
|
248
|
-
exports.createOpenAIFunctionsAgent = createOpenAIFunctionsAgent;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.OpenAIToolsAgentOutputParser = void 0;
|
|
4
|
+
exports.createOpenAIToolsAgent = createOpenAIToolsAgent;
|
|
4
5
|
const runnables_1 = require("@langchain/core/runnables");
|
|
5
6
|
const function_calling_1 = require("@langchain/core/utils/function_calling");
|
|
6
7
|
const openai_tools_js_1 = require("../format_scratchpad/openai_tools.cjs");
|
|
@@ -89,4 +90,3 @@ async function createOpenAIToolsAgent({ llm, tools, prompt, streamRunnable, }) {
|
|
|
89
90
|
});
|
|
90
91
|
return agent;
|
|
91
92
|
}
|
|
92
|
-
exports.createOpenAIToolsAgent = createOpenAIToolsAgent;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createReactAgent =
|
|
3
|
+
exports.createReactAgent = createReactAgent;
|
|
4
4
|
const runnables_1 = require("@langchain/core/runnables");
|
|
5
5
|
const render_js_1 = require("../../tools/render.cjs");
|
|
6
6
|
const log_js_1 = require("../format_scratchpad/log.cjs");
|
|
@@ -78,4 +78,3 @@ async function createReactAgent({ llm, tools, prompt, streamRunnable, }) {
|
|
|
78
78
|
});
|
|
79
79
|
return agent;
|
|
80
80
|
}
|
|
81
|
-
exports.createReactAgent = createReactAgent;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.StructuredChatAgent = void 0;
|
|
4
|
+
exports.createStructuredChatAgent = createStructuredChatAgent;
|
|
4
5
|
const base_1 = require("@langchain/core/language_models/base");
|
|
5
6
|
const runnables_1 = require("@langchain/core/runnables");
|
|
6
7
|
const prompts_1 = require("@langchain/core/prompts");
|
|
7
8
|
const function_calling_1 = require("@langchain/core/utils/function_calling");
|
|
8
|
-
const zod_to_json_schema_1 = require("zod-to-json-schema");
|
|
9
9
|
const types_1 = require("@langchain/core/utils/types");
|
|
10
|
+
const json_schema_1 = require("@langchain/core/utils/json_schema");
|
|
10
11
|
const llm_chain_js_1 = require("../../chains/llm_chain.cjs");
|
|
11
12
|
const agent_js_1 = require("../agent.cjs");
|
|
12
13
|
const outputParser_js_1 = require("./outputParser.cjs");
|
|
@@ -95,7 +96,9 @@ class StructuredChatAgent extends agent_js_1.Agent {
|
|
|
95
96
|
static createToolSchemasString(tools) {
|
|
96
97
|
return tools
|
|
97
98
|
.map((tool) => {
|
|
98
|
-
const jsonSchema = ((0, types_1.
|
|
99
|
+
const jsonSchema = ((0, types_1.isInteropZodSchema)(tool.schema)
|
|
100
|
+
? (0, json_schema_1.toJsonSchema)(tool.schema)
|
|
101
|
+
: tool.schema);
|
|
99
102
|
return `${tool.name}: ${tool.description}, args: ${JSON.stringify(jsonSchema?.properties)}`;
|
|
100
103
|
})
|
|
101
104
|
.join("\n");
|
|
@@ -255,4 +258,3 @@ async function createStructuredChatAgent({ llm, tools, prompt, streamRunnable, }
|
|
|
255
258
|
});
|
|
256
259
|
return agent;
|
|
257
260
|
}
|
|
258
|
-
exports.createStructuredChatAgent = createStructuredChatAgent;
|
|
@@ -2,8 +2,8 @@ import { isOpenAITool, } from "@langchain/core/language_models/base";
|
|
|
2
2
|
import { RunnablePassthrough } from "@langchain/core/runnables";
|
|
3
3
|
import { ChatPromptTemplate, HumanMessagePromptTemplate, SystemMessagePromptTemplate, PromptTemplate, } from "@langchain/core/prompts";
|
|
4
4
|
import { isStructuredTool } from "@langchain/core/utils/function_calling";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { isInteropZodSchema } from "@langchain/core/utils/types";
|
|
6
|
+
import { toJsonSchema, } from "@langchain/core/utils/json_schema";
|
|
7
7
|
import { LLMChain } from "../../chains/llm_chain.js";
|
|
8
8
|
import { Agent, AgentRunnableSequence, } from "../agent.js";
|
|
9
9
|
import { StructuredChatOutputParserWithRetries } from "./outputParser.js";
|
|
@@ -92,7 +92,9 @@ export class StructuredChatAgent extends Agent {
|
|
|
92
92
|
static createToolSchemasString(tools) {
|
|
93
93
|
return tools
|
|
94
94
|
.map((tool) => {
|
|
95
|
-
const jsonSchema = (
|
|
95
|
+
const jsonSchema = (isInteropZodSchema(tool.schema)
|
|
96
|
+
? toJsonSchema(tool.schema)
|
|
97
|
+
: tool.schema);
|
|
96
98
|
return `${tool.name}: ${tool.description}, args: ${JSON.stringify(jsonSchema?.properties)}`;
|
|
97
99
|
})
|
|
98
100
|
.join("\n");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const PREFIX = "Answer the following questions truthfully and as best you can.";
|
|
2
2
|
export declare const AGENT_ACTION_FORMAT_INSTRUCTIONS = "Output a JSON markdown code snippet containing a valid JSON blob (denoted below by $JSON_BLOB).\nThis $JSON_BLOB must have a \"action\" key (with the name of the tool to use) and an \"action_input\" key (tool input).\n\nValid \"action\" values: \"Final Answer\" (which you must use when giving your final response to the user), or one of [{tool_names}].\n\nThe $JSON_BLOB must be valid, parseable JSON and only contain a SINGLE action. Here is an example of an acceptable output:\n\n```json\n{{\n \"action\": $TOOL_NAME,\n \"action_input\": $INPUT\n}}\n```\n\nRemember to include the surrounding markdown code snippet delimiters (begin with \"```\" json and close with \"```\")!\n";
|
|
3
|
-
export declare const FORMAT_INSTRUCTIONS: string;
|
|
3
|
+
export declare const FORMAT_INSTRUCTIONS = "You have access to the following tools.\nYou must format your inputs to these tools to match their \"JSON schema\" definitions below.\n\n\"JSON Schema\" is a declarative language that allows you to annotate and validate JSON documents.\n\nFor example, the example \"JSON Schema\" instance {{\"properties\": {{\"foo\": {{\"description\": \"a list of test words\", \"type\": \"array\", \"items\": {{\"type\": \"string\"}}}}}}, \"required\": [\"foo\"]}}}}\nwould match an object with one required property, \"foo\". The \"type\" property specifies \"foo\" must be an \"array\", and the \"description\" property semantically describes it as \"a list of test words\". The items within \"foo\" must be strings.\nThus, the object {{\"foo\": [\"bar\", \"baz\"]}} is a well-formatted instance of this example \"JSON Schema\". The object {{\"properties\": {{\"foo\": [\"bar\", \"baz\"]}}}} is not well-formatted.\n\nHere are the JSON Schema instances for the tools you have access to:\n\n{tool_schemas}\n\nThe way you use the tools is as follows:\n\n------------------------\n\nOutput a JSON markdown code snippet containing a valid JSON blob (denoted below by $JSON_BLOB).\nThis $JSON_BLOB must have a \"action\" key (with the name of the tool to use) and an \"action_input\" key (tool input).\n\nValid \"action\" values: \"Final Answer\" (which you must use when giving your final response to the user), or one of [{tool_names}].\n\nThe $JSON_BLOB must be valid, parseable JSON and only contain a SINGLE action. Here is an example of an acceptable output:\n\n```json\n{{\n \"action\": $TOOL_NAME,\n \"action_input\": $INPUT\n}}\n```\n\nRemember to include the surrounding markdown code snippet delimiters (begin with \"```\" json and close with \"```\")!\n\n\nIf you are using a tool, \"action_input\" must adhere to the tool's input schema, given above.\n\n------------------------\n\nALWAYS use the following format:\n\nQuestion: the input question you must answer\nThought: you should always think about what to do\nAction:\n```json\n$JSON_BLOB\n```\nObservation: the result of the action\n... (this Thought/Action/Observation can repeat N times)\nThought: I now know the final answer\nAction:\n```json\n{{\n \"action\": \"Final Answer\",\n \"action_input\": \"Final response to human\"\n}}\n```";
|
|
4
4
|
export declare const SUFFIX = "Begin! Reminder to ALWAYS use the above format, and to use tools if appropriate.";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createToolCallingAgent =
|
|
3
|
+
exports.createToolCallingAgent = createToolCallingAgent;
|
|
4
4
|
const runnables_1 = require("@langchain/core/runnables");
|
|
5
5
|
const agent_js_1 = require("../agent.cjs");
|
|
6
6
|
const output_parser_js_1 = require("./output_parser.cjs");
|
|
@@ -91,4 +91,3 @@ function createToolCallingAgent({ llm, tools, prompt, streamRunnable, }) {
|
|
|
91
91
|
});
|
|
92
92
|
return agent;
|
|
93
93
|
}
|
|
94
|
-
exports.createToolCallingAgent = createToolCallingAgent;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ToolCallingAgentOutputParser =
|
|
3
|
+
exports.ToolCallingAgentOutputParser = void 0;
|
|
4
|
+
exports.parseAIMessageToToolAction = parseAIMessageToToolAction;
|
|
4
5
|
const messages_1 = require("@langchain/core/messages");
|
|
5
6
|
const output_parsers_1 = require("@langchain/core/output_parsers");
|
|
6
7
|
const types_js_1 = require("../types.cjs");
|
|
@@ -45,7 +46,6 @@ function parseAIMessageToToolAction(message) {
|
|
|
45
46
|
};
|
|
46
47
|
});
|
|
47
48
|
}
|
|
48
|
-
exports.parseAIMessageToToolAction = parseAIMessageToToolAction;
|
|
49
49
|
class ToolCallingAgentOutputParser extends types_js_1.AgentMultiActionOutputParser {
|
|
50
50
|
constructor() {
|
|
51
51
|
super(...arguments);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createConversationalRetrievalAgent =
|
|
3
|
+
exports.createConversationalRetrievalAgent = createConversationalRetrievalAgent;
|
|
4
4
|
const summary_buffer_js_1 = require("../../../memory/summary_buffer.cjs");
|
|
5
5
|
const initialize_js_1 = require("../../initialize.cjs");
|
|
6
6
|
const token_buffer_memory_js_1 = require("./token_buffer_memory.cjs");
|
|
@@ -47,4 +47,3 @@ async function createConversationalRetrievalAgent(llm, tools, options) {
|
|
|
47
47
|
});
|
|
48
48
|
return executor;
|
|
49
49
|
}
|
|
50
|
-
exports.createConversationalRetrievalAgent = createConversationalRetrievalAgent;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createRetrieverTool =
|
|
3
|
+
exports.createRetrieverTool = createRetrieverTool;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const tools_1 = require("@langchain/core/tools");
|
|
6
6
|
const document_js_1 = require("../../../util/document.cjs");
|
|
@@ -17,4 +17,3 @@ function createRetrieverTool(retriever, input) {
|
|
|
17
17
|
});
|
|
18
18
|
return new tools_1.DynamicStructuredTool({ ...input, func, schema });
|
|
19
19
|
}
|
|
20
|
-
exports.createRetrieverTool = createRetrieverTool;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.JsonToolkit = void 0;
|
|
4
|
+
exports.createJsonAgent = createJsonAgent;
|
|
4
5
|
const tools_1 = require("@langchain/core/tools");
|
|
5
6
|
const json_js_1 = require("../../../tools/json.cjs");
|
|
6
7
|
const prompt_js_1 = require("./prompt.cjs");
|
|
@@ -73,4 +74,3 @@ function createJsonAgent(llm, toolkit, args) {
|
|
|
73
74
|
returnIntermediateSteps: true,
|
|
74
75
|
});
|
|
75
76
|
}
|
|
76
|
-
exports.createJsonAgent = createJsonAgent;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.OpenApiToolkit = exports.RequestsToolkit = void 0;
|
|
4
|
+
exports.createOpenApiAgent = createOpenApiAgent;
|
|
4
5
|
const tools_1 = require("@langchain/core/tools");
|
|
5
6
|
const executor_js_1 = require("../../executor.cjs");
|
|
6
7
|
const prompt_js_1 = require("./prompt.cjs");
|
|
@@ -108,4 +109,3 @@ function createOpenApiAgent(llm, openApiToolkit, args) {
|
|
|
108
109
|
returnIntermediateSteps: true,
|
|
109
110
|
});
|
|
110
111
|
}
|
|
111
|
-
exports.createOpenApiAgent = createOpenApiAgent;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.SqlToolkit = void 0;
|
|
4
|
+
exports.createSqlAgent = createSqlAgent;
|
|
4
5
|
const tools_1 = require("@langchain/core/tools");
|
|
5
6
|
const prompts_1 = require("@langchain/core/prompts");
|
|
6
7
|
const sql_js_1 = require("../../../tools/sql.cjs");
|
|
@@ -74,4 +75,3 @@ function createSqlAgent(llm, toolkit, args) {
|
|
|
74
75
|
returnIntermediateSteps: true,
|
|
75
76
|
});
|
|
76
77
|
}
|
|
77
|
-
exports.createSqlAgent = createSqlAgent;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.VectorStoreRouterToolkit = exports.VectorStoreToolkit = void 0;
|
|
4
|
+
exports.createVectorStoreAgent = createVectorStoreAgent;
|
|
5
|
+
exports.createVectorStoreRouterAgent = createVectorStoreRouterAgent;
|
|
4
6
|
const tools_1 = require("@langchain/core/tools");
|
|
5
7
|
const vectorstore_js_1 = require("../../../tools/vectorstore.cjs");
|
|
6
8
|
const index_js_1 = require("../../mrkl/index.cjs");
|
|
@@ -113,7 +115,6 @@ function createVectorStoreAgent(llm, toolkit, args) {
|
|
|
113
115
|
returnIntermediateSteps: true,
|
|
114
116
|
});
|
|
115
117
|
}
|
|
116
|
-
exports.createVectorStoreAgent = createVectorStoreAgent;
|
|
117
118
|
/** @deprecated Create a specific agent with a custom tool instead. */
|
|
118
119
|
function createVectorStoreRouterAgent(llm, toolkit, args) {
|
|
119
120
|
const { prefix = prompt_js_1.VECTOR_ROUTER_PREFIX, suffix = prompt_js_2.SUFFIX, inputVariables = ["input", "agent_scratchpad"], } = args ?? {};
|
|
@@ -134,4 +135,3 @@ function createVectorStoreRouterAgent(llm, toolkit, args) {
|
|
|
134
135
|
returnIntermediateSteps: true,
|
|
135
136
|
});
|
|
136
137
|
}
|
|
137
|
-
exports.createVectorStoreRouterAgent = createVectorStoreRouterAgent;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.XMLAgent = void 0;
|
|
4
|
+
exports.createXmlAgent = createXmlAgent;
|
|
4
5
|
const runnables_1 = require("@langchain/core/runnables");
|
|
5
6
|
const prompts_1 = require("@langchain/core/prompts");
|
|
6
7
|
const llm_chain_js_1 = require("../../chains/llm_chain.cjs");
|
|
@@ -182,4 +183,3 @@ async function createXmlAgent({ llm, tools, prompt, streamRunnable, }) {
|
|
|
182
183
|
});
|
|
183
184
|
return agent;
|
|
184
185
|
}
|
|
185
|
-
exports.createXmlAgent = createXmlAgent;
|
|
@@ -4,7 +4,7 @@ export declare const API_URL_PROMPT_TEMPLATE: PromptTemplate<{
|
|
|
4
4
|
question: any;
|
|
5
5
|
api_docs: any;
|
|
6
6
|
}, any>;
|
|
7
|
-
export declare const API_RESPONSE_RAW_PROMPT_TEMPLATE:
|
|
7
|
+
export declare const API_RESPONSE_RAW_PROMPT_TEMPLATE = "You are given the below API Documentation:\n{api_docs}\nUsing this documentation, generate the full API url to call for answering the user question.\nYou should build the API url in order to get a response that is as short as possible, while still getting the necessary information to answer the question. Pay attention to deliberately exclude any unnecessary pieces of data in the API call.\n\nQuestion:{question}\nAPI url: {api_url}\n\nHere is the response from the API:\n\n{api_response}\n\nSummarize this response to answer the original question.\n\nSummary:";
|
|
8
8
|
export declare const API_RESPONSE_PROMPT_TEMPLATE: PromptTemplate<{
|
|
9
9
|
question: any;
|
|
10
10
|
api_docs: any;
|
package/dist/chains/base.cjs
CHANGED
|
@@ -1,4 +1,37 @@
|
|
|
1
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.BaseChain = void 0;
|
|
4
37
|
const outputs_1 = require("@langchain/core/outputs");
|
|
@@ -107,7 +140,7 @@ class BaseChain extends base_1.BaseLangChain {
|
|
|
107
140
|
async run(
|
|
108
141
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
109
142
|
input, config) {
|
|
110
|
-
const inputKeys = this.inputKeys.filter((k) => !this.memory?.memoryKeys.includes(k)
|
|
143
|
+
const inputKeys = this.inputKeys.filter((k) => !this.memory?.memoryKeys.includes(k));
|
|
111
144
|
const isKeylessInput = inputKeys.length <= 1;
|
|
112
145
|
if (!isKeylessInput) {
|
|
113
146
|
throw new Error(`Chain ${this._chainType()} expects multiple inputs, cannot use 'run' `);
|
|
@@ -162,35 +195,35 @@ class BaseChain extends base_1.BaseLangChain {
|
|
|
162
195
|
static async deserialize(data, values = {}) {
|
|
163
196
|
switch (data._type) {
|
|
164
197
|
case "llm_chain": {
|
|
165
|
-
const { LLMChain } = await
|
|
198
|
+
const { LLMChain } = await Promise.resolve().then(() => __importStar(require("./llm_chain.cjs")));
|
|
166
199
|
return LLMChain.deserialize(data);
|
|
167
200
|
}
|
|
168
201
|
case "sequential_chain": {
|
|
169
|
-
const { SequentialChain } = await
|
|
202
|
+
const { SequentialChain } = await Promise.resolve().then(() => __importStar(require("./sequential_chain.cjs")));
|
|
170
203
|
return SequentialChain.deserialize(data);
|
|
171
204
|
}
|
|
172
205
|
case "simple_sequential_chain": {
|
|
173
|
-
const { SimpleSequentialChain } = await
|
|
206
|
+
const { SimpleSequentialChain } = await Promise.resolve().then(() => __importStar(require("./sequential_chain.cjs")));
|
|
174
207
|
return SimpleSequentialChain.deserialize(data);
|
|
175
208
|
}
|
|
176
209
|
case "stuff_documents_chain": {
|
|
177
|
-
const { StuffDocumentsChain } = await
|
|
210
|
+
const { StuffDocumentsChain } = await Promise.resolve().then(() => __importStar(require("./combine_docs_chain.cjs")));
|
|
178
211
|
return StuffDocumentsChain.deserialize(data);
|
|
179
212
|
}
|
|
180
213
|
case "map_reduce_documents_chain": {
|
|
181
|
-
const { MapReduceDocumentsChain } = await
|
|
214
|
+
const { MapReduceDocumentsChain } = await Promise.resolve().then(() => __importStar(require("./combine_docs_chain.cjs")));
|
|
182
215
|
return MapReduceDocumentsChain.deserialize(data);
|
|
183
216
|
}
|
|
184
217
|
case "refine_documents_chain": {
|
|
185
|
-
const { RefineDocumentsChain } = await
|
|
218
|
+
const { RefineDocumentsChain } = await Promise.resolve().then(() => __importStar(require("./combine_docs_chain.cjs")));
|
|
186
219
|
return RefineDocumentsChain.deserialize(data);
|
|
187
220
|
}
|
|
188
221
|
case "vector_db_qa": {
|
|
189
|
-
const { VectorDBQAChain } = await
|
|
222
|
+
const { VectorDBQAChain } = await Promise.resolve().then(() => __importStar(require("./vector_db_qa.cjs")));
|
|
190
223
|
return VectorDBQAChain.deserialize(data, values);
|
|
191
224
|
}
|
|
192
225
|
case "api_chain": {
|
|
193
|
-
const { APIChain } = await
|
|
226
|
+
const { APIChain } = await Promise.resolve().then(() => __importStar(require("./api/api_chain.cjs")));
|
|
194
227
|
return APIChain.deserialize(data);
|
|
195
228
|
}
|
|
196
229
|
default:
|
package/dist/chains/base.d.ts
CHANGED
|
@@ -54,8 +54,8 @@ export declare abstract class BaseChain<RunInput extends ChainValues = ChainValu
|
|
|
54
54
|
signal?: AbortSignal;
|
|
55
55
|
timeout?: number;
|
|
56
56
|
}): Promise<ChainValues & {
|
|
57
|
-
signal?: AbortSignal
|
|
58
|
-
timeout?: number
|
|
57
|
+
signal?: AbortSignal;
|
|
58
|
+
timeout?: number;
|
|
59
59
|
}>;
|
|
60
60
|
/**
|
|
61
61
|
* @deprecated Use .invoke() instead. Will be removed in 0.2.0.
|
package/dist/chains/base.js
CHANGED
|
@@ -104,7 +104,7 @@ export class BaseChain extends BaseLangChain {
|
|
|
104
104
|
async run(
|
|
105
105
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
106
106
|
input, config) {
|
|
107
|
-
const inputKeys = this.inputKeys.filter((k) => !this.memory?.memoryKeys.includes(k)
|
|
107
|
+
const inputKeys = this.inputKeys.filter((k) => !this.memory?.memoryKeys.includes(k));
|
|
108
108
|
const isKeylessInput = inputKeys.length <= 1;
|
|
109
109
|
if (!isKeylessInput) {
|
|
110
110
|
throw new Error(`Chain ${this._chainType()} expects multiple inputs, cannot use 'run' `);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.DEFAULT_DOCUMENT_PROMPT = exports.INTERMEDIATE_STEPS_KEY = exports.DOCUMENTS_KEY = exports.DEFAULT_DOCUMENT_SEPARATOR = void 0;
|
|
4
|
+
exports.formatDocuments = formatDocuments;
|
|
4
5
|
const prompts_1 = require("@langchain/core/prompts");
|
|
5
6
|
exports.DEFAULT_DOCUMENT_SEPARATOR = "\n\n";
|
|
6
7
|
exports.DOCUMENTS_KEY = "context";
|
|
@@ -16,4 +17,3 @@ async function formatDocuments({ documentPrompt, documentSeparator, documents, c
|
|
|
16
17
|
.invoke({ ...document.metadata, page_content: document.pageContent }, config)));
|
|
17
18
|
return formattedDocs.join(documentSeparator);
|
|
18
19
|
}
|
|
19
|
-
exports.formatDocuments = formatDocuments;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.splitListOfDocs = splitListOfDocs;
|
|
4
|
+
exports.collapseDocs = collapseDocs;
|
|
4
5
|
/**
|
|
5
6
|
* Splits a list of documents into sublists based on a maximum token limit.
|
|
6
7
|
*
|
|
@@ -31,7 +32,6 @@ lengthFunc, tokenMax) {
|
|
|
31
32
|
newResultDocList.push(subResultDocs);
|
|
32
33
|
return newResultDocList;
|
|
33
34
|
}
|
|
34
|
-
exports.splitListOfDocs = splitListOfDocs;
|
|
35
35
|
/**
|
|
36
36
|
* Collapses a list of documents into a single document.
|
|
37
37
|
*
|
|
@@ -50,7 +50,6 @@ async function collapseDocs(docs, combineDocumentFunc) {
|
|
|
50
50
|
const result = await combineDocumentFunc(docs);
|
|
51
51
|
return { pageContent: result, metadata: collapseDocsMetadata(docs) };
|
|
52
52
|
}
|
|
53
|
-
exports.collapseDocs = collapseDocs;
|
|
54
53
|
function collapseDocsMetadata(docs) {
|
|
55
54
|
const combinedMetadata = {};
|
|
56
55
|
for (const key in docs[0].metadata) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createStuffDocumentsChain =
|
|
3
|
+
exports.createStuffDocumentsChain = createStuffDocumentsChain;
|
|
4
4
|
const output_parsers_1 = require("@langchain/core/output_parsers");
|
|
5
5
|
const runnables_1 = require("@langchain/core/runnables");
|
|
6
6
|
const base_js_1 = require("./base.cjs");
|
|
@@ -39,4 +39,3 @@ async function createStuffDocumentsChain({ llm, prompt, outputParser = new outpu
|
|
|
39
39
|
outputParser,
|
|
40
40
|
], "stuff_documents_chain");
|
|
41
41
|
}
|
|
42
|
-
exports.createStuffDocumentsChain = createStuffDocumentsChain;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createHistoryAwareRetriever =
|
|
3
|
+
exports.createHistoryAwareRetriever = createHistoryAwareRetriever;
|
|
4
4
|
const runnables_1 = require("@langchain/core/runnables");
|
|
5
5
|
const output_parsers_1 = require("@langchain/core/output_parsers");
|
|
6
6
|
/**
|
|
@@ -51,4 +51,3 @@ async function createHistoryAwareRetriever({ llm, retriever, rephrasePrompt, })
|
|
|
51
51
|
});
|
|
52
52
|
return retrieveDocuments;
|
|
53
53
|
}
|
|
54
|
-
exports.createHistoryAwareRetriever = createHistoryAwareRetriever;
|