langchain 0.0.171 → 0.0.172

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 (63) hide show
  1. package/agents/format_scratchpad/log.cjs +1 -0
  2. package/agents/format_scratchpad/log.d.ts +1 -0
  3. package/agents/format_scratchpad/log.js +1 -0
  4. package/agents/format_scratchpad/log_to_message.cjs +1 -0
  5. package/agents/format_scratchpad/log_to_message.d.ts +1 -0
  6. package/agents/format_scratchpad/log_to_message.js +1 -0
  7. package/agents/format_scratchpad/xml.cjs +1 -0
  8. package/agents/format_scratchpad/xml.d.ts +1 -0
  9. package/agents/format_scratchpad/xml.js +1 -0
  10. package/agents/format_scratchpad.cjs +1 -1
  11. package/agents/format_scratchpad.d.ts +1 -1
  12. package/agents/format_scratchpad.js +1 -1
  13. package/agents/react/output_parser.cjs +1 -0
  14. package/agents/react/output_parser.d.ts +1 -0
  15. package/agents/react/output_parser.js +1 -0
  16. package/dist/agents/format_scratchpad/log.cjs +16 -0
  17. package/dist/agents/format_scratchpad/log.d.ts +9 -0
  18. package/dist/agents/format_scratchpad/log.js +12 -0
  19. package/dist/agents/format_scratchpad/log_to_message.cjs +22 -0
  20. package/dist/agents/format_scratchpad/log_to_message.d.ts +2 -0
  21. package/dist/agents/format_scratchpad/log_to_message.js +18 -0
  22. package/dist/agents/{format_scratchpad.cjs → format_scratchpad/openai_functions.cjs} +3 -3
  23. package/dist/agents/{format_scratchpad.d.ts → format_scratchpad/openai_functions.d.ts} +1 -1
  24. package/dist/agents/{format_scratchpad.js → format_scratchpad/openai_functions.js} +3 -3
  25. package/dist/agents/format_scratchpad/xml.cjs +12 -0
  26. package/dist/agents/format_scratchpad/xml.d.ts +2 -0
  27. package/dist/agents/format_scratchpad/xml.js +8 -0
  28. package/dist/agents/react/output_parser.cjs +96 -0
  29. package/dist/agents/react/output_parser.d.ts +47 -0
  30. package/dist/agents/react/output_parser.js +92 -0
  31. package/dist/agents/react/prompt.cjs +13 -0
  32. package/dist/agents/react/prompt.d.ts +1 -0
  33. package/dist/agents/react/prompt.js +10 -0
  34. package/dist/embeddings/openai.cjs +11 -0
  35. package/dist/embeddings/openai.d.ts +2 -0
  36. package/dist/embeddings/openai.js +11 -0
  37. package/dist/load/import_constants.cjs +1 -0
  38. package/dist/load/import_constants.js +1 -0
  39. package/dist/load/import_map.cjs +8 -3
  40. package/dist/load/import_map.d.ts +6 -1
  41. package/dist/load/import_map.js +6 -1
  42. package/dist/storage/file_system.cjs +147 -0
  43. package/dist/storage/file_system.d.ts +60 -0
  44. package/dist/storage/file_system.js +140 -0
  45. package/dist/tools/render.cjs +18 -0
  46. package/dist/tools/render.d.ts +13 -0
  47. package/dist/tools/render.js +14 -0
  48. package/dist/vectorstores/analyticdb.cjs +7 -3
  49. package/dist/vectorstores/analyticdb.d.ts +1 -1
  50. package/dist/vectorstores/analyticdb.js +7 -3
  51. package/dist/vectorstores/qdrant.cjs +19 -11
  52. package/dist/vectorstores/qdrant.d.ts +1 -1
  53. package/dist/vectorstores/qdrant.js +19 -11
  54. package/dist/vectorstores/redis.cjs +4 -1
  55. package/dist/vectorstores/redis.d.ts +1 -1
  56. package/dist/vectorstores/redis.js +4 -1
  57. package/package.json +49 -1
  58. package/storage/file_system.cjs +1 -0
  59. package/storage/file_system.d.ts +1 -0
  60. package/storage/file_system.js +1 -0
  61. package/tools/render.cjs +1 -0
  62. package/tools/render.d.ts +1 -0
  63. package/tools/render.js +1 -0
