langchain 0.0.63 → 0.0.65

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 (163) hide show
  1. package/dist/agents/agent.cjs +3 -4
  2. package/dist/agents/agent.js +3 -4
  3. package/dist/agents/chat_convo/prompt.cjs +1 -1
  4. package/dist/agents/chat_convo/prompt.d.ts +1 -1
  5. package/dist/agents/chat_convo/prompt.js +1 -1
  6. package/dist/agents/initialize.cjs +1 -1
  7. package/dist/agents/initialize.d.ts +1 -1
  8. package/dist/agents/initialize.js +1 -1
  9. package/dist/agents/types.cjs +2 -2
  10. package/dist/agents/types.d.ts +2 -1
  11. package/dist/agents/types.js +1 -1
  12. package/dist/base_language/index.d.ts +4 -1
  13. package/dist/callbacks/manager.cjs +5 -1
  14. package/dist/callbacks/manager.js +5 -1
  15. package/dist/chains/analyze_documents_chain.cjs +3 -3
  16. package/dist/chains/analyze_documents_chain.d.ts +2 -1
  17. package/dist/chains/analyze_documents_chain.js +3 -3
  18. package/dist/chains/base.cjs +30 -11
  19. package/dist/chains/base.d.ts +7 -3
  20. package/dist/chains/base.js +30 -11
  21. package/dist/chains/chat_vector_db_chain.cjs +4 -4
  22. package/dist/chains/chat_vector_db_chain.d.ts +9 -15
  23. package/dist/chains/chat_vector_db_chain.js +4 -4
  24. package/dist/chains/combine_docs_chain.cjs +11 -11
  25. package/dist/chains/combine_docs_chain.d.ts +6 -5
  26. package/dist/chains/combine_docs_chain.js +11 -11
  27. package/dist/chains/conversational_retrieval_chain.cjs +4 -4
  28. package/dist/chains/conversational_retrieval_chain.d.ts +2 -1
  29. package/dist/chains/conversational_retrieval_chain.js +4 -4
  30. package/dist/chains/index.cjs +4 -3
  31. package/dist/chains/index.d.ts +2 -2
  32. package/dist/chains/index.js +1 -1
  33. package/dist/chains/llm_chain.cjs +4 -4
  34. package/dist/chains/llm_chain.d.ts +3 -2
  35. package/dist/chains/llm_chain.js +4 -4
  36. package/dist/chains/retrieval_qa.cjs +3 -3
  37. package/dist/chains/retrieval_qa.d.ts +2 -1
  38. package/dist/chains/retrieval_qa.js +3 -3
  39. package/dist/chains/sequential_chain.cjs +262 -0
  40. package/dist/chains/{simple_sequential_chain.d.ts → sequential_chain.d.ts} +31 -2
  41. package/dist/chains/sequential_chain.js +257 -0
  42. package/dist/chains/serde.d.ts +7 -1
  43. package/dist/chains/sql_db/sql_db_chain.cjs +7 -5
  44. package/dist/chains/sql_db/sql_db_chain.d.ts +2 -1
  45. package/dist/chains/sql_db/sql_db_chain.js +7 -5
  46. package/dist/chains/vector_db_qa.cjs +3 -3
  47. package/dist/chains/vector_db_qa.d.ts +2 -1
  48. package/dist/chains/vector_db_qa.js +3 -3
  49. package/dist/chat_models/base.d.ts +10 -8
  50. package/dist/chat_models/openai.cjs +9 -5
  51. package/dist/chat_models/openai.d.ts +14 -5
  52. package/dist/chat_models/openai.js +10 -6
  53. package/dist/document_loaders/fs/unstructured.cjs +48 -1
  54. package/dist/document_loaders/fs/unstructured.d.ts +9 -1
  55. package/dist/document_loaders/fs/unstructured.js +46 -0
  56. package/dist/embeddings/tensorflow.cjs +67 -0
  57. package/dist/embeddings/tensorflow.d.ts +12 -0
  58. package/dist/embeddings/tensorflow.js +40 -0
  59. package/dist/experimental/autogpt/output_parser.cjs +2 -2
  60. package/dist/experimental/autogpt/output_parser.d.ts +1 -1
  61. package/dist/experimental/autogpt/output_parser.js +1 -1
  62. package/dist/experimental/babyagi/agent.cjs +194 -0
  63. package/dist/experimental/babyagi/agent.d.ts +47 -0
  64. package/dist/experimental/babyagi/agent.js +190 -0
  65. package/dist/experimental/babyagi/index.cjs +11 -0
  66. package/dist/experimental/babyagi/index.d.ts +4 -0
  67. package/dist/experimental/babyagi/index.js +4 -0
  68. package/dist/experimental/babyagi/task_creation.cjs +29 -0
  69. package/dist/experimental/babyagi/task_creation.d.ts +5 -0
  70. package/dist/experimental/babyagi/task_creation.js +25 -0
  71. package/dist/experimental/babyagi/task_execution.cjs +20 -0
  72. package/dist/experimental/babyagi/task_execution.d.ts +5 -0
  73. package/dist/experimental/babyagi/task_execution.js +16 -0
  74. package/dist/experimental/babyagi/task_prioritization.cjs +23 -0
  75. package/dist/experimental/babyagi/task_prioritization.d.ts +5 -0
  76. package/dist/experimental/babyagi/task_prioritization.js +19 -0
  77. package/dist/llms/base.cjs +0 -9
  78. package/dist/llms/base.d.ts +11 -12
  79. package/dist/llms/base.js +0 -9
  80. package/dist/llms/openai-chat.cjs +9 -5
  81. package/dist/llms/openai-chat.d.ts +16 -7
  82. package/dist/llms/openai-chat.js +9 -5
  83. package/dist/llms/openai.cjs +9 -5
  84. package/dist/llms/openai.d.ts +15 -12
  85. package/dist/llms/openai.js +10 -6
  86. package/dist/memory/base.d.ts +1 -0
  87. package/dist/memory/buffer_memory.cjs +3 -0
  88. package/dist/memory/buffer_memory.d.ts +1 -0
  89. package/dist/memory/buffer_memory.js +3 -0
  90. package/dist/memory/buffer_window_memory.cjs +5 -0
  91. package/dist/memory/buffer_window_memory.d.ts +1 -0
  92. package/dist/memory/buffer_window_memory.js +5 -0
  93. package/dist/memory/motorhead_memory.cjs +3 -0
  94. package/dist/memory/motorhead_memory.d.ts +1 -0
  95. package/dist/memory/motorhead_memory.js +3 -0
  96. package/dist/memory/summary.cjs +3 -0
  97. package/dist/memory/summary.d.ts +1 -0
  98. package/dist/memory/summary.js +3 -0
  99. package/dist/output_parsers/combining.cjs +4 -4
  100. package/dist/output_parsers/combining.d.ts +3 -2
  101. package/dist/output_parsers/combining.js +3 -3
  102. package/dist/output_parsers/fix.cjs +6 -6
  103. package/dist/output_parsers/fix.d.ts +3 -2
  104. package/dist/output_parsers/fix.js +4 -4
  105. package/dist/output_parsers/list.cjs +3 -3
  106. package/dist/output_parsers/list.d.ts +1 -1
  107. package/dist/output_parsers/list.js +1 -1
  108. package/dist/output_parsers/regex.cjs +3 -3
  109. package/dist/output_parsers/regex.d.ts +1 -1
  110. package/dist/output_parsers/regex.js +1 -1
  111. package/dist/output_parsers/structured.cjs +10 -4
  112. package/dist/output_parsers/structured.d.ts +1 -1
  113. package/dist/output_parsers/structured.js +9 -3
  114. package/dist/prompts/base.d.ts +2 -1
  115. package/dist/prompts/chat.cjs +16 -2
  116. package/dist/prompts/chat.d.ts +2 -2
  117. package/dist/prompts/chat.js +16 -2
  118. package/dist/retrievers/supabase.cjs +2 -2
  119. package/dist/retrievers/supabase.js +2 -2
  120. package/dist/schema/index.cjs +1 -21
  121. package/dist/schema/index.d.ts +0 -30
  122. package/dist/schema/index.js +0 -18
  123. package/dist/schema/output_parser.cjs +23 -0
  124. package/dist/schema/output_parser.d.ts +32 -0
  125. package/dist/schema/output_parser.js +18 -0
  126. package/dist/tools/base.cjs +4 -4
  127. package/dist/tools/base.d.ts +4 -7
  128. package/dist/tools/base.js +4 -4
  129. package/dist/tools/fs.cjs +4 -4
  130. package/dist/tools/fs.d.ts +2 -2
  131. package/dist/tools/fs.js +4 -4
  132. package/dist/tools/serpapi.cjs +17 -10
  133. package/dist/tools/serpapi.d.ts +4 -1
  134. package/dist/tools/serpapi.js +17 -10
  135. package/dist/tools/webbrowser.cjs +5 -5
  136. package/dist/tools/webbrowser.d.ts +6 -6
  137. package/dist/tools/webbrowser.js +5 -5
  138. package/dist/util/async_caller.cjs +9 -0
  139. package/dist/util/async_caller.js +9 -0
  140. package/dist/util/axios-fetch-adapter.cjs +6 -0
  141. package/dist/util/axios-fetch-adapter.js +6 -0
  142. package/dist/util/axios-types.d.ts +3 -1
  143. package/dist/util/flatten.cjs +21 -0
  144. package/dist/util/flatten.d.ts +1 -0
  145. package/dist/util/flatten.js +17 -0
  146. package/dist/util/set.cjs +41 -0
  147. package/dist/util/set.d.ts +15 -0
  148. package/dist/util/set.js +35 -0
  149. package/dist/vectorstores/pinecone.cjs +4 -0
  150. package/dist/vectorstores/pinecone.js +4 -0
  151. package/dist/vectorstores/supabase.cjs +1 -1
  152. package/dist/vectorstores/supabase.js +1 -1
  153. package/dist/vectorstores/weaviate.cjs +15 -9
  154. package/dist/vectorstores/weaviate.js +15 -9
  155. package/embeddings/tensorflow.cjs +1 -0
  156. package/embeddings/tensorflow.d.ts +1 -0
  157. package/embeddings/tensorflow.js +1 -0
  158. package/experimental/babyagi.cjs +1 -0
  159. package/experimental/babyagi.d.ts +1 -0
  160. package/experimental/babyagi.js +1 -0
  161. package/package.json +36 -5
  162. package/dist/chains/simple_sequential_chain.cjs +0 -124
  163. package/dist/chains/simple_sequential_chain.js +0 -120
