langchain 0.2.9 → 0.2.10

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.
@@ -478,6 +478,9 @@ class AgentExecutor extends base_js_1.BaseChain {
478
478
  observation = tool
479
479
  ? await tool.invoke(action.toolInput, (0, runnables_1.patchConfig)(config, { callbacks: runManager?.getChild() }))
480
480
  : `${action.tool} is not a valid tool, try another one.`;
481
+ if (typeof observation !== "string") {
482
+ throw new Error("Received unsupported non-string response from tool call.");
483
+ }
481
484
  }
482
485
  catch (e) {
483
486
  // eslint-disable-next-line no-instanceof/no-instanceof
@@ -573,6 +576,9 @@ class AgentExecutor extends base_js_1.BaseChain {
573
576
  const tool = nameToolMap[agentAction.tool];
574
577
  try {
575
578
  observation = await tool.call(agentAction.toolInput, runManager?.getChild());
579
+ if (typeof observation !== "string") {
580
+ throw new Error("Received unsupported non-string response from tool call.");
581
+ }
576
582
  }
577
583
  catch (e) {
578
584
  // eslint-disable-next-line no-instanceof/no-instanceof
@@ -473,6 +473,9 @@ export class AgentExecutor extends BaseChain {
473
473
  observation = tool
474
474
  ? await tool.invoke(action.toolInput, patchConfig(config, { callbacks: runManager?.getChild() }))
475
475
  : `${action.tool} is not a valid tool, try another one.`;
476
+ if (typeof observation !== "string") {
477
+ throw new Error("Received unsupported non-string response from tool call.");
478
+ }
476
479
  }
477
480
  catch (e) {
478
481
  // eslint-disable-next-line no-instanceof/no-instanceof
@@ -568,6 +571,9 @@ export class AgentExecutor extends BaseChain {
568
571
  const tool = nameToolMap[agentAction.tool];
569
572
  try {
570
573
  observation = await tool.call(agentAction.toolInput, runManager?.getChild());
574
+ if (typeof observation !== "string") {
575
+ throw new Error("Received unsupported non-string response from tool call.");
576
+ }
571
577
  }
572
578
  catch (e) {
573
579
  // eslint-disable-next-line no-instanceof/no-instanceof
@@ -211,7 +211,7 @@ class ParentDocumentRetriever extends multi_vector_js_1.MultiVectorRetriever {
211
211
  pageContent: subDoc.pageContent,
212
212
  metadata: { ...subDoc.metadata, [this.idKey]: parentDocId },
213
213
  }));
214
- await this._storeDocuments(parentDoc, taggedSubDocs, addToDocstore);
214
+ await this._storeDocuments({ [parentDocId]: parentDoc }, taggedSubDocs, addToDocstore);
215
215
  }
216
216
  }
217
217
  }
@@ -63,7 +63,7 @@ export declare class ParentDocumentRetriever extends MultiVectorRetriever {
63
63
  documentCompressorFilteringFn?: ParentDocumentRetrieverFields["documentCompressorFilteringFn"];
64
64
  constructor(fields: ParentDocumentRetrieverFields);
65
65
  _getRelevantDocuments(query: string): Promise<Document[]>;
66
- _storeDocuments(parentDoc: Document, childDocs: Document[], addToDocstore: boolean): Promise<void>;
66
+ _storeDocuments(parentDoc: Record<string, Document>, childDocs: Document[], addToDocstore: boolean): Promise<void>;
67
67
  /**
68
68
  * Adds documents to the docstore and vectorstores.
69
69
  * If a retriever is provided, it will be used to add documents instead of the vectorstore.
@@ -185,7 +185,7 @@ export class ParentDocumentRetriever extends MultiVectorRetriever {
185
185
  pageContent: subDoc.pageContent,
186
186
  metadata: { ...subDoc.metadata, [this.idKey]: parentDocId },
187
187
  }));
188
- await this._storeDocuments(parentDoc, taggedSubDocs, addToDocstore);
188
+ await this._storeDocuments({ [parentDocId]: parentDoc }, taggedSubDocs, addToDocstore);
189
189
  }
190
190
  }
191
191
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langchain",
3
- "version": "0.2.9",
3
+ "version": "0.2.10",
4
4
  "description": "Typescript bindings for langchain",
5
5
  "type": "module",
6
6
  "engines": {