langchain 0.3.28 → 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.
Files changed (104) hide show
  1. package/dist/agents/agent.cjs +36 -3
  2. package/dist/agents/format_scratchpad/log.cjs +1 -2
  3. package/dist/agents/format_scratchpad/log_to_message.cjs +1 -2
  4. package/dist/agents/format_scratchpad/openai_functions.cjs +2 -3
  5. package/dist/agents/format_scratchpad/tool_calling.cjs +2 -3
  6. package/dist/agents/format_scratchpad/xml.cjs +1 -2
  7. package/dist/agents/initialize.cjs +2 -2
  8. package/dist/agents/openai_functions/index.cjs +3 -3
  9. package/dist/agents/openai_tools/index.cjs +2 -2
  10. package/dist/agents/react/index.cjs +1 -2
  11. package/dist/agents/structured_chat/index.cjs +2 -2
  12. package/dist/agents/structured_chat/prompt.d.ts +1 -1
  13. package/dist/agents/tool_calling/index.cjs +1 -2
  14. package/dist/agents/tool_calling/output_parser.cjs +2 -2
  15. package/dist/agents/toolkits/conversational_retrieval/openai_functions.cjs +1 -2
  16. package/dist/agents/toolkits/conversational_retrieval/tool.cjs +1 -2
  17. package/dist/agents/toolkits/json/json.cjs +2 -2
  18. package/dist/agents/toolkits/openapi/openapi.cjs +2 -2
  19. package/dist/agents/toolkits/sql/sql.cjs +2 -2
  20. package/dist/agents/toolkits/vectorstore/vectorstore.cjs +3 -3
  21. package/dist/agents/xml/index.cjs +2 -2
  22. package/dist/chains/api/prompts.d.ts +1 -1
  23. package/dist/chains/base.cjs +42 -9
  24. package/dist/chains/base.d.ts +2 -2
  25. package/dist/chains/base.js +1 -1
  26. package/dist/chains/combine_documents/base.cjs +2 -2
  27. package/dist/chains/combine_documents/reduce.cjs +2 -3
  28. package/dist/chains/combine_documents/stuff.cjs +1 -2
  29. package/dist/chains/history_aware_retriever.cjs +1 -2
  30. package/dist/chains/openai_functions/base.cjs +2 -3
  31. package/dist/chains/openai_functions/extraction.cjs +2 -3
  32. package/dist/chains/openai_functions/openapi.cjs +4 -5
  33. package/dist/chains/openai_functions/openapi.js +1 -1
  34. package/dist/chains/openai_functions/structured_output.cjs +3 -3
  35. package/dist/chains/openai_functions/tagging.cjs +2 -3
  36. package/dist/chains/query_constructor/index.cjs +3 -3
  37. package/dist/chains/question_answering/load.cjs +4 -4
  38. package/dist/chains/retrieval.cjs +1 -2
  39. package/dist/chains/router/utils.cjs +1 -2
  40. package/dist/chains/sequential_chain.cjs +2 -1
  41. package/dist/chains/sequential_chain.js +2 -1
  42. package/dist/chains/sql_db/sql_db_chain.cjs +2 -2
  43. package/dist/chat_models/universal.cjs +54 -21
  44. package/dist/document_loaders/fs/buffer.cjs +34 -1
  45. package/dist/document_loaders/fs/buffer.d.ts +0 -3
  46. package/dist/document_loaders/fs/directory.cjs +35 -2
  47. package/dist/document_loaders/fs/directory.d.ts +0 -2
  48. package/dist/document_loaders/fs/text.cjs +34 -1
  49. package/dist/document_loaders/fs/text.d.ts +0 -1
  50. package/dist/document_transformers/openai_functions.cjs +3 -3
  51. package/dist/evaluation/embedding_distance/base.cjs +3 -3
  52. package/dist/evaluation/loader.cjs +1 -2
  53. package/dist/experimental/autogpt/output_parser.cjs +2 -2
  54. package/dist/experimental/autogpt/prompt_generator.cjs +2 -2
  55. package/dist/experimental/generative_agents/generative_agent.cjs +1 -1
  56. package/dist/experimental/generative_agents/generative_agent.js +1 -1
  57. package/dist/experimental/openai_assistant/index.cjs +8 -4
  58. package/dist/experimental/openai_assistant/index.d.ts +6 -6
  59. package/dist/experimental/openai_assistant/index.js +9 -5
  60. package/dist/experimental/openai_files/index.cjs +2 -2
  61. package/dist/experimental/openai_files/index.d.ts +6 -4
  62. package/dist/experimental/openai_files/index.js +2 -2
  63. package/dist/experimental/plan_and_execute/agent_executor.cjs +2 -2
  64. package/dist/hub/base.cjs +4 -5
  65. package/dist/hub/index.cjs +2 -2
  66. package/dist/hub/node.cjs +43 -10
  67. package/dist/index.cjs +0 -1
  68. package/dist/index.d.ts +0 -1
  69. package/dist/index.js +1 -1
  70. package/dist/load/import_map.cjs +17 -7
  71. package/dist/load/index.cjs +18 -9
  72. package/dist/output_parsers/expression_type_handlers/base.cjs +34 -1
  73. package/dist/prompts/index.cjs +0 -1
  74. package/dist/prompts/index.d.ts +0 -1
  75. package/dist/prompts/index.js +1 -1
  76. package/dist/retrievers/hyde.cjs +2 -2
  77. package/dist/retrievers/parent_document.cjs +17 -7
  78. package/dist/smith/config.cjs +5 -6
  79. package/dist/smith/name_generation.cjs +1 -2
  80. package/dist/smith/runner_utils.cjs +1 -2
  81. package/dist/sql_db.cjs +35 -2
  82. package/dist/storage/encoder_backed.cjs +2 -2
  83. package/dist/storage/encoder_backed.d.ts +1 -1
  84. package/dist/storage/file_system.cjs +17 -7
  85. package/dist/storage/file_system.d.ts +1 -1
  86. package/dist/stores/file/node.cjs +17 -7
  87. package/dist/tools/convert_to_openai.cjs +2 -2
  88. package/dist/tools/render.cjs +2 -3
  89. package/dist/tools/retriever.cjs +1 -2
  90. package/dist/tools/webbrowser.cjs +17 -7
  91. package/dist/util/axios-fetch-adapter.cjs +1 -1
  92. package/dist/util/azure.cjs +1 -2
  93. package/dist/util/entrypoint_deprecation.cjs +2 -3
  94. package/dist/util/load.cjs +34 -1
  95. package/dist/util/ml-distance/distances.cjs +3 -4
  96. package/dist/util/ml-distance/similarities.cjs +1 -2
  97. package/dist/util/ml-distance-euclidean/euclidean.cjs +2 -3
  98. package/dist/util/openapi.cjs +17 -7
  99. package/dist/util/openapi.d.ts +32 -32
  100. package/dist/util/parse.cjs +17 -7
  101. package/dist/util/prompt-layer.d.ts +1 -1
  102. package/dist/util/set.cjs +3 -4
  103. package/dist/util/time.cjs +1 -2
  104. package/package.json +6 -6