@@ -1,4 +1,4 @@
1
- import { BaseOutputParser, OutputParserException } from "../schema/index.js";
1
+ import { BaseOutputParser, OutputParserException, } from "../schema/output_parser.js";
2
2
  import { LLMChain } from "../chains/llm_chain.js";
3
3
  import { NAIVE_FIX_PROMPT } from "./prompts.js";
4
4
  export class OutputFixingParser extends BaseOutputParser {
@@ -24,9 +24,9 @@ export class OutputFixingParser extends BaseOutputParser {
24
24
  this.parser = parser;
25
25
  this.retryChain = retryChain;
26
26
  }
27
- async parse(completion) {
27
+ async parse(completion, callbacks) {
28
28
  try {
29
- return await this.parser.parse(completion);
29
+ return await this.parser.parse(completion, callbacks);
30
30
  }
31
31
  catch (e) {
32
32
  // eslint-disable-next-line no-instanceof/no-instanceof
@@ -35,7 +35,7 @@ export class OutputFixingParser extends BaseOutputParser {
35
35
  instructions: this.parser.getFormatInstructions(),
36
36
  completion,
37
37
  error: e,
38
- });
38
+ }, callbacks);
39
39
  const newCompletion = result[this.retryChain.outputKey];
40
40
  return this.parser.parse(newCompletion);
41
41
  }
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CommaSeparatedListOutputParser = exports.ListOutputParser = void 0;
4
- const index_js_1 = require("../schema/index.cjs");
4
+ const output_parser_js_1 = require("../schema/output_parser.cjs");
5
5
  /**
6
6
  * Class to parse the output of an LLM call to a list.
7
7
  * @augments BaseOutputParser
8
8
  */