@@ -0,0 +1 @@
1
+ module.exports = require('../../dist/agents/format_scratchpad/log.cjs');
@@ -0,0 +1 @@
1
+ export * from '../../dist/agents/format_scratchpad/log.js'
@@ -0,0 +1 @@
1
+ export * from '../../dist/agents/format_scratchpad/log.js'
@@ -0,0 +1 @@
1
+ module.exports = require('../../dist/agents/format_scratchpad/log_to_message.cjs');
@@ -0,0 +1 @@
1
+ export * from '../../dist/agents/format_scratchpad/log_to_message.js'
@@ -0,0 +1 @@
1
+ export * from '../../dist/agents/format_scratchpad/log_to_message.js'
@@ -0,0 +1 @@
1
+ module.exports = require('../../dist/agents/format_scratchpad/xml.cjs');
@@ -0,0 +1 @@
1
+ export * from '../../dist/agents/format_scratchpad/xml.js'
@@ -0,0 +1 @@
1
+ export * from '../../dist/agents/format_scratchpad/xml.js'
@@ -1 +1 @@
1
- module.exports = require('../dist/agents/format_scratchpad.cjs');
1
+ module.exports = require('../dist/agents/format_scratchpad/openai_functions.cjs');
@@ -1 +1 @@
1
- export * from '../dist/agents/format_scratchpad.js'
1
+ export * from '../dist/agents/format_scratchpad/openai_functions.js'
@@ -1 +1 @@
1
- export * from '../dist/agents/format_scratchpad.js'
1
+ export * from '../dist/agents/format_scratchpad/openai_functions.js'
@@ -0,0 +1 @@
1
+ module.exports = require('../../dist/agents/react/output_parser.cjs');
@@ -0,0 +1 @@
1
+ export * from '../../dist/agents/react/output_parser.js'
@@ -0,0 +1 @@
1
+ export * from '../../dist/agents/react/output_parser.js'
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatLogToString = void 0;
4
+ /**
5
+ * Construct the scratchpad that lets the agent continue its thought process.
6
+ * @param intermediateSteps
7
+ * @param observationPrefix
8
+ * @param llmPrefix
9
+ * @returns a string with the formatted observations and agent logs
10
+ */
11
+ function formatLogToString(intermediateSteps, observationPrefix = "Observation: ", llmPrefix = "Thought: ") {
12
+ const formattedSteps = intermediateSteps.reduce((thoughts, { action, observation }) => thoughts +
13
+ [action.log, `\n${observationPrefix}${observation}`, llmPrefix].join("\n"), "");
14
+ return formattedSteps;
15
+ }
16
+ exports.formatLogToString = formatLogToString;
@@ -0,0 +1,9 @@
1
+ import { AgentStep } from "../../schema/index.js";
2
+ /**
3
+ * Construct the scratchpad that lets the agent continue its thought process.
4
+ * @param intermediateSteps
5
+ * @param observationPrefix
6
+ * @param llmPrefix
7
+ * @returns a string with the formatted observations and agent logs
8
+ */
9
+ export declare function formatLogToString(intermediateSteps: AgentStep[], observationPrefix?: string, llmPrefix?: string): string;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Construct the scratchpad that lets the agent continue its thought process.
3
+ * @param intermediateSteps
4
+ * @param observationPrefix
5
+ * @param llmPrefix
6
+ * @returns a string with the formatted observations and agent logs
7
+ */
8
+ export function formatLogToString(intermediateSteps, observationPrefix = "Observation: ", llmPrefix = "Thought: ") {
9
+ const formattedSteps = intermediateSteps.reduce((thoughts, { action, observation }) => thoughts +
10
+ [action.log, `\n${observationPrefix}${observation}`, llmPrefix].join("\n"), "");
11
+ return formattedSteps;
12
+ }
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatLogToMessage = void 0;
4
+ const template_js_1 = require("../../prompts/template.cjs");
5
+ const index_js_1 = require("../../schema/index.cjs");
6
+ function formatLogToMessage(intermediateSteps, templateToolResponse = "{observation}") {
7
+ // Get all input variables, if there is more than one, throw an error.
8
+ const matches = [...templateToolResponse.matchAll(/{([^}]*)}/g)];
9
+ const stringsInsideBrackets = matches.map((match) => match[1]);
10
+ if (stringsInsideBrackets.length > 1) {
11
+ throw new Error(`templateToolResponse must contain one input variable: ${templateToolResponse}`);
12
+ }
13
+ const thoughts = [];
14
+ for (const step of intermediateSteps) {
15
+ thoughts.push(new index_js_1.AIMessage(step.action.log));
16
+ thoughts.push(new index_js_1.HumanMessage((0, template_js_1.renderTemplate)(templateToolResponse, "f-string", {
17
+ [stringsInsideBrackets[0]]: step.observation,
18
+ })));
19
+ }
20
+ return thoughts;
21
+ }
22
+ exports.formatLogToMessage = formatLogToMessage;
@@ -0,0 +1,2 @@
1
+ import { AgentStep, BaseMessage } from "../../schema/index.js";
2
+ export declare function formatLogToMessage(intermediateSteps: AgentStep[], templateToolResponse?: string): BaseMessage[];
@@ -0,0 +1,18 @@
1
+ import { renderTemplate } from "../../prompts/template.js";
2
+ import { AIMessage, HumanMessage, } from "../../schema/index.js";
3
+ export function formatLogToMessage(intermediateSteps, templateToolResponse = "{observation}") {
4
+ // Get all input variables, if there is more than one, throw an error.
5
+ const matches = [...templateToolResponse.matchAll(/{([^}]*)}/g)];
6
+ const stringsInsideBrackets = matches.map((match) => match[1]);
7
+ if (stringsInsideBrackets.length > 1) {
8
+ throw new Error(`templateToolResponse must contain one input variable: ${templateToolResponse}`);
9
+ }
10
+ const thoughts = [];
11
+ for (const step of intermediateSteps) {
12
+ thoughts.push(new AIMessage(step.action.log));
13
+ thoughts.push(new HumanMessage(renderTemplate(templateToolResponse, "f-string", {
14
+ [stringsInsideBrackets[0]]: step.observation,
15
+ })));
16
+ }
17
+ return thoughts;
18
+ }
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.formatForOpenAIFunctions = void 0;
4
- const template_js_1 = require("../prompts/template.cjs");
5
- const index_js_1 = require("../schema/index.cjs");
6
- const prompt_js_1 = require("./chat_convo/prompt.cjs");
4
+ const template_js_1 = require("../../prompts/template.cjs");
5
+ const index_js_1 = require("../../schema/index.cjs");
6
+ const prompt_js_1 = require("../chat_convo/prompt.cjs");
7
7
  /**
8
8
  * Format a list of AgentSteps into a list of BaseMessage instances for
9
9
  * agents that use OpenAI's API. Helpful for passing in previous agent
@@ -1,4 +1,4 @@
1
- import { AgentStep, BaseMessage } from "../schema/index.js";
1
+ import { AgentStep, BaseMessage } from "../../schema/index.js";
2
2
  /**
3
3
  * Format a list of AgentSteps into a list of BaseMessage instances for
4
4
  * agents that use OpenAI's API. Helpful for passing in previous agent
@@ -1,6 +1,6 @@
1
- import { renderTemplate } from "../prompts/template.js";
2
- import { AIMessage, HumanMessage, } from "../schema/index.js";
3
- import { TEMPLATE_TOOL_RESPONSE } from "./chat_convo/prompt.js";
1
+ import { renderTemplate } from "../../prompts/template.js";
2
+ import { AIMessage, HumanMessage, } from "../../schema/index.js";
3
+ import { TEMPLATE_TOOL_RESPONSE } from "../chat_convo/prompt.js";
4
4
  /**
5
5
  * Format a list of AgentSteps into a list of BaseMessage instances for
6
6
  * agents that use OpenAI's API. Helpful for passing in previous agent
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatXml = void 0;
4
+ function formatXml(intermediateSteps) {
5
+ let log = "";
6
+ for (const step of intermediateSteps) {
7
+ const { action, observation } = step;
8
+ log += `<tool>${action.tool}</tool><tool_input>${action.toolInput}\n</tool_input><observation>${observation}</observation>`;
9
+ }
10
+ return log;
11
+ }
12
+ exports.formatXml = formatXml;
@@ -0,0 +1,2 @@
1
+ import { AgentStep } from "../../schema/index.js";
2
+ export declare function formatXml(intermediateSteps: AgentStep[]): string;
@@ -0,0 +1,8 @@
1
+ export function formatXml(intermediateSteps) {
2
+ let log = "";
3
+ for (const step of intermediateSteps) {
4
+ const { action, observation } = step;
5
+ log += `<tool>${action.tool}</tool><tool_input>${action.toolInput}\n</tool_input><observation>${observation}</observation>`;
6
+ }
7
+ return log;
8
+ }
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ReActSingleInputOutputParser = void 0;
4
+ const template_js_1 = require("../../prompts/template.cjs");
5
+ const types_js_1 = require("../types.cjs");
6
+ const prompt_js_1 = require("./prompt.cjs");
7
+ const FINAL_ANSWER_ACTION = "Final Answer:";
8
+ const FINAL_ANSWER_AND_PARSABLE_ACTION_ERROR_MESSAGE = "Parsing LLM output produced both a final answer and a parse-able action:";
9
+ /**
10
+ * Parses ReAct-style LLM calls that have a single tool input.
11
+ *
12
+ * Expects output to be in one of two formats.
13
+ *
14
+ * If the output signals that an action should be taken,
15
+ * should be in the below format. This will result in an AgentAction
16
+ * being returned.
17
+ *
18
+ * ```
19
+ * Thought: agent thought here
20
+ * Action: search
21
+ * Action Input: what is the temperature in SF?
22
+ * ```
23
+ *
24
+ * If the output signals that a final answer should be given,
25
+ * should be in the below format. This will result in an AgentFinish
26
+ * being returned.
27
+ *
28
+ * ```
29
+ * Thought: agent thought here
30
+ * Final Answer: The temperature is 100 degrees
31
+ * ```
32
+ */
33
+ class ReActSingleInputOutputParser extends types_js_1.AgentActionOutputParser {
34
+ constructor(fields) {
35
+ super(...arguments);
36
+ Object.defineProperty(this, "lc_namespace", {
37
+ enumerable: true,
38
+ configurable: true,
39
+ writable: true,
40
+ value: ["langchain", "agents", "react"]
41
+ });
42
+ Object.defineProperty(this, "toolNames", {
43
+ enumerable: true,
44
+ configurable: true,
45
+ writable: true,
46
+ value: void 0
47
+ });
48
+ this.toolNames = fields.toolNames;
49
+ }
50
+ /**
51
+ * Parses the given text into an AgentAction or AgentFinish object. If an
52
+ * output fixing parser is defined, uses it to parse the text.
53
+ * @param text Text to parse.
54
+ * @returns Promise that resolves to an AgentAction or AgentFinish object.
55
+ */
56
+ async parse(text) {
57
+ const includesAnswer = text.includes(FINAL_ANSWER_ACTION);
58
+ const regex = /Action\s*\d*\s*:[\s]*(.*?)[\s]*Action\s*\d*\s*Input\s*\d*\s*:[\s]*(.*)/;
59
+ const actionMatch = text.match(regex);
60
+ if (actionMatch) {
61
+ if (includesAnswer) {
62
+ throw new Error(`${FINAL_ANSWER_AND_PARSABLE_ACTION_ERROR_MESSAGE}: ${text}`);
63
+ }
64
+ const action = actionMatch[1];
65
+ const actionInput = actionMatch[2];
66
+ const toolInput = actionInput.trim().replace(/"/g, "");
67
+ return {
68
+ tool: action,
69
+ toolInput,
70
+ log: text,
71
+ };
72
+ }
73
+ if (includesAnswer) {
74
+ const finalAnswerText = text.split(FINAL_ANSWER_ACTION)[1].trim();
75
+ return {
76
+ returnValues: {
77
+ output: finalAnswerText,
78
+ },
79
+ log: text,
80
+ };
81
+ }
82
+ throw new Error(`Could not parse LLM output: ${text}`);
83
+ }
84
+ /**
85
+ * Returns the format instructions as a string. If the 'raw' option is
86
+ * true, returns the raw FORMAT_INSTRUCTIONS.
87
+ * @param options Options for getting the format instructions.
88
+ * @returns Format instructions as a string.
89
+ */
90
+ getFormatInstructions() {
91
+ return (0, template_js_1.renderTemplate)(prompt_js_1.FORMAT_INSTRUCTIONS, "f-string", {
92
+ tool_names: this.toolNames.join(", "),
93
+ });
94
+ }
95
+ }
96
+ exports.ReActSingleInputOutputParser = ReActSingleInputOutputParser;
@@ -0,0 +1,47 @@
1
+ import { AgentActionOutputParser } from "../types.js";
2
+ import { AgentAction, AgentFinish } from "../../schema/index.js";
3
+ /**
4
+ * Parses ReAct-style LLM calls that have a single tool input.
5
+ *
6
+ * Expects output to be in one of two formats.
7
+ *
8
+ * If the output signals that an action should be taken,
9
+ * should be in the below format. This will result in an AgentAction
10
+ * being returned.
11
+ *
12
+ * ```
13
+ * Thought: agent thought here
14
+ * Action: search
15
+ * Action Input: what is the temperature in SF?
16
+ * ```
17
+ *
18
+ * If the output signals that a final answer should be given,
19
+ * should be in the below format. This will result in an AgentFinish
20
+ * being returned.
21
+ *
22
+ * ```
23
+ * Thought: agent thought here
24
+ * Final Answer: The temperature is 100 degrees
25
+ * ```
26
+ */
27
+ export declare class ReActSingleInputOutputParser extends AgentActionOutputParser {
28
+ lc_namespace: string[];
29
+ private toolNames;
30
+ constructor(fields: {
31
+ toolNames: string[];
32
+ });
33
+ /**
34
+ * Parses the given text into an AgentAction or AgentFinish object. If an
35
+ * output fixing parser is defined, uses it to parse the text.
36
+ * @param text Text to parse.
37
+ * @returns Promise that resolves to an AgentAction or AgentFinish object.
38
+ */
39
+ parse(text: string): Promise<AgentAction | AgentFinish>;
40
+ /**
41
+ * Returns the format instructions as a string. If the 'raw' option is
42
+ * true, returns the raw FORMAT_INSTRUCTIONS.
43
+ * @param options Options for getting the format instructions.
44
+ * @returns Format instructions as a string.
45
+ */
46
+ getFormatInstructions(): string;
47
+ }
@@ -0,0 +1,92 @@
1
+ import { renderTemplate } from "../../prompts/template.js";
2
+ import { AgentActionOutputParser } from "../types.js";
3
+ import { FORMAT_INSTRUCTIONS } from "./prompt.js";
4
+ const FINAL_ANSWER_ACTION = "Final Answer:";
5
+ const FINAL_ANSWER_AND_PARSABLE_ACTION_ERROR_MESSAGE = "Parsing LLM output produced both a final answer and a parse-able action:";
6
+ /**
7
+ * Parses ReAct-style LLM calls that have a single tool input.
8
+ *
9
+ * Expects output to be in one of two formats.
10
+ *
11
+ * If the output signals that an action should be taken,
12
+ * should be in the below format. This will result in an AgentAction
13
+ * being returned.
14
+ *
15
+ * ```
16
+ * Thought: agent thought here
17
+ * Action: search
18
+ * Action Input: what is the temperature in SF?
19
+ * ```
20
+ *
21
+ * If the output signals that a final answer should be given,
22
+ * should be in the below format. This will result in an AgentFinish
23
+ * being returned.
24
+ *
25
+ * ```
26
+ * Thought: agent thought here
27
+ * Final Answer: The temperature is 100 degrees
28
+ * ```
29
+ */
30
+ export class ReActSingleInputOutputParser extends AgentActionOutputParser {
31
+ constructor(fields) {
32
+ super(...arguments);
33
+ Object.defineProperty(this, "lc_namespace", {
34
+ enumerable: true,
35
+ configurable: true,
36
+ writable: true,
37
+ value: ["langchain", "agents", "react"]
38
+ });
39
+ Object.defineProperty(this, "toolNames", {
40
+ enumerable: true,
41
+ configurable: true,
42
+ writable: true,
43
+ value: void 0
44
+ });
45
+ this.toolNames = fields.toolNames;
46
+ }
47
+ /**
48
+ * Parses the given text into an AgentAction or AgentFinish object. If an
49
+ * output fixing parser is defined, uses it to parse the text.
50
+ * @param text Text to parse.
51
+ * @returns Promise that resolves to an AgentAction or AgentFinish object.
52
+ */
53
+ async parse(text) {
54
+ const includesAnswer = text.includes(FINAL_ANSWER_ACTION);
55
+ const regex = /Action\s*\d*\s*:[\s]*(.*?)[\s]*Action\s*\d*\s*Input\s*\d*\s*:[\s]*(.*)/;
56
+ const actionMatch = text.match(regex);
57
+ if (actionMatch) {
58
+ if (includesAnswer) {
59
+ throw new Error(`${FINAL_ANSWER_AND_PARSABLE_ACTION_ERROR_MESSAGE}: ${text}`);
60
+ }
61
+ const action = actionMatch[1];
62
+ const actionInput = actionMatch[2];
63
+ const toolInput = actionInput.trim().replace(/"/g, "");
64
+ return {
65
+ tool: action,
66
+ toolInput,
67
+ log: text,
68
+ };
69
+ }
70
+ if (includesAnswer) {
71
+ const finalAnswerText = text.split(FINAL_ANSWER_ACTION)[1].trim();
72
+ return {
73
+ returnValues: {
74
+ output: finalAnswerText,
75
+ },
76
+ log: text,
77
+ };
78
+ }
79
+ throw new Error(`Could not parse LLM output: ${text}`);
80
+ }
81
+ /**
82
+ * Returns the format instructions as a string. If the 'raw' option is
83
+ * true, returns the raw FORMAT_INSTRUCTIONS.
84
+ * @param options Options for getting the format instructions.
85
+ * @returns Format instructions as a string.
86
+ */
87
+ getFormatInstructions() {
88
+ return renderTemplate(FORMAT_INSTRUCTIONS, "f-string", {
89
+ tool_names: this.toolNames.join(", "),
90
+ });
91
+ }
92
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FORMAT_INSTRUCTIONS = void 0;
4
+ exports.FORMAT_INSTRUCTIONS /* #__PURE__ */ = `Use the following format:
5
+
6
+ Question: the input question you must answer
7
+ Thought: you should always think about what to do
8
+ Action: the action to take, should be one of [{tool_names}]
9
+ Action Input: the input to the action
10
+ Observation: the result of the action
11
+ ... (this Thought/Action/Action Input/Observation can repeat N times)
12
+ Thought: I now know the final answer
13
+ Final Answer: the final answer to the original input question`;
@@ -0,0 +1 @@
1
+ export declare const FORMAT_INSTRUCTIONS = "Use the following format:\n\nQuestion: the input question you must answer\nThought: you should always think about what to do\nAction: the action to take, should be one of [{tool_names}]\nAction Input: the input to the action\nObservation: the result of the action\n... (this Thought/Action/Action Input/Observation can repeat N times)\nThought: I now know the final answer\nFinal Answer: the final answer to the original input question";
@@ -0,0 +1,10 @@
1
+ export const FORMAT_INSTRUCTIONS /* #__PURE__ */ = `Use the following format:
2
+
3
+ Question: the input question you must answer
4
+ Thought: you should always think about what to do
5
+ Action: the action to take, should be one of [{tool_names}]
6
+ Action Input: the input to the action
7
+ Observation: the result of the action
8
+ ... (this Thought/Action/Action Input/Observation can repeat N times)
9
+ Thought: I now know the final answer
10
+ Final Answer: the final answer to the original input question`;
@@ -70,6 +70,12 @@ class OpenAIEmbeddings extends base_js_1.Embeddings {
70
70
  writable: true,
71
71
  value: void 0
72
72
  });
73
+ Object.defineProperty(this, "organization", {
74
+ enumerable: true,
75
+ configurable: true,
76
+ writable: true,
77
+ value: void 0
78
+ });
73
79
  Object.defineProperty(this, "client", {
74
80
  enumerable: true,
75
81
  configurable: true,
@@ -100,6 +106,9 @@ class OpenAIEmbeddings extends base_js_1.Embeddings {
100
106
  this.azureOpenAIBasePath =
101
107
  fieldsWithDefaults?.azureOpenAIBasePath ??
102
108
  (0, env_js_1.getEnvironmentVariable)("AZURE_OPENAI_BASE_PATH");
109
+ this.organization =
110
+ fieldsWithDefaults?.configuration?.organization ??
111
+ (0, env_js_1.getEnvironmentVariable)("OPENAI_ORGANIZATION");
103
112
  this.modelName = fieldsWithDefaults?.modelName ?? this.modelName;
104
113
  this.batchSize =
105
114
  fieldsWithDefaults?.batchSize ?? (azureApiKey ? 1 : this.batchSize);
@@ -124,11 +133,13 @@ class OpenAIEmbeddings extends base_js_1.Embeddings {
124
133
  }
125
134
  this.clientConfig = {
126
135
  apiKey,
136
+ organization: this.organization,
127
137
  baseURL: configuration?.basePath,
128
138
  dangerouslyAllowBrowser: true,
129
139
  defaultHeaders: configuration?.baseOptions?.headers,
130
140
  defaultQuery: configuration?.baseOptions?.params,
131
141
  ...configuration,
142
+ ...fields?.configuration,
132
143
  };
133
144
  }
134
145
  /**
@@ -38,11 +38,13 @@ export declare class OpenAIEmbeddings extends Embeddings implements OpenAIEmbedd
38
38
  azureOpenAIApiInstanceName?: string;
39
39
  azureOpenAIApiDeploymentName?: string;
40
40
  azureOpenAIBasePath?: string;
41
+ organization?: string;
41
42
  private client;
42
43
  private clientConfig;
43
44
  constructor(fields?: Partial<OpenAIEmbeddingsParams> & Partial<AzureOpenAIInput> & {
44
45
  verbose?: boolean;
45
46
  openAIApiKey?: string;
47
+ configuration?: ClientOptions;
46
48
  }, configuration?: ClientOptions & LegacyOpenAIInput);
47
49
  /**
48
50
  * Method to generate embeddings for an array of documents. Splits the
@@ -67,6 +67,12 @@ export class OpenAIEmbeddings extends Embeddings {
67
67
  writable: true,
68
68
  value: void 0
69
69
  });
70
+ Object.defineProperty(this, "organization", {
71
+ enumerable: true,
72
+ configurable: true,
73
+ writable: true,
74
+ value: void 0
75
+ });
70
76
  Object.defineProperty(this, "client", {
71
77
  enumerable: true,
72
78
  configurable: true,
@@ -97,6 +103,9 @@ export class OpenAIEmbeddings extends Embeddings {
97
103
  this.azureOpenAIBasePath =
98
104
  fieldsWithDefaults?.azureOpenAIBasePath ??
99
105
  getEnvironmentVariable("AZURE_OPENAI_BASE_PATH");
106
+ this.organization =
107
+ fieldsWithDefaults?.configuration?.organization ??
108
+ getEnvironmentVariable("OPENAI_ORGANIZATION");
100
109
  this.modelName = fieldsWithDefaults?.modelName ?? this.modelName;
101
110
  this.batchSize =
102
111
  fieldsWithDefaults?.batchSize ?? (azureApiKey ? 1 : this.batchSize);
@@ -121,11 +130,13 @@ export class OpenAIEmbeddings extends Embeddings {
121
130
  }
122
131
  this.clientConfig = {
123
132
  apiKey,
133
+ organization: this.organization,
124
134
  baseURL: configuration?.basePath,
125
135
  dangerouslyAllowBrowser: true,
126
136
  defaultHeaders: configuration?.baseOptions?.headers,
127
137
  defaultQuery: configuration?.baseOptions?.params,
128
138
  ...configuration,
139
+ ...fields?.configuration,
129
140
  };
130
141
  }
131
142
  /**
@@ -146,6 +146,7 @@ exports.optionalImportEntrypoints = [
146
146
  "langchain/storage/ioredis",
147
147
  "langchain/storage/vercel_kv",
148
148
  "langchain/storage/upstash_redis",
149
+ "langchain/storage/file_system",
149
150
  "langchain/graphs/neo4j_graph",
150
151
  "langchain/hub",
151
152
  "langchain/experimental/multimodal_embeddings/googlevertexai",
@@ -143,6 +143,7 @@ export const optionalImportEntrypoints = [
143
143
  "langchain/storage/ioredis",
144
144
  "langchain/storage/vercel_kv",
145
145
  "langchain/storage/upstash_redis",
146
+ "langchain/storage/file_system",
146
147
  "langchain/graphs/neo4j_graph",
147
148
  "langchain/hub",
148
149
  "langchain/experimental/multimodal_embeddings/googlevertexai",
@@ -24,14 +24,19 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  return result;
25
25
  };
26
26
  Object.defineProperty(exports, "__esModule", { value: true });
27
- exports.schema__output_parser = exports.schema__document = exports.schema = exports.chat_models__fake = exports.chat_models__yandex = exports.chat_models__minimax = exports.chat_models__ollama = exports.chat_models__baiduwenxin = exports.chat_models__fireworks = exports.chat_models__cloudflare_workersai = exports.chat_models__anthropic = exports.chat_models__openai = exports.chat_models__base = exports.document_transformers__openai_functions = exports.document_loaders__web__sort_xyz_blockchain = exports.document_loaders__web__serpapi = exports.document_loaders__web__searchapi = exports.document_loaders__base = exports.document = exports.memory = exports.text_splitter = exports.vectorstores__xata = exports.vectorstores__vectara = exports.vectorstores__prisma = exports.vectorstores__memory = exports.vectorstores__base = exports.prompts = exports.llms__fake = exports.llms__yandex = exports.llms__fireworks = exports.llms__ollama = exports.llms__cloudflare_workersai = exports.llms__aleph_alpha = exports.llms__ai21 = exports.llms__openai = exports.llms__base = exports.embeddings__minimax = exports.embeddings__openai = exports.embeddings__ollama = exports.embeddings__fake = exports.embeddings__cache_backed = exports.embeddings__base = exports.chains__openai_functions = exports.chains = exports.tools = exports.base_language = exports.agents__format_scratchpad = exports.agents__toolkits = exports.agents = exports.load__serializable = void 0;
28
- exports.runnables__remote = exports.evaluation = exports.experimental__chains__violation_of_expectations = exports.experimental__chat_models__bittensor = exports.experimental__plan_and_execute = exports.experimental__generative_agents = exports.experimental__babyagi = exports.experimental__autogpt = exports.util__time = exports.util__math = exports.storage__in_memory = exports.storage__encoder_backed = exports.stores__message__in_memory = exports.stores__file__in_memory = exports.stores__doc__in_memory = exports.cache = exports.retrievers__vespa = exports.retrievers__score_threshold = exports.retrievers__hyde = exports.retrievers__document_compressors__embeddings_filter = exports.retrievers__document_compressors__chain_extract = exports.retrievers__time_weighted = exports.retrievers__tavily_search_api = exports.retrievers__parent_document = exports.retrievers__multi_vector = exports.retrievers__multi_query = exports.retrievers__document_compressors = exports.retrievers__contextual_compression = exports.retrievers__databerry = exports.retrievers__chaindesk = exports.retrievers__remote = exports.output_parsers = exports.callbacks = exports.schema__storage = exports.schema__runnable = exports.schema__retriever = exports.schema__query_constructor = void 0;
27
+ exports.chat_models__minimax = exports.chat_models__ollama = exports.chat_models__baiduwenxin = exports.chat_models__fireworks = exports.chat_models__cloudflare_workersai = exports.chat_models__anthropic = exports.chat_models__openai = exports.chat_models__base = exports.document_transformers__openai_functions = exports.document_loaders__web__sort_xyz_blockchain = exports.document_loaders__web__serpapi = exports.document_loaders__web__searchapi = exports.document_loaders__base = exports.document = exports.memory = exports.text_splitter = exports.vectorstores__xata = exports.vectorstores__vectara = exports.vectorstores__prisma = exports.vectorstores__memory = exports.vectorstores__base = exports.prompts = exports.llms__fake = exports.llms__yandex = exports.llms__fireworks = exports.llms__ollama = exports.llms__cloudflare_workersai = exports.llms__aleph_alpha = exports.llms__ai21 = exports.llms__openai = exports.llms__base = exports.embeddings__minimax = exports.embeddings__openai = exports.embeddings__ollama = exports.embeddings__fake = exports.embeddings__cache_backed = exports.embeddings__base = exports.chains__openai_functions = exports.chains = exports.tools__render = exports.tools = exports.base_language = exports.agents__react__output_parser = exports.agents__format_scratchpad__log_to_message = exports.agents__format_scratchpad__xml = exports.agents__format_scratchpad__log = exports.agents__format_scratchpad = exports.agents__toolkits = exports.agents = exports.load__serializable = void 0;
28
+ exports.runnables__remote = exports.evaluation = exports.experimental__chains__violation_of_expectations = exports.experimental__chat_models__bittensor = exports.experimental__plan_and_execute = exports.experimental__generative_agents = exports.experimental__babyagi = exports.experimental__autogpt = exports.util__time = exports.util__math = exports.storage__in_memory = exports.storage__encoder_backed = exports.stores__message__in_memory = exports.stores__file__in_memory = exports.stores__doc__in_memory = exports.cache = exports.retrievers__vespa = exports.retrievers__score_threshold = exports.retrievers__hyde = exports.retrievers__document_compressors__embeddings_filter = exports.retrievers__document_compressors__chain_extract = exports.retrievers__time_weighted = exports.retrievers__tavily_search_api = exports.retrievers__parent_document = exports.retrievers__multi_vector = exports.retrievers__multi_query = exports.retrievers__document_compressors = exports.retrievers__contextual_compression = exports.retrievers__databerry = exports.retrievers__chaindesk = exports.retrievers__remote = exports.output_parsers = exports.callbacks = exports.schema__storage = exports.schema__runnable = exports.schema__retriever = exports.schema__query_constructor = exports.schema__output_parser = exports.schema__document = exports.schema = exports.chat_models__fake = exports.chat_models__yandex = void 0;
29
29
  exports.load__serializable = __importStar(require("../load/serializable.cjs"));
30
30
  exports.agents = __importStar(require("../agents/index.cjs"));
31
31
  exports.agents__toolkits = __importStar(require("../agents/toolkits/index.cjs"));
32
- exports.agents__format_scratchpad = __importStar(require("../agents/format_scratchpad.cjs"));
32
+ exports.agents__format_scratchpad = __importStar(require("../agents/format_scratchpad/openai_functions.cjs"));
33
+ exports.agents__format_scratchpad__log = __importStar(require("../agents/format_scratchpad/log.cjs"));
34
+ exports.agents__format_scratchpad__xml = __importStar(require("../agents/format_scratchpad/xml.cjs"));
35
+ exports.agents__format_scratchpad__log_to_message = __importStar(require("../agents/format_scratchpad/log_to_message.cjs"));
36
+ exports.agents__react__output_parser = __importStar(require("../agents/react/output_parser.cjs"));
33
37
  exports.base_language = __importStar(require("../base_language/index.cjs"));
34
38
  exports.tools = __importStar(require("../tools/index.cjs"));
39
+ exports.tools__render = __importStar(require("../tools/render.cjs"));
35
40
  exports.chains = __importStar(require("../chains/index.cjs"));
36
41
  exports.chains__openai_functions = __importStar(require("../chains/openai_functions/index.cjs"));
37
42
  exports.embeddings__base = __importStar(require("../embeddings/base.cjs"));
@@ -1,9 +1,14 @@
1
1
  export * as load__serializable from "../load/serializable.js";
2
2
  export * as agents from "../agents/index.js";
3
3
  export * as agents__toolkits from "../agents/toolkits/index.js";
4
- export * as agents__format_scratchpad from "../agents/format_scratchpad.js";
4
+ export * as agents__format_scratchpad from "../agents/format_scratchpad/openai_functions.js";
5
+ export * as agents__format_scratchpad__log from "../agents/format_scratchpad/log.js";
6
+ export * as agents__format_scratchpad__xml from "../agents/format_scratchpad/xml.js";
7
+ export * as agents__format_scratchpad__log_to_message from "../agents/format_scratchpad/log_to_message.js";
8
+ export * as agents__react__output_parser from "../agents/react/output_parser.js";
5
9
  export * as base_language from "../base_language/index.js";
6
10
  export * as tools from "../tools/index.js";
11
+ export * as tools__render from "../tools/render.js";
7
12
  export * as chains from "../chains/index.js";
8
13
  export * as chains__openai_functions from "../chains/openai_functions/index.js";
9
14
  export * as embeddings__base from "../embeddings/base.js";