@@ -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.isRunnableAgent = exports.BaseMultiActionAgent = exports.BaseSingleActionAgent = exports.BaseAgent = void 0;
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 import("./mrkl/index.js");
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 = void 0;
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 = void 0;
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.formatToOpenAIFunctionMessages = exports.formatForOpenAIFunctions = void 0;
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.formatToToolMessages = exports._createToolMessage = void 0;
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 = void 0;
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.initializeAgentExecutorWithOptions = exports.initializeAgentExecutor = void 0;
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.createOpenAIFunctionsAgent = exports.OpenAIAgent = exports._formatIntermediateSteps = void 0;
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.createOpenAIToolsAgent = exports.OpenAIToolsAgentOutputParser = void 0;
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 = void 0;
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,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createStructuredChatAgent = exports.StructuredChatAgent = void 0;
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");
@@ -257,4 +258,3 @@ async function createStructuredChatAgent({ llm, tools, prompt, streamRunnable, }
257
258
  });
258
259
  return agent;
259
260
  }
260
- exports.createStructuredChatAgent = createStructuredChatAgent;
@@ -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 = void 0;
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 = exports.parseAIMessageToToolAction = void 0;
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 = void 0;
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 = void 0;
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.createJsonAgent = exports.JsonToolkit = void 0;
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.createOpenApiAgent = exports.OpenApiToolkit = exports.RequestsToolkit = void 0;
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.createSqlAgent = exports.SqlToolkit = void 0;
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.createVectorStoreRouterAgent = exports.createVectorStoreAgent = exports.VectorStoreRouterToolkit = exports.VectorStoreToolkit = void 0;
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.createXmlAgent = exports.XMLAgent = void 0;
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: string;
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;
@@ -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) ?? true);
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 import("./llm_chain.js");
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 import("./sequential_chain.js");
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 import("./sequential_chain.js");
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 import("./combine_docs_chain.js");
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 import("./combine_docs_chain.js");
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 import("./combine_docs_chain.js");
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 import("./vector_db_qa.js");
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 import("./api/api_chain.js");
226
+ const { APIChain } = await Promise.resolve().then(() => __importStar(require("./api/api_chain.cjs")));
194
227
  return APIChain.deserialize(data);