9
- class ListOutputParser extends index_js_1.BaseOutputParser {
9
+ class ListOutputParser extends output_parser_js_1.BaseOutputParser {
10
10
  }
11
11
  exports.ListOutputParser = ListOutputParser;
12
12
  /**
@@ -22,7 +22,7 @@ class CommaSeparatedListOutputParser extends ListOutputParser {
22
22
  .map((s) => s.trim());
23
23
  }
24
24
  catch (e) {
25
- throw new index_js_1.OutputParserException(`Could not parse output: ${text}`);
25
+ throw new output_parser_js_1.OutputParserException(`Could not parse output: ${text}`);
26
26
  }
27
27
  }
28
28
  getFormatInstructions() {
@@ -1,4 +1,4 @@
1
- import { BaseOutputParser } from "../schema/index.js";
1
+ import { BaseOutputParser } from "../schema/output_parser.js";
2
2
  /**
3
3
  * Class to parse the output of an LLM call to a list.
4
4
  * @augments BaseOutputParser
@@ -1,4 +1,4 @@
1
- import { BaseOutputParser, OutputParserException } from "../schema/index.js";
1
+ import { BaseOutputParser, OutputParserException, } from "../schema/output_parser.js";
2
2
  /**
3
3
  * Class to parse the output of an LLM call to a list.
4
4
  * @augments BaseOutputParser
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RegexParser = void 0;
4
- const index_js_1 = require("../schema/index.cjs");
4
+ const output_parser_js_1 = require("../schema/output_parser.cjs");
5
5
  /**
6
6
  * Class to parse the output of an LLM call into a dictionary.
7
7
  * @augments BaseOutputParser
8
8
  */
9
- class RegexParser extends index_js_1.BaseOutputParser {
9
+ class RegexParser extends output_parser_js_1.BaseOutputParser {
10
10
  constructor(regex, outputKeys, defaultOutputKey) {
11
11
  super();
12
12
  Object.defineProperty(this, "regex", {
@@ -43,7 +43,7 @@ class RegexParser extends index_js_1.BaseOutputParser {
43
43
  }, {});
44
44
  }
45
45
  if (this.defaultOutputKey === undefined) {
46
- throw new index_js_1.OutputParserException(`Could not parse output: ${text}`);
46
+ throw new output_parser_js_1.OutputParserException(`Could not parse output: ${text}`);
47
47
  }
48
48
  return this.outputKeys.reduce((acc, key) => {
49
49
  acc[key] = key === this.defaultOutputKey ? text : "";
@@ -1,4 +1,4 @@
1
- import { BaseOutputParser } from "../schema/index.js";
1
+ import { BaseOutputParser } from "../schema/output_parser.js";
2
2
  /**
3
3
  * Class to parse the output of an LLM call into a dictionary.
4
4
  * @augments BaseOutputParser
@@ -1,4 +1,4 @@
1
- import { BaseOutputParser, OutputParserException } from "../schema/index.js";
1
+ import { BaseOutputParser, OutputParserException, } from "../schema/output_parser.js";
2
2
  /**
3
3
  * Class to parse the output of an LLM call into a dictionary.
4
4
  * @augments BaseOutputParser
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.StructuredOutputParser = void 0;
4
4
  const zod_1 = require("zod");
5
- const index_js_1 = require("../schema/index.cjs");
5
+ const output_parser_js_1 = require("../schema/output_parser.cjs");
6
6
  function printSchema(schema, depth = 0) {
7
7
  if (schema._def.typeName === "ZodString" &&
8
8
  schema._def.checks.some((check) => check.kind === "datetime")) {
@@ -25,6 +25,12 @@ function printSchema(schema, depth = 0) {
25
25
  .map((value) => `"${value}"`)
26
26
  .join(" | ");
27
27
  }
28
+ if (schema._def.typeName === "ZodNativeEnum") {
29
+ return zod_1.util
30
+ .getValidEnumValues(schema._def.values)
31
+ .map((value) => `"${value}"`)
32
+ .join(" | ");
33
+ }
28
34
  if (schema._def.typeName === "ZodNullable") {
29
35
  return `${printSchema(schema._def.innerType, depth)} // Nullable`;
30
36
  }
@@ -52,7 +58,7 @@ ${indent}}`;
52
58
  }
53
59
  throw new Error(`Unsupported type: ${schema._def.typeName}`);
54
60
  }
55
- class StructuredOutputParser extends index_js_1.BaseOutputParser {
61
+ class StructuredOutputParser extends output_parser_js_1.BaseOutputParser {
56
62
  constructor(schema) {
57
63
  super();
58
64
  Object.defineProperty(this, "schema", {
@@ -82,10 +88,10 @@ Including the leading and trailing "\`\`\`json" and "\`\`\`"
82
88
  async parse(text) {
83
89
  try {
84
90
  const json = text.trim().split("```json")[1].split("```")[0].trim();
85
- return this.schema.parse(JSON.parse(json));
91
+ return this.schema.parseAsync(JSON.parse(json));
86
92
  }
87
93
  catch (e) {
88
- throw new index_js_1.OutputParserException(`Failed to parse. Text: "${text}". Error: ${e}`);
94
+ throw new output_parser_js_1.OutputParserException(`Failed to parse. Text: "${text}". Error: ${e}`);
89
95
  }
90
96
  }
91
97
  }
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import { BaseOutputParser } from "../schema/index.js";
2
+ import { BaseOutputParser } from "../schema/output_parser.js";
3
3
  export declare class StructuredOutputParser<T extends z.ZodTypeAny> extends BaseOutputParser<z.infer<T>> {
4
4
  schema: T;
5
5
  constructor(schema: T);
@@ -1,5 +1,5 @@
1
- import { z } from "zod";
2
- import { BaseOutputParser, OutputParserException } from "../schema/index.js";
1
+ import { z, util } from "zod";
2
+ import { BaseOutputParser, OutputParserException, } from "../schema/output_parser.js";
3
3
  function printSchema(schema, depth = 0) {
4
4
  if (schema._def.typeName === "ZodString" &&
5
5
  schema._def.checks.some((check) => check.kind === "datetime")) {
@@ -22,6 +22,12 @@ function printSchema(schema, depth = 0) {
22
22
  .map((value) => `"${value}"`)
23
23
  .join(" | ");
24
24
  }
25
+ if (schema._def.typeName === "ZodNativeEnum") {
26
+ return util
27
+ .getValidEnumValues(schema._def.values)
28
+ .map((value) => `"${value}"`)
29
+ .join(" | ");
30
+ }
25
31
  if (schema._def.typeName === "ZodNullable") {
26
32
  return `${printSchema(schema._def.innerType, depth)} // Nullable`;
27
33
  }
@@ -79,7 +85,7 @@ Including the leading and trailing "\`\`\`json" and "\`\`\`"
79
85
  async parse(text) {
80
86
  try {
81
87
  const json = text.trim().split("```json")[1].split("```")[0].trim();
82
- return this.schema.parse(JSON.parse(json));
88
+ return this.schema.parseAsync(JSON.parse(json));
83
89
  }
84
90
  catch (e) {
85
91
  throw new OutputParserException(`Failed to parse. Text: "${text}". Error: ${e}`);
@@ -1,4 +1,5 @@
1
- import { BaseOutputParser, BasePromptValue, Example, HumanChatMessage, InputValues, PartialValues } from "../schema/index.js";
1
+ import { BasePromptValue, Example, HumanChatMessage, InputValues, PartialValues } from "../schema/index.js";
2
+ import { BaseOutputParser } from "../schema/output_parser.js";
2
3
  import { SerializedBasePromptTemplate } from "./serde.js";
3
4
  export declare class StringPromptValue {
4
5
  value: string;
@@ -218,15 +218,29 @@ class ChatPromptTemplate extends BaseChatPromptTemplate {
218
218
  return new ChatPromptTemplate(promptDict);
219
219
  }
220
220
  static fromPromptMessages(promptMessages) {
221
+ const flattenedMessages = promptMessages.reduce((acc, promptMessage) => acc.concat(
222
+ // eslint-disable-next-line no-instanceof/no-instanceof
223
+ promptMessage instanceof ChatPromptTemplate
224
+ ? promptMessage.promptMessages
225
+ : [promptMessage]), []);
226
+ const flattenedPartialVariables = promptMessages.reduce((acc, promptMessage) =>
227
+ // eslint-disable-next-line no-instanceof/no-instanceof
228
+ promptMessage instanceof ChatPromptTemplate
229
+ ? Object.assign(acc, promptMessage.partialVariables)
230
+ : acc, Object.create(null));
221
231
  const inputVariables = new Set();
222
- for (const promptMessage of promptMessages) {
232
+ for (const promptMessage of flattenedMessages) {
223
233
  for (const inputVariable of promptMessage.inputVariables) {
234
+ if (inputVariable in flattenedPartialVariables) {
235
+ continue;
236
+ }
224
237
  inputVariables.add(inputVariable);
225
238
  }
226
239
  }
227
240
  return new ChatPromptTemplate({
228
241
  inputVariables: [...inputVariables],
229
- promptMessages,
242
+ promptMessages: flattenedMessages,
243
+ partialVariables: flattenedPartialVariables,
230
244
  });
231
245
  }
232
246
  }
@@ -71,6 +71,6 @@ export declare class ChatPromptTemplate extends BaseChatPromptTemplate implement
71
71
  _getPromptType(): "chat";
72
72
  formatMessages(values: InputValues): Promise<BaseChatMessage[]>;
73
73
  serialize(): SerializedChatPromptTemplate;
74
- partial(values: PartialValues): Promise<BasePromptTemplate>;
75
- static fromPromptMessages(promptMessages: BaseMessagePromptTemplate[]): ChatPromptTemplate;
74
+ partial(values: PartialValues): Promise<ChatPromptTemplate>;
75
+ static fromPromptMessages(promptMessages: (BaseMessagePromptTemplate | ChatPromptTemplate)[]): ChatPromptTemplate;
76
76
  }
@@ -206,15 +206,29 @@ export class ChatPromptTemplate extends BaseChatPromptTemplate {
206
206
  return new ChatPromptTemplate(promptDict);
207
207
  }
208
208
  static fromPromptMessages(promptMessages) {
209
+ const flattenedMessages = promptMessages.reduce((acc, promptMessage) => acc.concat(
210
+ // eslint-disable-next-line no-instanceof/no-instanceof
211
+ promptMessage instanceof ChatPromptTemplate
212
+ ? promptMessage.promptMessages
213
+ : [promptMessage]), []);
214
+ const flattenedPartialVariables = promptMessages.reduce((acc, promptMessage) =>
215
+ // eslint-disable-next-line no-instanceof/no-instanceof
216
+ promptMessage instanceof ChatPromptTemplate
217
+ ? Object.assign(acc, promptMessage.partialVariables)
218
+ : acc, Object.create(null));
209
219
  const inputVariables = new Set();
210
- for (const promptMessage of promptMessages) {
220
+ for (const promptMessage of flattenedMessages) {
211
221
  for (const inputVariable of promptMessage.inputVariables) {
222
+ if (inputVariable in flattenedPartialVariables) {
223
+ continue;
224
+ }
212
225
  inputVariables.add(inputVariable);
213
226
  }
214
227
  }
215
228
  return new ChatPromptTemplate({
216
229
  inputVariables: [...inputVariables],
217
- promptMessages,
230
+ promptMessages: flattenedMessages,
231
+ partialVariables: flattenedPartialVariables,
218
232
  });
219
233
  }
220
234
  }
@@ -70,7 +70,7 @@ class SupabaseHybridSearch extends index_js_1.BaseRetriever {
70
70
  };
71
71
  const { data: searches, error } = await this.client.rpc(this.similarityQueryName, matchDocumentsParams);
72
72
  if (error) {
73
- throw new Error(`Error searching for documents: ${error}`);
73
+ throw new Error(`Error searching for documents: ${error.code} ${error.message} ${error.details}`);
74
74
  }
75
75
  return searches.map((resp) => [
76
76
  new document_js_1.Document({
@@ -88,7 +88,7 @@ class SupabaseHybridSearch extends index_js_1.BaseRetriever {
88
88
  };
89
89
  const { data: searches, error } = await this.client.rpc(this.keywordQueryName, kwMatchDocumentsParams);
90
90
  if (error) {
91
- throw new Error(`Error searching for documents: ${error}`);
91
+ throw new Error(`Error searching for documents: ${error.code} ${error.message} ${error.details}`);
92
92
  }
93
93
  return searches.map((resp) => [
94
94
  new document_js_1.Document({
@@ -67,7 +67,7 @@ export class SupabaseHybridSearch extends BaseRetriever {
67
67
  };
68
68
  const { data: searches, error } = await this.client.rpc(this.similarityQueryName, matchDocumentsParams);
69
69
  if (error) {
70
- throw new Error(`Error searching for documents: ${error}`);
70
+ throw new Error(`Error searching for documents: ${error.code} ${error.message} ${error.details}`);
71
71
  }
72
72
  return searches.map((resp) => [
73
73
  new Document({
@@ -85,7 +85,7 @@ export class SupabaseHybridSearch extends BaseRetriever {
85
85
  };
86
86
  const { data: searches, error } = await this.client.rpc(this.keywordQueryName, kwMatchDocumentsParams);
87
87
  if (error) {
88
- throw new Error(`Error searching for documents: ${error}`);
88
+ throw new Error(`Error searching for documents: ${error.code} ${error.message} ${error.details}`);
89
89
  }
90
90
  return searches.map((resp) => [
91
91
  new Document({
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseFileStore = exports.BaseCache = exports.BaseChatMessageHistory = exports.OutputParserException = exports.BaseOutputParser = exports.BaseRetriever = exports.BasePromptValue = exports.ChatMessage = exports.SystemChatMessage = exports.AIChatMessage = exports.HumanChatMessage = exports.BaseChatMessage = exports.RUN_KEY = void 0;
3
+ exports.BaseFileStore = exports.BaseCache = exports.BaseChatMessageHistory = exports.BaseRetriever = exports.BasePromptValue = exports.ChatMessage = exports.SystemChatMessage = exports.AIChatMessage = exports.HumanChatMessage = exports.BaseChatMessage = exports.RUN_KEY = void 0;
4
4
  exports.RUN_KEY = "__run";
5
5
  class BaseChatMessage {
6
6
  constructor(text) {
@@ -68,26 +68,6 @@ exports.BasePromptValue = BasePromptValue;
68
68
  class BaseRetriever {
69
69
  }
70
70
  exports.BaseRetriever = BaseRetriever;
71
- /** Class to parse the output of an LLM call.
72
- */
73
- class BaseOutputParser {
74
- async parseWithPrompt(text, _prompt) {
75
- return this.parse(text);
76
- }
77
- /**
78
- * Return the string type key uniquely identifying this class of parser
79
- */
80
- _type() {
81
- throw new Error("_type not implemented");
82
- }
83
- }
84
- exports.BaseOutputParser = BaseOutputParser;
85
- class OutputParserException extends Error {
86
- constructor(message) {
87
- super(message);
88
- }
89
- }
90
- exports.OutputParserException = OutputParserException;
91
71
  class BaseChatMessageHistory {
92
72
  }
93
73
  exports.BaseChatMessageHistory = BaseChatMessageHistory;
@@ -92,36 +92,6 @@ export type ChainValues = Record<string, any>;
92
92
  export declare abstract class BaseRetriever {
93
93
  abstract getRelevantDocuments(query: string): Promise<Document[]>;
94
94
  }
95
- /** Class to parse the output of an LLM call.
96
- */
97
- export declare abstract class BaseOutputParser<T = unknown> {
98
- /**
99
- * Parse the output of an LLM call.
100
- *
101
- * @param text - LLM output to parse.
102
- * @returns Parsed output.
103
- */
104
- abstract parse(text: string): Promise<T>;
105
- parseWithPrompt(text: string, _prompt: BasePromptValue): Promise<T>;
106
- /**
107
- * Return a string describing the format of the output.
108
- * @returns Format instructions.
109
- * @example
110
- * ```json
111
- * {
112
- * "foo": "bar"
113
- * }
114
- * ```
115
- */
116
- abstract getFormatInstructions(): string;
117
- /**
118
- * Return the string type key uniquely identifying this class of parser
119
- */
120
- _type(): string;
121
- }
122
- export declare class OutputParserException extends Error {
123
- constructor(message: string);
124
- }
125
95
  export declare abstract class BaseChatMessageHistory {
126
96
  abstract getMessages(): Promise<BaseChatMessage[]>;
127
97
  abstract addUserMessage(message: string): Promise<void>;
@@ -58,24 +58,6 @@ export class BasePromptValue {
58
58
  */
59
59
  export class BaseRetriever {
60
60
  }
61
- /** Class to parse the output of an LLM call.
62
- */
63
- export class BaseOutputParser {
64
- async parseWithPrompt(text, _prompt) {
65
- return this.parse(text);
66
- }
67
- /**
68
- * Return the string type key uniquely identifying this class of parser
69
- */
70
- _type() {
71
- throw new Error("_type not implemented");
72
- }
73
- }
74
- export class OutputParserException extends Error {
75
- constructor(message) {
76
- super(message);
77
- }
78
- }
79
61
  export class BaseChatMessageHistory {
80
62
  }
81
63
  export class BaseCache {
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OutputParserException = exports.BaseOutputParser = void 0;
4
+ /** Class to parse the output of an LLM call.
5
+ */
6
+ class BaseOutputParser {
7
+ async parseWithPrompt(text, _prompt, callbacks) {
8
+ return this.parse(text, callbacks);
9
+ }
10
+ /**
11
+ * Return the string type key uniquely identifying this class of parser
12
+ */
13
+ _type() {
14
+ throw new Error("_type not implemented");
15
+ }
16
+ }
17
+ exports.BaseOutputParser = BaseOutputParser;
18
+ class OutputParserException extends Error {
19
+ constructor(message) {
20
+ super(message);
21
+ }
22
+ }
23
+ exports.OutputParserException = OutputParserException;
@@ -0,0 +1,32 @@
1
+ import { Callbacks } from "../callbacks/manager.js";
2
+ import { BasePromptValue } from "./index.js";
3
+ /** Class to parse the output of an LLM call.
4
+ */
5
+ export declare abstract class BaseOutputParser<T = unknown> {
6
+ /**
7
+ * Parse the output of an LLM call.
8
+ *
9
+ * @param text - LLM output to parse.
10
+ * @returns Parsed output.
11
+ */
12
+ abstract parse(text: string, callbacks?: Callbacks): Promise<T>;
13
+ parseWithPrompt(text: string, _prompt: BasePromptValue, callbacks?: Callbacks): Promise<T>;
14
+ /**
15
+ * Return a string describing the format of the output.
16
+ * @returns Format instructions.
17
+ * @example
18
+ * ```json
19
+ * {
20
+ * "foo": "bar"
21
+ * }
22
+ * ```
23
+ */
24
+ abstract getFormatInstructions(): string;
25
+ /**
26
+ * Return the string type key uniquely identifying this class of parser
27
+ */
28
+ _type(): string;
29
+ }
30
+ export declare class OutputParserException extends Error {
31
+ constructor(message: string);
32
+ }
@@ -0,0 +1,18 @@
1
+ /** Class to parse the output of an LLM call.
2
+ */
3
+ export class BaseOutputParser {
4
+ async parseWithPrompt(text, _prompt, callbacks) {
5
+ return this.parse(text, callbacks);
6
+ }
7
+ /**
8
+ * Return the string type key uniquely identifying this class of parser
9
+ */
10
+ _type() {
11
+ throw new Error("_type not implemented");
12
+ }
13
+ }
14
+ export class OutputParserException extends Error {
15
+ constructor(message) {
16
+ super(message);
17
+ }
18
+ }
@@ -5,8 +5,8 @@ const zod_1 = require("zod");
5
5
  const manager_js_1 = require("../callbacks/manager.cjs");
6
6
  const index_js_1 = require("../base_language/index.cjs");
7
7
  class StructuredTool extends index_js_1.BaseLangChain {
8
- constructor(verbose, callbacks) {
9
- super({ verbose, callbacks });
8
+ constructor(fields) {
9
+ super(fields ?? {});
10
10
  Object.defineProperty(this, "returnDirect", {
11
11
  enumerable: true,
12
12
  configurable: true,
@@ -32,8 +32,8 @@ class StructuredTool extends index_js_1.BaseLangChain {
32
32
  }
33
33
  exports.StructuredTool = StructuredTool;
34
34
  class Tool extends StructuredTool {
35
- constructor() {
36
- super(...arguments);
35
+ constructor(verbose, callbacks) {
36
+ super({ verbose, callbacks });
37
37
  Object.defineProperty(this, "schema", {
38
38
  enumerable: true,
39
39
  configurable: true,
@@ -1,16 +1,12 @@
1
1
  import { z } from "zod";
2
- import { CallbackManager, CallbackManagerForToolRun, Callbacks } from "../callbacks/manager.js";
2
+ import { CallbackManagerForToolRun, Callbacks } from "../callbacks/manager.js";
3
3
  import { BaseLangChain, BaseLangChainParams } from "../base_language/index.js";
4
4
  export interface ToolParams extends BaseLangChainParams {
5
- /**
6
- * @deprecated Use `callbacks` instead
7
- */
8
- callbackManager?: CallbackManager;
9
5
  }
10
6
  export declare abstract class StructuredTool<T extends z.ZodObject<any, any, any, any> = z.ZodObject<any, any, any, any>> extends BaseLangChain {
11
7
  abstract schema: T | z.ZodEffects<T>;
12
- constructor(verbose?: boolean, callbacks?: Callbacks);
13
- protected abstract _call(arg: z.output<T>, callbackManager?: CallbackManagerForToolRun): Promise<string>;
8
+ constructor(fields?: ToolParams);
9
+ protected abstract _call(arg: z.output<T>, runManager?: CallbackManagerForToolRun): Promise<string>;
14
10
  call(arg: (z.output<T> extends string ? string : never) | z.input<T>, callbacks?: Callbacks): Promise<string>;
15
11
  abstract name: string;
16
12
  abstract description: string;
@@ -26,5 +22,6 @@ export declare abstract class Tool extends StructuredTool {
26
22
  }>, string | undefined, {
27
23
  input?: string | undefined;
28
24
  }>;
25
+ constructor(verbose?: boolean, callbacks?: Callbacks);
29
26
  call(arg: string | undefined | z.input<this["schema"]>, callbacks?: Callbacks): Promise<string>;
30
27
  }
@@ -2,8 +2,8 @@ import { z } from "zod";
2
2
  import { CallbackManager, } from "../callbacks/manager.js";
3
3
  import { BaseLangChain } from "../base_language/index.js";
4
4
  export class StructuredTool extends BaseLangChain {
5
- constructor(verbose, callbacks) {
6
- super({ verbose, callbacks });
5
+ constructor(fields) {
6
+ super(fields ?? {});
7
7
  Object.defineProperty(this, "returnDirect", {
8
8
  enumerable: true,
9
9
  configurable: true,
@@ -28,8 +28,8 @@ export class StructuredTool extends BaseLangChain {
28
28
  }
29
29
  }
30
30
  export class Tool extends StructuredTool {
31
- constructor() {
32
- super(...arguments);
31
+ constructor(verbose, callbacks) {
32
+ super({ verbose, callbacks });
33
33
  Object.defineProperty(this, "schema", {
34
34
  enumerable: true,
35
35
  configurable: true,
package/dist/tools/fs.cjs CHANGED
@@ -4,8 +4,8 @@ exports.WriteFileTool = exports.ReadFileTool = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const base_js_1 = require("./base.cjs");
6
6
  class ReadFileTool extends base_js_1.StructuredTool {
7
- constructor({ verbose, callbacks, store }) {
8
- super(verbose, callbacks);
7
+ constructor({ store, ...rest }) {
8
+ super(rest);
9
9
  Object.defineProperty(this, "schema", {
10
10
  enumerable: true,
11
11
  configurable: true,
@@ -40,8 +40,8 @@ class ReadFileTool extends base_js_1.StructuredTool {
40
40
  }
41
41
  exports.ReadFileTool = ReadFileTool;
42
42
  class WriteFileTool extends base_js_1.StructuredTool {
43
- constructor({ verbose, callbacks, store }) {
44
- super(verbose, callbacks);
43
+ constructor({ store, ...rest }) {
44
+ super(rest);
45
45
  Object.defineProperty(this, "schema", {
46
46
  enumerable: true,
47
47
  configurable: true,
@@ -15,7 +15,7 @@ export declare class ReadFileTool extends StructuredTool {
15
15
  name: string;
16
16
  description: string;
17
17
  store: BaseFileStore;
18
- constructor({ verbose, callbacks, store }: ReadFileParams);
18
+ constructor({ store, ...rest }: ReadFileParams);
19
19
  _call({ file_path }: z.infer<typeof this.schema>): Promise<string>;
20
20
  }
21
21
  interface WriteFileParams extends ToolParams {
@@ -35,7 +35,7 @@ export declare class WriteFileTool extends StructuredTool {
35
35
  name: string;
36
36
  description: string;
37
37
  store: BaseFileStore;
38
- constructor({ verbose, callbacks, store }: WriteFileParams);
38
+ constructor({ store, ...rest }: WriteFileParams);
39
39
  _call({ file_path, text }: z.infer<typeof this.schema>): Promise<string>;
40
40
  }
41
41
  export {};
package/dist/tools/fs.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { z } from "zod";
2
2
  import { StructuredTool } from "./base.js";
3
3
  export class ReadFileTool extends StructuredTool {
4
- constructor({ verbose, callbacks, store }) {
5
- super(verbose, callbacks);
4
+ constructor({ store, ...rest }) {
5
+ super(rest);
6
6
  Object.defineProperty(this, "schema", {
7
7
  enumerable: true,
8
8
  configurable: true,
@@ -36,8 +36,8 @@ export class ReadFileTool extends StructuredTool {
36
36
  }
37
37
  }
38
38
  export class WriteFileTool extends StructuredTool {
39
- constructor({ verbose, callbacks, store }) {
40
- super(verbose, callbacks);
39
+ constructor({ store, ...rest }) {
40
+ super(rest);
41
41
  Object.defineProperty(this, "schema", {
42
42
  enumerable: true,
43
43
  configurable: true,