langchain 0.1.26 → 0.1.28

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 (34) hide show
  1. package/dist/agents/agent.cjs +137 -10
  2. package/dist/agents/agent.d.ts +37 -5
  3. package/dist/agents/agent.js +133 -9
  4. package/dist/agents/executor.cjs +4 -1
  5. package/dist/agents/executor.js +5 -2
  6. package/dist/agents/openai_functions/index.cjs +6 -2
  7. package/dist/agents/openai_functions/index.d.ts +7 -5
  8. package/dist/agents/openai_functions/index.js +7 -3
  9. package/dist/agents/openai_tools/index.cjs +7 -2
  10. package/dist/agents/openai_tools/index.d.ts +7 -4
  11. package/dist/agents/openai_tools/index.js +7 -2
  12. package/dist/agents/react/index.cjs +7 -2
  13. package/dist/agents/react/index.d.ts +7 -5
  14. package/dist/agents/react/index.js +7 -2
  15. package/dist/agents/structured_chat/index.cjs +6 -2
  16. package/dist/agents/structured_chat/index.d.ts +7 -5
  17. package/dist/agents/structured_chat/index.js +7 -3
  18. package/dist/agents/types.d.ts +21 -3
  19. package/dist/agents/xml/index.cjs +6 -2
  20. package/dist/agents/xml/index.d.ts +7 -5
  21. package/dist/agents/xml/index.js +7 -3
  22. package/dist/document_loaders/fs/unstructured.cjs +40 -0
  23. package/dist/document_loaders/fs/unstructured.d.ts +8 -0
  24. package/dist/document_loaders/fs/unstructured.js +40 -0
  25. package/dist/document_loaders/web/gitbook.cjs +11 -3
  26. package/dist/document_loaders/web/gitbook.d.ts +1 -0
  27. package/dist/document_loaders/web/gitbook.js +11 -3
  28. package/dist/output_parsers/fix.cjs +16 -4
  29. package/dist/output_parsers/fix.d.ts +10 -3
  30. package/dist/output_parsers/fix.js +16 -4
  31. package/dist/retrievers/parent_document.cjs +3 -2
  32. package/dist/retrievers/parent_document.d.ts +3 -1
  33. package/dist/retrievers/parent_document.js +3 -2
  34. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  import { type VectorStoreInterface, type VectorStoreRetrieverInterface } from "@langchain/core/vectorstores";
2
2
  import { Document } from "@langchain/core/documents";
3
- import { TextSplitter } from "../text_splitter.js";
3
+ import { TextSplitter, TextSplitterChunkHeaderOptions } from "../text_splitter.js";
4
4
  import { MultiVectorRetriever, type MultiVectorRetrieverInput } from "./multi_vector.js";
5
5
  /**
6
6
  * Interface for the fields required to initialize a
@@ -69,9 +69,11 @@ export declare class ParentDocumentRetriever extends MultiVectorRetriever {
69
69
  * This can be false if and only if `ids` are provided. You may want
70
70
  * to set this to False if the documents are already in the docstore
71
71
  * and you don't want to re-add them.
72
+ * @param config.chunkHeaderOptions Object with options for adding Contextual chunk headers
72
73
  */
73
74
  addDocuments(docs: Document[], config?: {
74
75
  ids?: string[];
75
76
  addToDocstore?: boolean;
77
+ childDocChunkHeaderOptions?: TextSplitterChunkHeaderOptions;
76
78
  }): Promise<void>;
77
79
  }
@@ -127,9 +127,10 @@ export class ParentDocumentRetriever extends MultiVectorRetriever {
127
127
  * This can be false if and only if `ids` are provided. You may want
128
128
  * to set this to False if the documents are already in the docstore
129
129
  * and you don't want to re-add them.
130
+ * @param config.chunkHeaderOptions Object with options for adding Contextual chunk headers
130
131
  */
131
132
  async addDocuments(docs, config) {
132
- const { ids, addToDocstore = true } = config ?? {};
133
+ const { ids, addToDocstore = true, childDocChunkHeaderOptions = {}, } = config ?? {};
133
134
  const parentDocs = this.parentSplitter
134
135
  ? await this.parentSplitter.splitDocuments(docs)
135
136
  : docs;
@@ -151,7 +152,7 @@ export class ParentDocumentRetriever extends MultiVectorRetriever {
151
152
  for (let i = 0; i < parentDocs.length; i += 1) {
152
153
  const parentDoc = parentDocs[i];
153
154
  const parentDocId = parentDocIds[i];
154
- const subDocs = await this.childSplitter.splitDocuments([parentDoc]);
155
+ const subDocs = await this.childSplitter.splitDocuments([parentDoc], childDocChunkHeaderOptions);
155
156
  const taggedSubDocs = subDocs.map((subDoc) => new Document({
156
157
  pageContent: subDoc.pageContent,
157
158
  metadata: { ...subDoc.metadata, [this.idKey]: parentDocId },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langchain",
3
- "version": "0.1.26",
3
+ "version": "0.1.28",
4
4
  "description": "Typescript bindings for langchain",
5
5
  "type": "module",
6
6
  "engines": {