195
228
  }
196
229
  default:
@@ -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 | undefined;
58
- timeout?: number | undefined;
57
+ signal?: AbortSignal;
58
+ timeout?: number;
59
59
  }>;
60
60
  /**
61
61
  * @deprecated Use .invoke() instead. Will be removed in 0.2.0.
@@ -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) ?? true);
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.formatDocuments = exports.DEFAULT_DOCUMENT_PROMPT = exports.INTERMEDIATE_STEPS_KEY = exports.DOCUMENTS_KEY = exports.DEFAULT_DOCUMENT_SEPARATOR = void 0;
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.collapseDocs = exports.splitListOfDocs = void 0;
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 = void 0;
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 = void 0;
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;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createStructuredOutputRunnable = exports.createOpenAIFnRunnable = void 0;
3
+ exports.createOpenAIFnRunnable = createOpenAIFnRunnable;
4
+ exports.createStructuredOutputRunnable = createStructuredOutputRunnable;
4
5
  const types_1 = require("@langchain/core/utils/types");
5
6
  const json_schema_1 = require("@langchain/core/utils/json_schema");
6
7
  const openai_functions_js_1 = require("../../output_parsers/openai_functions.cjs");
@@ -67,7 +68,6 @@ function createOpenAIFnRunnable(config) {
67
68
  const llmWithKwargs = llm.withConfig(llmKwargs);
68
69
  return prompt.pipe(llmWithKwargs).pipe(outputParser);
69
70
  }
70
- exports.createOpenAIFnRunnable = createOpenAIFnRunnable;
71
71
  /**
72
72
  * @deprecated Prefer the `.withStructuredOutput` method on chat model classes.
73
73
  *
@@ -141,4 +141,3 @@ function createStructuredOutputRunnable(config) {
141
141
  outputParser,
142
142
  });
143
143
  }
144
- exports.createStructuredOutputRunnable = createStructuredOutputRunnable;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createExtractionChainFromZod = exports.createExtractionChain = void 0;
3
+ exports.createExtractionChain = createExtractionChain;
4
+ exports.createExtractionChainFromZod = createExtractionChainFromZod;
4
5
  const prompts_1 = require("@langchain/core/prompts");
5
6
  const json_schema_1 = require("@langchain/core/utils/json_schema");
6
7
  const openai_functions_js_1 = require("../../output_parsers/openai_functions.cjs");
@@ -57,7 +58,6 @@ function createExtractionChain(schema, llm) {
57
58
  tags: ["openai_functions", "extraction"],
58
59
  });
59
60
  }
60
- exports.createExtractionChain = createExtractionChain;
61
61
  /**
62
62
  * Function that creates an extraction chain from a Zod schema. It
63
63
  * converts the Zod schema to a JSON schema using before creating
@@ -71,4 +71,3 @@ function createExtractionChainFromZod(
71
71
  schema, llm) {
72
72
  return createExtractionChain((0, json_schema_1.toJsonSchema)(schema), llm);
73
73
  }
74
- exports.createExtractionChainFromZod = createExtractionChainFromZod;