@langchain/core 1.0.0-alpha.4 → 1.0.0-alpha.6
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.
- package/dist/agents.d.ts.map +1 -1
- package/dist/caches/base.d.cts.map +1 -1
- package/dist/caches/base.d.ts.map +1 -1
- package/dist/callbacks/base.d.cts.map +1 -1
- package/dist/language_models/chat_models.d.cts.map +1 -1
- package/dist/language_models/chat_models.d.ts.map +1 -1
- package/dist/load/import_map.cjs +1 -1
- package/dist/load/import_map.js +1 -1
- package/dist/messages/ai.cjs +19 -14
- package/dist/messages/ai.cjs.map +1 -1
- package/dist/messages/ai.js +19 -14
- package/dist/messages/ai.js.map +1 -1
- package/dist/messages/base.cjs +9 -2
- package/dist/messages/base.cjs.map +1 -1
- package/dist/messages/base.d.cts +2 -2
- package/dist/messages/base.d.cts.map +1 -1
- package/dist/messages/base.d.ts +2 -2
- package/dist/messages/base.d.ts.map +1 -1
- package/dist/messages/base.js +9 -2
- package/dist/messages/base.js.map +1 -1
- package/dist/messages/block_translators/bedrock_converse.cjs +213 -0
- package/dist/messages/block_translators/bedrock_converse.cjs.map +1 -0
- package/dist/messages/block_translators/bedrock_converse.js +213 -0
- package/dist/messages/block_translators/bedrock_converse.js.map +1 -0
- package/dist/messages/block_translators/google_genai.cjs +73 -0
- package/dist/messages/block_translators/google_genai.cjs.map +1 -0
- package/dist/messages/block_translators/google_genai.js +73 -0
- package/dist/messages/block_translators/google_genai.js.map +1 -0
- package/dist/messages/block_translators/google_vertexai.cjs +74 -0
- package/dist/messages/block_translators/google_vertexai.cjs.map +1 -0
- package/dist/messages/block_translators/google_vertexai.js +74 -0
- package/dist/messages/block_translators/google_vertexai.js.map +1 -0
- package/dist/messages/block_translators/index.cjs +10 -1
- package/dist/messages/block_translators/index.cjs.map +1 -1
- package/dist/messages/block_translators/index.js +10 -1
- package/dist/messages/block_translators/index.js.map +1 -1
- package/dist/messages/block_translators/utils.cjs +4 -0
- package/dist/messages/block_translators/utils.cjs.map +1 -1
- package/dist/messages/block_translators/utils.js +4 -1
- package/dist/messages/block_translators/utils.js.map +1 -1
- package/dist/messages/content/index.cjs.map +1 -1
- package/dist/messages/content/index.d.cts +20 -1
- package/dist/messages/content/index.d.cts.map +1 -1
- package/dist/messages/content/index.d.ts +20 -1
- package/dist/messages/content/index.d.ts.map +1 -1
- package/dist/messages/content/index.js.map +1 -1
- package/dist/messages/content/tools.cjs +3 -0
- package/dist/messages/content/tools.cjs.map +1 -1
- package/dist/messages/content/tools.d.cts +67 -6
- package/dist/messages/content/tools.d.cts.map +1 -1
- package/dist/messages/content/tools.d.ts +67 -6
- package/dist/messages/content/tools.d.ts.map +1 -1
- package/dist/messages/content/tools.js +3 -0
- package/dist/messages/content/tools.js.map +1 -1
- package/dist/messages/index.cjs +4 -0
- package/dist/messages/index.cjs.map +1 -1
- package/dist/messages/index.d.cts +2 -2
- package/dist/messages/index.d.ts +2 -2
- package/dist/messages/index.js +4 -2
- package/dist/messages/index.js.map +1 -1
- package/dist/messages/message.cjs.map +1 -1
- package/dist/messages/message.d.cts +6 -6
- package/dist/messages/message.d.cts.map +1 -1
- package/dist/messages/message.d.ts +6 -6
- package/dist/messages/message.d.ts.map +1 -1
- package/dist/messages/message.js.map +1 -1
- package/dist/messages/tool.cjs.map +1 -1
- package/dist/messages/tool.d.cts +3 -1
- package/dist/messages/tool.d.cts.map +1 -1
- package/dist/messages/tool.d.ts +3 -1
- package/dist/messages/tool.d.ts.map +1 -1
- package/dist/messages/tool.js.map +1 -1
- package/dist/utils/testing/chat_models.cjs +245 -0
- package/dist/utils/testing/chat_models.cjs.map +1 -0
- package/dist/utils/testing/chat_models.d.cts +134 -0
- package/dist/utils/testing/chat_models.d.cts.map +1 -0
- package/dist/utils/testing/chat_models.d.ts +134 -0
- package/dist/utils/testing/chat_models.d.ts.map +1 -0
- package/dist/utils/testing/chat_models.js +243 -0
- package/dist/utils/testing/chat_models.js.map +1 -0
- package/dist/utils/testing/embeddings.cjs +90 -0
- package/dist/utils/testing/embeddings.cjs.map +1 -0
- package/dist/utils/testing/embeddings.d.cts +58 -0
- package/dist/utils/testing/embeddings.d.cts.map +1 -0
- package/dist/utils/testing/embeddings.d.ts +58 -0
- package/dist/utils/testing/embeddings.d.ts.map +1 -0
- package/dist/utils/testing/embeddings.js +89 -0
- package/dist/utils/testing/embeddings.js.map +1 -0
- package/dist/utils/testing/index.cjs +42 -655
- package/dist/utils/testing/index.cjs.map +1 -1
- package/dist/utils/testing/index.d.cts +11 -379
- package/dist/utils/testing/index.d.ts +11 -379
- package/dist/utils/testing/index.js +10 -623
- package/dist/utils/testing/index.js.map +1 -1
- package/dist/utils/testing/llms.cjs +59 -0
- package/dist/utils/testing/llms.cjs.map +1 -0
- package/dist/utils/testing/llms.d.cts +31 -0
- package/dist/utils/testing/llms.d.cts.map +1 -0
- package/dist/utils/testing/llms.d.ts +31 -0
- package/dist/utils/testing/llms.d.ts.map +1 -0
- package/dist/utils/testing/llms.js +58 -0
- package/dist/utils/testing/llms.js.map +1 -0
- package/dist/utils/testing/message_history.cjs +67 -0
- package/dist/utils/testing/message_history.cjs.map +1 -0
- package/dist/utils/testing/message_history.d.cts +31 -0
- package/dist/utils/testing/message_history.d.cts.map +1 -0
- package/dist/utils/testing/message_history.d.ts +31 -0
- package/dist/utils/testing/message_history.d.ts.map +1 -0
- package/dist/utils/testing/message_history.js +65 -0
- package/dist/utils/testing/message_history.js.map +1 -0
- package/dist/utils/testing/output_parsers.cjs +20 -0
- package/dist/utils/testing/output_parsers.cjs.map +1 -0
- package/dist/utils/testing/output_parsers.d.cts +16 -0
- package/dist/utils/testing/output_parsers.d.cts.map +1 -0
- package/dist/utils/testing/output_parsers.d.ts +16 -0
- package/dist/utils/testing/output_parsers.d.ts.map +1 -0
- package/dist/utils/testing/output_parsers.js +20 -0
- package/dist/utils/testing/output_parsers.js.map +1 -0
- package/dist/utils/testing/retrievers.cjs +19 -0
- package/dist/utils/testing/retrievers.cjs.map +1 -0
- package/dist/utils/testing/retrievers.d.cts +17 -0
- package/dist/utils/testing/retrievers.d.cts.map +1 -0
- package/dist/utils/testing/retrievers.d.ts +17 -0
- package/dist/utils/testing/retrievers.d.ts.map +1 -0
- package/dist/utils/testing/retrievers.js +19 -0
- package/dist/utils/testing/retrievers.js.map +1 -0
- package/dist/utils/testing/runnables.cjs +19 -0
- package/dist/utils/testing/runnables.cjs.map +1 -0
- package/dist/utils/testing/runnables.d.cts +15 -0
- package/dist/utils/testing/runnables.d.cts.map +1 -0
- package/dist/utils/testing/runnables.d.ts +15 -0
- package/dist/utils/testing/runnables.d.ts.map +1 -0
- package/dist/utils/testing/runnables.js +19 -0
- package/dist/utils/testing/runnables.js.map +1 -0
- package/dist/utils/testing/tools.cjs +21 -0
- package/dist/utils/testing/tools.cjs.map +1 -0
- package/dist/utils/testing/tools.d.cts +21 -0
- package/dist/utils/testing/tools.d.cts.map +1 -0
- package/dist/utils/testing/tools.d.ts +21 -0
- package/dist/utils/testing/tools.d.ts.map +1 -0
- package/dist/utils/testing/tools.js +21 -0
- package/dist/utils/testing/tools.js.map +1 -0
- package/dist/utils/testing/tracers.cjs +25 -0
- package/dist/utils/testing/tracers.cjs.map +1 -0
- package/dist/utils/testing/tracers.d.cts +15 -0
- package/dist/utils/testing/tracers.d.cts.map +1 -0
- package/dist/utils/testing/tracers.d.ts +15 -0
- package/dist/utils/testing/tracers.d.ts.map +1 -0
- package/dist/utils/testing/tracers.js +25 -0
- package/dist/utils/testing/tracers.js.map +1 -0
- package/dist/utils/testing/vectorstores.cjs +129 -0
- package/dist/utils/testing/vectorstores.cjs.map +1 -0
- package/dist/utils/testing/vectorstores.d.cts +101 -0
- package/dist/utils/testing/vectorstores.d.cts.map +1 -0
- package/dist/utils/testing/vectorstores.d.ts +101 -0
- package/dist/utils/testing/vectorstores.d.ts.map +1 -0
- package/dist/utils/testing/vectorstores.js +129 -0
- package/dist/utils/testing/vectorstores.js.map +1 -0
- package/dist/utils/types/index.cjs +2 -0
- package/dist/utils/types/index.d.cts +2 -2
- package/dist/utils/types/index.d.ts +2 -2
- package/dist/utils/types/index.js +3 -2
- package/dist/utils/types/zod.cjs +39 -3
- package/dist/utils/types/zod.cjs.map +1 -1
- package/dist/utils/types/zod.d.cts +18 -1
- package/dist/utils/types/zod.d.cts.map +1 -1
- package/dist/utils/types/zod.d.ts +18 -1
- package/dist/utils/types/zod.d.ts.map +1 -1
- package/dist/utils/types/zod.js +39 -4
- package/dist/utils/types/zod.js.map +1 -1
- package/package.json +1 -1
- package/dist/utils/testing/index.d.cts.map +0 -1
- package/dist/utils/testing/index.d.ts.map +0 -1
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { Document } from "../../documents/document.cjs";
|
|
2
|
+
import { EmbeddingsInterface } from "../../embeddings.cjs";
|
|
3
|
+
import { VectorStore } from "../../vectorstores.cjs";
|
|
4
|
+
import { cosine } from "../ml-distance/similarities.cjs";
|
|
5
|
+
|
|
6
|
+
//#region src/utils/testing/vectorstores.d.ts
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Interface representing a vector in memory. It includes the content
|
|
10
|
+
* (text), the corresponding embedding (vector), and any associated
|
|
11
|
+
* metadata.
|
|
12
|
+
*/
|
|
13
|
+
interface MemoryVector {
|
|
14
|
+
content: string;
|
|
15
|
+
embedding: number[];
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
+
metadata: Record<string, any>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Interface for the arguments that can be passed to the
|
|
21
|
+
* `FakeVectorStore` constructor. It includes an optional `similarity`
|
|
22
|
+
* function.
|
|
23
|
+
*/
|
|
24
|
+
interface FakeVectorStoreArgs {
|
|
25
|
+
similarity?: typeof cosine;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Class that extends `VectorStore` to store vectors in memory. Provides
|
|
29
|
+
* methods for adding documents, performing similarity searches, and
|
|
30
|
+
* creating instances from texts, documents, or an existing index.
|
|
31
|
+
*/
|
|
32
|
+
declare class FakeVectorStore extends VectorStore {
|
|
33
|
+
FilterType: (doc: Document) => boolean;
|
|
34
|
+
memoryVectors: MemoryVector[];
|
|
35
|
+
similarity: typeof cosine;
|
|
36
|
+
_vectorstoreType(): string;
|
|
37
|
+
constructor(embeddings: EmbeddingsInterface, {
|
|
38
|
+
similarity,
|
|
39
|
+
...rest
|
|
40
|
+
}?: FakeVectorStoreArgs);
|
|
41
|
+
/**
|
|
42
|
+
* Method to add documents to the memory vector store. It extracts the
|
|
43
|
+
* text from each document, generates embeddings for them, and adds the
|
|
44
|
+
* resulting vectors to the store.
|
|
45
|
+
* @param documents Array of `Document` instances to be added to the store.
|
|
46
|
+
* @returns Promise that resolves when all documents have been added.
|
|
47
|
+
*/
|
|
48
|
+
addDocuments(documents: Document[]): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Method to add vectors to the memory vector store. It creates
|
|
51
|
+
* `MemoryVector` instances for each vector and document pair and adds
|
|
52
|
+
* them to the store.
|
|
53
|
+
* @param vectors Array of vectors to be added to the store.
|
|
54
|
+
* @param documents Array of `Document` instances corresponding to the vectors.
|
|
55
|
+
* @returns Promise that resolves when all vectors have been added.
|
|
56
|
+
*/
|
|
57
|
+
addVectors(vectors: number[][], documents: Document[]): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Method to perform a similarity search in the memory vector store. It
|
|
60
|
+
* calculates the similarity between the query vector and each vector in
|
|
61
|
+
* the store, sorts the results by similarity, and returns the top `k`
|
|
62
|
+
* results along with their scores.
|
|
63
|
+
* @param query Query vector to compare against the vectors in the store.
|
|
64
|
+
* @param k Number of top results to return.
|
|
65
|
+
* @param filter Optional filter function to apply to the vectors before performing the search.
|
|
66
|
+
* @returns Promise that resolves with an array of tuples, each containing a `Document` and its similarity score.
|
|
67
|
+
*/
|
|
68
|
+
similaritySearchVectorWithScore(query: number[], k: number, filter?: this["FilterType"]): Promise<[Document, number][]>;
|
|
69
|
+
/**
|
|
70
|
+
* Static method to create a `FakeVectorStore` instance from an array of
|
|
71
|
+
* texts. It creates a `Document` for each text and metadata pair, and
|
|
72
|
+
* adds them to the store.
|
|
73
|
+
* @param texts Array of texts to be added to the store.
|
|
74
|
+
* @param metadatas Array or single object of metadata corresponding to the texts.
|
|
75
|
+
* @param embeddings `Embeddings` instance used to generate embeddings for the texts.
|
|
76
|
+
* @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.
|
|
77
|
+
* @returns Promise that resolves with a new `FakeVectorStore` instance.
|
|
78
|
+
*/
|
|
79
|
+
static fromTexts(texts: string[], metadatas: object[] | object, embeddings: EmbeddingsInterface, dbConfig?: FakeVectorStoreArgs): Promise<FakeVectorStore>;
|
|
80
|
+
/**
|
|
81
|
+
* Static method to create a `FakeVectorStore` instance from an array of
|
|
82
|
+
* `Document` instances. It adds the documents to the store.
|
|
83
|
+
* @param docs Array of `Document` instances to be added to the store.
|
|
84
|
+
* @param embeddings `Embeddings` instance used to generate embeddings for the documents.
|
|
85
|
+
* @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.
|
|
86
|
+
* @returns Promise that resolves with a new `FakeVectorStore` instance.
|
|
87
|
+
*/
|
|
88
|
+
static fromDocuments(docs: Document[], embeddings: EmbeddingsInterface, dbConfig?: FakeVectorStoreArgs): Promise<FakeVectorStore>;
|
|
89
|
+
/**
|
|
90
|
+
* Static method to create a `FakeVectorStore` instance from an existing
|
|
91
|
+
* index. It creates a new `FakeVectorStore` instance without adding any
|
|
92
|
+
* documents or vectors.
|
|
93
|
+
* @param embeddings `Embeddings` instance used to generate embeddings for the documents.
|
|
94
|
+
* @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.
|
|
95
|
+
* @returns Promise that resolves with a new `FakeVectorStore` instance.
|
|
96
|
+
*/
|
|
97
|
+
static fromExistingIndex(embeddings: EmbeddingsInterface, dbConfig?: FakeVectorStoreArgs): Promise<FakeVectorStore>;
|
|
98
|
+
}
|
|
99
|
+
//#endregion
|
|
100
|
+
export { FakeVectorStore, FakeVectorStoreArgs };
|
|
101
|
+
//# sourceMappingURL=vectorstores.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vectorstores.d.cts","names":["Document","EmbeddingsInterface","VectorStore","cosine","MemoryVector","Record","FakeVectorStoreArgs","FakeVectorStore","similarity","Promise"],"sources":["../../../src/utils/testing/vectorstores.d.ts"],"sourcesContent":["import { Document } from \"../../documents/document.js\";\nimport { EmbeddingsInterface } from \"../../embeddings.js\";\nimport { VectorStore } from \"../../vectorstores.js\";\nimport { cosine } from \"../ml-distance/similarities.js\";\n/**\n * Interface representing a vector in memory. It includes the content\n * (text), the corresponding embedding (vector), and any associated\n * metadata.\n */\ninterface MemoryVector {\n content: string;\n embedding: number[];\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n metadata: Record<string, any>;\n}\n/**\n * Interface for the arguments that can be passed to the\n * `FakeVectorStore` constructor. It includes an optional `similarity`\n * function.\n */\nexport interface FakeVectorStoreArgs {\n similarity?: typeof cosine;\n}\n/**\n * Class that extends `VectorStore` to store vectors in memory. Provides\n * methods for adding documents, performing similarity searches, and\n * creating instances from texts, documents, or an existing index.\n */\nexport declare class FakeVectorStore extends VectorStore {\n FilterType: (doc: Document) => boolean;\n memoryVectors: MemoryVector[];\n similarity: typeof cosine;\n _vectorstoreType(): string;\n constructor(embeddings: EmbeddingsInterface, { similarity, ...rest }?: FakeVectorStoreArgs);\n /**\n * Method to add documents to the memory vector store. It extracts the\n * text from each document, generates embeddings for them, and adds the\n * resulting vectors to the store.\n * @param documents Array of `Document` instances to be added to the store.\n * @returns Promise that resolves when all documents have been added.\n */\n addDocuments(documents: Document[]): Promise<void>;\n /**\n * Method to add vectors to the memory vector store. It creates\n * `MemoryVector` instances for each vector and document pair and adds\n * them to the store.\n * @param vectors Array of vectors to be added to the store.\n * @param documents Array of `Document` instances corresponding to the vectors.\n * @returns Promise that resolves when all vectors have been added.\n */\n addVectors(vectors: number[][], documents: Document[]): Promise<void>;\n /**\n * Method to perform a similarity search in the memory vector store. It\n * calculates the similarity between the query vector and each vector in\n * the store, sorts the results by similarity, and returns the top `k`\n * results along with their scores.\n * @param query Query vector to compare against the vectors in the store.\n * @param k Number of top results to return.\n * @param filter Optional filter function to apply to the vectors before performing the search.\n * @returns Promise that resolves with an array of tuples, each containing a `Document` and its similarity score.\n */\n similaritySearchVectorWithScore(query: number[], k: number, filter?: this[\"FilterType\"]): Promise<[Document, number][]>;\n /**\n * Static method to create a `FakeVectorStore` instance from an array of\n * texts. It creates a `Document` for each text and metadata pair, and\n * adds them to the store.\n * @param texts Array of texts to be added to the store.\n * @param metadatas Array or single object of metadata corresponding to the texts.\n * @param embeddings `Embeddings` instance used to generate embeddings for the texts.\n * @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.\n * @returns Promise that resolves with a new `FakeVectorStore` instance.\n */\n static fromTexts(texts: string[], metadatas: object[] | object, embeddings: EmbeddingsInterface, dbConfig?: FakeVectorStoreArgs): Promise<FakeVectorStore>;\n /**\n * Static method to create a `FakeVectorStore` instance from an array of\n * `Document` instances. It adds the documents to the store.\n * @param docs Array of `Document` instances to be added to the store.\n * @param embeddings `Embeddings` instance used to generate embeddings for the documents.\n * @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.\n * @returns Promise that resolves with a new `FakeVectorStore` instance.\n */\n static fromDocuments(docs: Document[], embeddings: EmbeddingsInterface, dbConfig?: FakeVectorStoreArgs): Promise<FakeVectorStore>;\n /**\n * Static method to create a `FakeVectorStore` instance from an existing\n * index. It creates a new `FakeVectorStore` instance without adding any\n * documents or vectors.\n * @param embeddings `Embeddings` instance used to generate embeddings for the documents.\n * @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.\n * @returns Promise that resolves with a new `FakeVectorStore` instance.\n */\n static fromExistingIndex(embeddings: EmbeddingsInterface, dbConfig?: FakeVectorStoreArgs): Promise<FakeVectorStore>;\n}\nexport {};\n"],"mappings":";;;;;;;;;AAGwD;AAiBxD;AAQA;UAnBUI,YAAAA,CAmB0B;EAAA,OACdJ,EAAAA,MAAAA;EAAQ,SACXI,EAAAA,MAAAA,EAAAA;EAAY;EACF,QAEDH,EApBdI,MAoBcJ,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA;;;;;;;AA4B2ED,UAzCtFM,mBAAAA,CAyCsFN;EAAQ,UAAjBS,CAAAA,EAAAA,OAxCtEN,MAwCsEM;;;;;;;AAoBPH,cArDlEC,eAAAA,SAAwBL,WAAAA,CAqD0CI;EAAmB,UAAWC,EAAAA,CAAAA,GAAAA,EApD/FP,QAoD+FO,EAAAA,GAAAA,OAAAA;EAAe,aAAvBE,EAnD1FL,YAmD0FK,EAAAA;EAAO,UAS3ER,EAAAA,OA3DlBE,MA2DkBF;EAAmB,gBAAaK,CAAAA,CAAAA,EAAAA,MAAAA;EAAmB,WAAWC,CAAAA,UAAAA,EAzD3EN,mBAyD2EM,EAAAA;IAAAA,UAAAA;IAAAA,GAAAA;EAAAA,CAAAA,CAAAA,EAzD5BD,mBAyD4BC;EAAe;;AA9D9D;;;;;0BAa5BP,aAAaS;;;;;;;;;6CASMT,aAAaS;;;;;;;;;;;4FAWkCA,SAAST;;;;;;;;;;;8EAWvBC,gCAAgCK,sBAAsBG,QAAQF;;;;;;;;;6BAS/GP,wBAAwBC,gCAAgCK,sBAAsBG,QAAQF;;;;;;;;;uCAS5EN,gCAAgCK,sBAAsBG,QAAQF"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { Document } from "../../documents/document.js";
|
|
2
|
+
import { EmbeddingsInterface } from "../../embeddings.js";
|
|
3
|
+
import { VectorStore } from "../../vectorstores.js";
|
|
4
|
+
import { cosine } from "../ml-distance/similarities.js";
|
|
5
|
+
|
|
6
|
+
//#region src/utils/testing/vectorstores.d.ts
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Interface representing a vector in memory. It includes the content
|
|
10
|
+
* (text), the corresponding embedding (vector), and any associated
|
|
11
|
+
* metadata.
|
|
12
|
+
*/
|
|
13
|
+
interface MemoryVector {
|
|
14
|
+
content: string;
|
|
15
|
+
embedding: number[];
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
+
metadata: Record<string, any>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Interface for the arguments that can be passed to the
|
|
21
|
+
* `FakeVectorStore` constructor. It includes an optional `similarity`
|
|
22
|
+
* function.
|
|
23
|
+
*/
|
|
24
|
+
interface FakeVectorStoreArgs {
|
|
25
|
+
similarity?: typeof cosine;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Class that extends `VectorStore` to store vectors in memory. Provides
|
|
29
|
+
* methods for adding documents, performing similarity searches, and
|
|
30
|
+
* creating instances from texts, documents, or an existing index.
|
|
31
|
+
*/
|
|
32
|
+
declare class FakeVectorStore extends VectorStore {
|
|
33
|
+
FilterType: (doc: Document) => boolean;
|
|
34
|
+
memoryVectors: MemoryVector[];
|
|
35
|
+
similarity: typeof cosine;
|
|
36
|
+
_vectorstoreType(): string;
|
|
37
|
+
constructor(embeddings: EmbeddingsInterface, {
|
|
38
|
+
similarity,
|
|
39
|
+
...rest
|
|
40
|
+
}?: FakeVectorStoreArgs);
|
|
41
|
+
/**
|
|
42
|
+
* Method to add documents to the memory vector store. It extracts the
|
|
43
|
+
* text from each document, generates embeddings for them, and adds the
|
|
44
|
+
* resulting vectors to the store.
|
|
45
|
+
* @param documents Array of `Document` instances to be added to the store.
|
|
46
|
+
* @returns Promise that resolves when all documents have been added.
|
|
47
|
+
*/
|
|
48
|
+
addDocuments(documents: Document[]): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Method to add vectors to the memory vector store. It creates
|
|
51
|
+
* `MemoryVector` instances for each vector and document pair and adds
|
|
52
|
+
* them to the store.
|
|
53
|
+
* @param vectors Array of vectors to be added to the store.
|
|
54
|
+
* @param documents Array of `Document` instances corresponding to the vectors.
|
|
55
|
+
* @returns Promise that resolves when all vectors have been added.
|
|
56
|
+
*/
|
|
57
|
+
addVectors(vectors: number[][], documents: Document[]): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Method to perform a similarity search in the memory vector store. It
|
|
60
|
+
* calculates the similarity between the query vector and each vector in
|
|
61
|
+
* the store, sorts the results by similarity, and returns the top `k`
|
|
62
|
+
* results along with their scores.
|
|
63
|
+
* @param query Query vector to compare against the vectors in the store.
|
|
64
|
+
* @param k Number of top results to return.
|
|
65
|
+
* @param filter Optional filter function to apply to the vectors before performing the search.
|
|
66
|
+
* @returns Promise that resolves with an array of tuples, each containing a `Document` and its similarity score.
|
|
67
|
+
*/
|
|
68
|
+
similaritySearchVectorWithScore(query: number[], k: number, filter?: this["FilterType"]): Promise<[Document, number][]>;
|
|
69
|
+
/**
|
|
70
|
+
* Static method to create a `FakeVectorStore` instance from an array of
|
|
71
|
+
* texts. It creates a `Document` for each text and metadata pair, and
|
|
72
|
+
* adds them to the store.
|
|
73
|
+
* @param texts Array of texts to be added to the store.
|
|
74
|
+
* @param metadatas Array or single object of metadata corresponding to the texts.
|
|
75
|
+
* @param embeddings `Embeddings` instance used to generate embeddings for the texts.
|
|
76
|
+
* @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.
|
|
77
|
+
* @returns Promise that resolves with a new `FakeVectorStore` instance.
|
|
78
|
+
*/
|
|
79
|
+
static fromTexts(texts: string[], metadatas: object[] | object, embeddings: EmbeddingsInterface, dbConfig?: FakeVectorStoreArgs): Promise<FakeVectorStore>;
|
|
80
|
+
/**
|
|
81
|
+
* Static method to create a `FakeVectorStore` instance from an array of
|
|
82
|
+
* `Document` instances. It adds the documents to the store.
|
|
83
|
+
* @param docs Array of `Document` instances to be added to the store.
|
|
84
|
+
* @param embeddings `Embeddings` instance used to generate embeddings for the documents.
|
|
85
|
+
* @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.
|
|
86
|
+
* @returns Promise that resolves with a new `FakeVectorStore` instance.
|
|
87
|
+
*/
|
|
88
|
+
static fromDocuments(docs: Document[], embeddings: EmbeddingsInterface, dbConfig?: FakeVectorStoreArgs): Promise<FakeVectorStore>;
|
|
89
|
+
/**
|
|
90
|
+
* Static method to create a `FakeVectorStore` instance from an existing
|
|
91
|
+
* index. It creates a new `FakeVectorStore` instance without adding any
|
|
92
|
+
* documents or vectors.
|
|
93
|
+
* @param embeddings `Embeddings` instance used to generate embeddings for the documents.
|
|
94
|
+
* @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.
|
|
95
|
+
* @returns Promise that resolves with a new `FakeVectorStore` instance.
|
|
96
|
+
*/
|
|
97
|
+
static fromExistingIndex(embeddings: EmbeddingsInterface, dbConfig?: FakeVectorStoreArgs): Promise<FakeVectorStore>;
|
|
98
|
+
}
|
|
99
|
+
//#endregion
|
|
100
|
+
export { FakeVectorStore, FakeVectorStoreArgs };
|
|
101
|
+
//# sourceMappingURL=vectorstores.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vectorstores.d.ts","names":["Document","EmbeddingsInterface","VectorStore","cosine","MemoryVector","Record","FakeVectorStoreArgs","FakeVectorStore","similarity","Promise"],"sources":["../../../src/utils/testing/vectorstores.d.ts"],"sourcesContent":["import { Document } from \"../../documents/document.js\";\nimport { EmbeddingsInterface } from \"../../embeddings.js\";\nimport { VectorStore } from \"../../vectorstores.js\";\nimport { cosine } from \"../ml-distance/similarities.js\";\n/**\n * Interface representing a vector in memory. It includes the content\n * (text), the corresponding embedding (vector), and any associated\n * metadata.\n */\ninterface MemoryVector {\n content: string;\n embedding: number[];\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n metadata: Record<string, any>;\n}\n/**\n * Interface for the arguments that can be passed to the\n * `FakeVectorStore` constructor. It includes an optional `similarity`\n * function.\n */\nexport interface FakeVectorStoreArgs {\n similarity?: typeof cosine;\n}\n/**\n * Class that extends `VectorStore` to store vectors in memory. Provides\n * methods for adding documents, performing similarity searches, and\n * creating instances from texts, documents, or an existing index.\n */\nexport declare class FakeVectorStore extends VectorStore {\n FilterType: (doc: Document) => boolean;\n memoryVectors: MemoryVector[];\n similarity: typeof cosine;\n _vectorstoreType(): string;\n constructor(embeddings: EmbeddingsInterface, { similarity, ...rest }?: FakeVectorStoreArgs);\n /**\n * Method to add documents to the memory vector store. It extracts the\n * text from each document, generates embeddings for them, and adds the\n * resulting vectors to the store.\n * @param documents Array of `Document` instances to be added to the store.\n * @returns Promise that resolves when all documents have been added.\n */\n addDocuments(documents: Document[]): Promise<void>;\n /**\n * Method to add vectors to the memory vector store. It creates\n * `MemoryVector` instances for each vector and document pair and adds\n * them to the store.\n * @param vectors Array of vectors to be added to the store.\n * @param documents Array of `Document` instances corresponding to the vectors.\n * @returns Promise that resolves when all vectors have been added.\n */\n addVectors(vectors: number[][], documents: Document[]): Promise<void>;\n /**\n * Method to perform a similarity search in the memory vector store. It\n * calculates the similarity between the query vector and each vector in\n * the store, sorts the results by similarity, and returns the top `k`\n * results along with their scores.\n * @param query Query vector to compare against the vectors in the store.\n * @param k Number of top results to return.\n * @param filter Optional filter function to apply to the vectors before performing the search.\n * @returns Promise that resolves with an array of tuples, each containing a `Document` and its similarity score.\n */\n similaritySearchVectorWithScore(query: number[], k: number, filter?: this[\"FilterType\"]): Promise<[Document, number][]>;\n /**\n * Static method to create a `FakeVectorStore` instance from an array of\n * texts. It creates a `Document` for each text and metadata pair, and\n * adds them to the store.\n * @param texts Array of texts to be added to the store.\n * @param metadatas Array or single object of metadata corresponding to the texts.\n * @param embeddings `Embeddings` instance used to generate embeddings for the texts.\n * @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.\n * @returns Promise that resolves with a new `FakeVectorStore` instance.\n */\n static fromTexts(texts: string[], metadatas: object[] | object, embeddings: EmbeddingsInterface, dbConfig?: FakeVectorStoreArgs): Promise<FakeVectorStore>;\n /**\n * Static method to create a `FakeVectorStore` instance from an array of\n * `Document` instances. It adds the documents to the store.\n * @param docs Array of `Document` instances to be added to the store.\n * @param embeddings `Embeddings` instance used to generate embeddings for the documents.\n * @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.\n * @returns Promise that resolves with a new `FakeVectorStore` instance.\n */\n static fromDocuments(docs: Document[], embeddings: EmbeddingsInterface, dbConfig?: FakeVectorStoreArgs): Promise<FakeVectorStore>;\n /**\n * Static method to create a `FakeVectorStore` instance from an existing\n * index. It creates a new `FakeVectorStore` instance without adding any\n * documents or vectors.\n * @param embeddings `Embeddings` instance used to generate embeddings for the documents.\n * @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.\n * @returns Promise that resolves with a new `FakeVectorStore` instance.\n */\n static fromExistingIndex(embeddings: EmbeddingsInterface, dbConfig?: FakeVectorStoreArgs): Promise<FakeVectorStore>;\n}\nexport {};\n"],"mappings":";;;;;;;;;AAGwD;AAiBxD;AAQA;UAnBUI,YAAAA,CAmB0B;EAAA,OACdJ,EAAAA,MAAAA;EAAQ,SACXI,EAAAA,MAAAA,EAAAA;EAAY;EACF,QAEDH,EApBdI,MAoBcJ,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA;;;;;;;AA4B2ED,UAzCtFM,mBAAAA,CAyCsFN;EAAQ,UAAjBS,CAAAA,EAAAA,OAxCtEN,MAwCsEM;;;;;;;AAoBPH,cArDlEC,eAAAA,SAAwBL,WAAAA,CAqD0CI;EAAmB,UAAWC,EAAAA,CAAAA,GAAAA,EApD/FP,QAoD+FO,EAAAA,GAAAA,OAAAA;EAAe,aAAvBE,EAnD1FL,YAmD0FK,EAAAA;EAAO,UAS3ER,EAAAA,OA3DlBE,MA2DkBF;EAAmB,gBAAaK,CAAAA,CAAAA,EAAAA,MAAAA;EAAmB,WAAWC,CAAAA,UAAAA,EAzD3EN,mBAyD2EM,EAAAA;IAAAA,UAAAA;IAAAA,GAAAA;EAAAA,CAAAA,CAAAA,EAzD5BD,mBAyD4BC;EAAe;;AA9D9D;;;;;0BAa5BP,aAAaS;;;;;;;;;6CASMT,aAAaS;;;;;;;;;;;4FAWkCA,SAAST;;;;;;;;;;;8EAWvBC,gCAAgCK,sBAAsBG,QAAQF;;;;;;;;;6BAS/GP,wBAAwBC,gCAAgCK,sBAAsBG,QAAQF;;;;;;;;;uCAS5EN,gCAAgCK,sBAAsBG,QAAQF"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { VectorStore } from "../../vectorstores.js";
|
|
2
|
+
import { Document } from "../../documents/document.js";
|
|
3
|
+
import { cosine } from "../ml-distance/similarities.js";
|
|
4
|
+
|
|
5
|
+
//#region src/utils/testing/vectorstores.ts
|
|
6
|
+
/**
|
|
7
|
+
* Class that extends `VectorStore` to store vectors in memory. Provides
|
|
8
|
+
* methods for adding documents, performing similarity searches, and
|
|
9
|
+
* creating instances from texts, documents, or an existing index.
|
|
10
|
+
*/
|
|
11
|
+
var FakeVectorStore = class FakeVectorStore extends VectorStore {
|
|
12
|
+
memoryVectors = [];
|
|
13
|
+
similarity;
|
|
14
|
+
_vectorstoreType() {
|
|
15
|
+
return "memory";
|
|
16
|
+
}
|
|
17
|
+
constructor(embeddings, { similarity,...rest } = {}) {
|
|
18
|
+
super(embeddings, rest);
|
|
19
|
+
this.similarity = similarity ?? cosine;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Method to add documents to the memory vector store. It extracts the
|
|
23
|
+
* text from each document, generates embeddings for them, and adds the
|
|
24
|
+
* resulting vectors to the store.
|
|
25
|
+
* @param documents Array of `Document` instances to be added to the store.
|
|
26
|
+
* @returns Promise that resolves when all documents have been added.
|
|
27
|
+
*/
|
|
28
|
+
async addDocuments(documents) {
|
|
29
|
+
const texts = documents.map(({ pageContent }) => pageContent);
|
|
30
|
+
return this.addVectors(await this.embeddings.embedDocuments(texts), documents);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Method to add vectors to the memory vector store. It creates
|
|
34
|
+
* `MemoryVector` instances for each vector and document pair and adds
|
|
35
|
+
* them to the store.
|
|
36
|
+
* @param vectors Array of vectors to be added to the store.
|
|
37
|
+
* @param documents Array of `Document` instances corresponding to the vectors.
|
|
38
|
+
* @returns Promise that resolves when all vectors have been added.
|
|
39
|
+
*/
|
|
40
|
+
async addVectors(vectors, documents) {
|
|
41
|
+
const memoryVectors = vectors.map((embedding, idx) => ({
|
|
42
|
+
content: documents[idx].pageContent,
|
|
43
|
+
embedding,
|
|
44
|
+
metadata: documents[idx].metadata
|
|
45
|
+
}));
|
|
46
|
+
this.memoryVectors = this.memoryVectors.concat(memoryVectors);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Method to perform a similarity search in the memory vector store. It
|
|
50
|
+
* calculates the similarity between the query vector and each vector in
|
|
51
|
+
* the store, sorts the results by similarity, and returns the top `k`
|
|
52
|
+
* results along with their scores.
|
|
53
|
+
* @param query Query vector to compare against the vectors in the store.
|
|
54
|
+
* @param k Number of top results to return.
|
|
55
|
+
* @param filter Optional filter function to apply to the vectors before performing the search.
|
|
56
|
+
* @returns Promise that resolves with an array of tuples, each containing a `Document` and its similarity score.
|
|
57
|
+
*/
|
|
58
|
+
async similaritySearchVectorWithScore(query, k, filter) {
|
|
59
|
+
const filterFunction = (memoryVector) => {
|
|
60
|
+
if (!filter) return true;
|
|
61
|
+
const doc = new Document({
|
|
62
|
+
metadata: memoryVector.metadata,
|
|
63
|
+
pageContent: memoryVector.content
|
|
64
|
+
});
|
|
65
|
+
return filter(doc);
|
|
66
|
+
};
|
|
67
|
+
const filteredMemoryVectors = this.memoryVectors.filter(filterFunction);
|
|
68
|
+
const searches = filteredMemoryVectors.map((vector, index) => ({
|
|
69
|
+
similarity: this.similarity(query, vector.embedding),
|
|
70
|
+
index
|
|
71
|
+
})).sort((a, b) => a.similarity > b.similarity ? -1 : 0).slice(0, k);
|
|
72
|
+
const result = searches.map((search) => [new Document({
|
|
73
|
+
metadata: filteredMemoryVectors[search.index].metadata,
|
|
74
|
+
pageContent: filteredMemoryVectors[search.index].content
|
|
75
|
+
}), search.similarity]);
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Static method to create a `FakeVectorStore` instance from an array of
|
|
80
|
+
* texts. It creates a `Document` for each text and metadata pair, and
|
|
81
|
+
* adds them to the store.
|
|
82
|
+
* @param texts Array of texts to be added to the store.
|
|
83
|
+
* @param metadatas Array or single object of metadata corresponding to the texts.
|
|
84
|
+
* @param embeddings `Embeddings` instance used to generate embeddings for the texts.
|
|
85
|
+
* @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.
|
|
86
|
+
* @returns Promise that resolves with a new `FakeVectorStore` instance.
|
|
87
|
+
*/
|
|
88
|
+
static async fromTexts(texts, metadatas, embeddings, dbConfig) {
|
|
89
|
+
const docs = [];
|
|
90
|
+
for (let i = 0; i < texts.length; i += 1) {
|
|
91
|
+
const metadata = Array.isArray(metadatas) ? metadatas[i] : metadatas;
|
|
92
|
+
const newDoc = new Document({
|
|
93
|
+
pageContent: texts[i],
|
|
94
|
+
metadata
|
|
95
|
+
});
|
|
96
|
+
docs.push(newDoc);
|
|
97
|
+
}
|
|
98
|
+
return FakeVectorStore.fromDocuments(docs, embeddings, dbConfig);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Static method to create a `FakeVectorStore` instance from an array of
|
|
102
|
+
* `Document` instances. It adds the documents to the store.
|
|
103
|
+
* @param docs Array of `Document` instances to be added to the store.
|
|
104
|
+
* @param embeddings `Embeddings` instance used to generate embeddings for the documents.
|
|
105
|
+
* @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.
|
|
106
|
+
* @returns Promise that resolves with a new `FakeVectorStore` instance.
|
|
107
|
+
*/
|
|
108
|
+
static async fromDocuments(docs, embeddings, dbConfig) {
|
|
109
|
+
const instance = new this(embeddings, dbConfig);
|
|
110
|
+
await instance.addDocuments(docs);
|
|
111
|
+
return instance;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Static method to create a `FakeVectorStore` instance from an existing
|
|
115
|
+
* index. It creates a new `FakeVectorStore` instance without adding any
|
|
116
|
+
* documents or vectors.
|
|
117
|
+
* @param embeddings `Embeddings` instance used to generate embeddings for the documents.
|
|
118
|
+
* @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.
|
|
119
|
+
* @returns Promise that resolves with a new `FakeVectorStore` instance.
|
|
120
|
+
*/
|
|
121
|
+
static async fromExistingIndex(embeddings, dbConfig) {
|
|
122
|
+
const instance = new this(embeddings, dbConfig);
|
|
123
|
+
return instance;
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
//#endregion
|
|
128
|
+
export { FakeVectorStore };
|
|
129
|
+
//# sourceMappingURL=vectorstores.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vectorstores.js","names":["embeddings: EmbeddingsInterface","documents: Document[]","vectors: number[][]","query: number[]","k: number","filter?: this[\"FilterType\"]","memoryVector: MemoryVector","result: [Document, number][]","texts: string[]","metadatas: object[] | object","dbConfig?: FakeVectorStoreArgs","docs: Document[]"],"sources":["../../../src/utils/testing/vectorstores.ts"],"sourcesContent":["import { Document } from \"../../documents/document.js\";\nimport { EmbeddingsInterface } from \"../../embeddings.js\";\nimport { VectorStore } from \"../../vectorstores.js\";\nimport { cosine } from \"../ml-distance/similarities.js\";\n\n/**\n * Interface representing a vector in memory. It includes the content\n * (text), the corresponding embedding (vector), and any associated\n * metadata.\n */\ninterface MemoryVector {\n content: string;\n embedding: number[];\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n metadata: Record<string, any>;\n}\n\n/**\n * Interface for the arguments that can be passed to the\n * `FakeVectorStore` constructor. It includes an optional `similarity`\n * function.\n */\nexport interface FakeVectorStoreArgs {\n similarity?: typeof cosine;\n}\n\n/**\n * Class that extends `VectorStore` to store vectors in memory. Provides\n * methods for adding documents, performing similarity searches, and\n * creating instances from texts, documents, or an existing index.\n */\nexport class FakeVectorStore extends VectorStore {\n declare FilterType: (doc: Document) => boolean;\n\n memoryVectors: MemoryVector[] = [];\n\n similarity: typeof cosine;\n\n _vectorstoreType(): string {\n return \"memory\";\n }\n\n constructor(\n embeddings: EmbeddingsInterface,\n { similarity, ...rest }: FakeVectorStoreArgs = {}\n ) {\n super(embeddings, rest);\n\n this.similarity = similarity ?? cosine;\n }\n\n /**\n * Method to add documents to the memory vector store. It extracts the\n * text from each document, generates embeddings for them, and adds the\n * resulting vectors to the store.\n * @param documents Array of `Document` instances to be added to the store.\n * @returns Promise that resolves when all documents have been added.\n */\n async addDocuments(documents: Document[]): Promise<void> {\n const texts = documents.map(({ pageContent }) => pageContent);\n return this.addVectors(\n await this.embeddings.embedDocuments(texts),\n documents\n );\n }\n\n /**\n * Method to add vectors to the memory vector store. It creates\n * `MemoryVector` instances for each vector and document pair and adds\n * them to the store.\n * @param vectors Array of vectors to be added to the store.\n * @param documents Array of `Document` instances corresponding to the vectors.\n * @returns Promise that resolves when all vectors have been added.\n */\n async addVectors(vectors: number[][], documents: Document[]): Promise<void> {\n const memoryVectors = vectors.map((embedding, idx) => ({\n content: documents[idx].pageContent,\n embedding,\n metadata: documents[idx].metadata,\n }));\n\n this.memoryVectors = this.memoryVectors.concat(memoryVectors);\n }\n\n /**\n * Method to perform a similarity search in the memory vector store. It\n * calculates the similarity between the query vector and each vector in\n * the store, sorts the results by similarity, and returns the top `k`\n * results along with their scores.\n * @param query Query vector to compare against the vectors in the store.\n * @param k Number of top results to return.\n * @param filter Optional filter function to apply to the vectors before performing the search.\n * @returns Promise that resolves with an array of tuples, each containing a `Document` and its similarity score.\n */\n async similaritySearchVectorWithScore(\n query: number[],\n k: number,\n filter?: this[\"FilterType\"]\n ): Promise<[Document, number][]> {\n const filterFunction = (memoryVector: MemoryVector) => {\n if (!filter) {\n return true;\n }\n\n const doc = new Document({\n metadata: memoryVector.metadata,\n pageContent: memoryVector.content,\n });\n return filter(doc);\n };\n const filteredMemoryVectors = this.memoryVectors.filter(filterFunction);\n const searches = filteredMemoryVectors\n .map((vector, index) => ({\n similarity: this.similarity(query, vector.embedding),\n index,\n }))\n .sort((a, b) => (a.similarity > b.similarity ? -1 : 0))\n .slice(0, k);\n\n const result: [Document, number][] = searches.map((search) => [\n new Document({\n metadata: filteredMemoryVectors[search.index].metadata,\n pageContent: filteredMemoryVectors[search.index].content,\n }),\n search.similarity,\n ]);\n\n return result;\n }\n\n /**\n * Static method to create a `FakeVectorStore` instance from an array of\n * texts. It creates a `Document` for each text and metadata pair, and\n * adds them to the store.\n * @param texts Array of texts to be added to the store.\n * @param metadatas Array or single object of metadata corresponding to the texts.\n * @param embeddings `Embeddings` instance used to generate embeddings for the texts.\n * @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.\n * @returns Promise that resolves with a new `FakeVectorStore` instance.\n */\n static async fromTexts(\n texts: string[],\n metadatas: object[] | object,\n embeddings: EmbeddingsInterface,\n dbConfig?: FakeVectorStoreArgs\n ): Promise<FakeVectorStore> {\n const docs: Document[] = [];\n for (let i = 0; i < texts.length; i += 1) {\n const metadata = Array.isArray(metadatas) ? metadatas[i] : metadatas;\n const newDoc = new Document({\n pageContent: texts[i],\n metadata,\n });\n docs.push(newDoc);\n }\n return FakeVectorStore.fromDocuments(docs, embeddings, dbConfig);\n }\n\n /**\n * Static method to create a `FakeVectorStore` instance from an array of\n * `Document` instances. It adds the documents to the store.\n * @param docs Array of `Document` instances to be added to the store.\n * @param embeddings `Embeddings` instance used to generate embeddings for the documents.\n * @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.\n * @returns Promise that resolves with a new `FakeVectorStore` instance.\n */\n static async fromDocuments(\n docs: Document[],\n embeddings: EmbeddingsInterface,\n dbConfig?: FakeVectorStoreArgs\n ): Promise<FakeVectorStore> {\n const instance = new this(embeddings, dbConfig);\n await instance.addDocuments(docs);\n return instance;\n }\n\n /**\n * Static method to create a `FakeVectorStore` instance from an existing\n * index. It creates a new `FakeVectorStore` instance without adding any\n * documents or vectors.\n * @param embeddings `Embeddings` instance used to generate embeddings for the documents.\n * @param dbConfig Optional `FakeVectorStoreArgs` to configure the `FakeVectorStore` instance.\n * @returns Promise that resolves with a new `FakeVectorStore` instance.\n */\n static async fromExistingIndex(\n embeddings: EmbeddingsInterface,\n dbConfig?: FakeVectorStoreArgs\n ): Promise<FakeVectorStore> {\n const instance = new this(embeddings, dbConfig);\n return instance;\n }\n}\n"],"mappings":";;;;;;;;;;AA+BA,IAAa,kBAAb,MAAa,wBAAwB,YAAY;CAG/C,gBAAgC,CAAE;CAElC;CAEA,mBAA2B;AACzB,SAAO;CACR;CAED,YACEA,YACA,EAAE,WAAY,GAAG,MAA2B,GAAG,CAAE,GACjD;EACA,MAAM,YAAY,KAAK;EAEvB,KAAK,aAAa,cAAc;CACjC;;;;;;;;CASD,MAAM,aAAaC,WAAsC;EACvD,MAAM,QAAQ,UAAU,IAAI,CAAC,EAAE,aAAa,KAAK,YAAY;AAC7D,SAAO,KAAK,WACV,MAAM,KAAK,WAAW,eAAe,MAAM,EAC3C,UACD;CACF;;;;;;;;;CAUD,MAAM,WAAWC,SAAqBD,WAAsC;EAC1E,MAAM,gBAAgB,QAAQ,IAAI,CAAC,WAAW,SAAS;GACrD,SAAS,UAAU,KAAK;GACxB;GACA,UAAU,UAAU,KAAK;EAC1B,GAAE;EAEH,KAAK,gBAAgB,KAAK,cAAc,OAAO,cAAc;CAC9D;;;;;;;;;;;CAYD,MAAM,gCACJE,OACAC,GACAC,QAC+B;EAC/B,MAAM,iBAAiB,CAACC,iBAA+B;AACrD,OAAI,CAAC,OACH,QAAO;GAGT,MAAM,MAAM,IAAI,SAAS;IACvB,UAAU,aAAa;IACvB,aAAa,aAAa;GAC3B;AACD,UAAO,OAAO,IAAI;EACnB;EACD,MAAM,wBAAwB,KAAK,cAAc,OAAO,eAAe;EACvE,MAAM,WAAW,sBACd,IAAI,CAAC,QAAQ,WAAW;GACvB,YAAY,KAAK,WAAW,OAAO,OAAO,UAAU;GACpD;EACD,GAAE,CACF,KAAK,CAAC,GAAG,MAAO,EAAE,aAAa,EAAE,aAAa,KAAK,EAAG,CACtD,MAAM,GAAG,EAAE;EAEd,MAAMC,SAA+B,SAAS,IAAI,CAAC,WAAW,CAC5D,IAAI,SAAS;GACX,UAAU,sBAAsB,OAAO,OAAO;GAC9C,aAAa,sBAAsB,OAAO,OAAO;EAClD,IACD,OAAO,UACR,EAAC;AAEF,SAAO;CACR;;;;;;;;;;;CAYD,aAAa,UACXC,OACAC,WACAT,YACAU,UAC0B;EAC1B,MAAMC,OAAmB,CAAE;AAC3B,OAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK,GAAG;GACxC,MAAM,WAAW,MAAM,QAAQ,UAAU,GAAG,UAAU,KAAK;GAC3D,MAAM,SAAS,IAAI,SAAS;IAC1B,aAAa,MAAM;IACnB;GACD;GACD,KAAK,KAAK,OAAO;EAClB;AACD,SAAO,gBAAgB,cAAc,MAAM,YAAY,SAAS;CACjE;;;;;;;;;CAUD,aAAa,cACXA,MACAX,YACAU,UAC0B;EAC1B,MAAM,WAAW,IAAI,KAAK,YAAY;EACtC,MAAM,SAAS,aAAa,KAAK;AACjC,SAAO;CACR;;;;;;;;;CAUD,aAAa,kBACXV,YACAU,UAC0B;EAC1B,MAAM,WAAW,IAAI,KAAK,YAAY;AACtC,SAAO;CACR;AACF"}
|
|
@@ -12,6 +12,7 @@ require_rolldown_runtime.__export(types_exports, {
|
|
|
12
12
|
interopParseAsync: () => require_zod.interopParseAsync,
|
|
13
13
|
interopSafeParse: () => require_zod.interopSafeParse,
|
|
14
14
|
interopSafeParseAsync: () => require_zod.interopSafeParseAsync,
|
|
15
|
+
interopZodObjectMakeFieldsOptional: () => require_zod.interopZodObjectMakeFieldsOptional,
|
|
15
16
|
interopZodObjectPartial: () => require_zod.interopZodObjectPartial,
|
|
16
17
|
interopZodObjectPassthrough: () => require_zod.interopZodObjectPassthrough,
|
|
17
18
|
interopZodObjectStrict: () => require_zod.interopZodObjectStrict,
|
|
@@ -37,6 +38,7 @@ exports.interopParse = require_zod.interopParse;
|
|
|
37
38
|
exports.interopParseAsync = require_zod.interopParseAsync;
|
|
38
39
|
exports.interopSafeParse = require_zod.interopSafeParse;
|
|
39
40
|
exports.interopSafeParseAsync = require_zod.interopSafeParseAsync;
|
|
41
|
+
exports.interopZodObjectMakeFieldsOptional = require_zod.interopZodObjectMakeFieldsOptional;
|
|
40
42
|
exports.interopZodObjectPartial = require_zod.interopZodObjectPartial;
|
|
41
43
|
exports.interopZodObjectPassthrough = require_zod.interopZodObjectPassthrough;
|
|
42
44
|
exports.interopZodObjectStrict = require_zod.interopZodObjectStrict;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InferInteropZodInput, InferInteropZodOutput, InteropZodIssue, InteropZodObject, InteropZodObjectShape, InteropZodType, Mutable, ZodObjectV3, ZodObjectV4, ZodStringV3, ZodStringV4, extendInteropZodObject, getInteropZodDefaultGetter, getInteropZodObjectShape, getSchemaDescription, interopParse, interopParseAsync, interopSafeParse, interopSafeParseAsync, interopZodObjectPartial, interopZodObjectPassthrough, interopZodObjectStrict, interopZodTransformInputSchema, isInteropZodObject, isInteropZodSchema, isShapelessZodSchema, isSimpleStringZodSchema, isZodArrayV4, isZodObjectV3, isZodObjectV4, isZodSchema, isZodSchemaV3, isZodSchemaV4 } from "./zod.cjs";
|
|
1
|
+
import { InferInteropZodInput, InferInteropZodOutput, InteropZodDefault, InteropZodIssue, InteropZodObject, InteropZodObjectShape, InteropZodOptional, InteropZodType, Mutable, ZodDefaultV3, ZodDefaultV4, ZodObjectV3, ZodObjectV4, ZodOptionalV3, ZodOptionalV4, ZodStringV3, ZodStringV4, extendInteropZodObject, getInteropZodDefaultGetter, getInteropZodObjectShape, getSchemaDescription, interopParse, interopParseAsync, interopSafeParse, interopSafeParseAsync, interopZodObjectMakeFieldsOptional, interopZodObjectPartial, interopZodObjectPassthrough, interopZodObjectStrict, interopZodTransformInputSchema, isInteropZodObject, isInteropZodSchema, isShapelessZodSchema, isSimpleStringZodSchema, isZodArrayV4, isZodObjectV3, isZodObjectV4, isZodSchema, isZodSchemaV3, isZodSchemaV4 } from "./zod.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/utils/types/index.d.ts
|
|
4
4
|
|
|
@@ -12,5 +12,5 @@ type PartialValues<K extends string = string> = Record<K, string | (() => Promis
|
|
|
12
12
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
13
|
type ChainValues = Record<string, any>;
|
|
14
14
|
//#endregion
|
|
15
|
-
export { ChainValues, InferInteropZodInput, InferInteropZodOutput, InputValues, InteropZodIssue, InteropZodObject, InteropZodObjectShape, InteropZodType, Mutable, PartialValues, StringWithAutocomplete, ZodObjectV3, ZodObjectV4, ZodStringV3, ZodStringV4, extendInteropZodObject, getInteropZodDefaultGetter, getInteropZodObjectShape, getSchemaDescription, interopParse, interopParseAsync, interopSafeParse, interopSafeParseAsync, interopZodObjectPartial, interopZodObjectPassthrough, interopZodObjectStrict, interopZodTransformInputSchema, isInteropZodObject, isInteropZodSchema, isShapelessZodSchema, isSimpleStringZodSchema, isZodArrayV4, isZodObjectV3, isZodObjectV4, isZodSchema, isZodSchemaV3, isZodSchemaV4 };
|
|
15
|
+
export { ChainValues, InferInteropZodInput, InferInteropZodOutput, InputValues, InteropZodDefault, InteropZodIssue, InteropZodObject, InteropZodObjectShape, InteropZodOptional, InteropZodType, Mutable, PartialValues, StringWithAutocomplete, ZodDefaultV3, ZodDefaultV4, ZodObjectV3, ZodObjectV4, ZodOptionalV3, ZodOptionalV4, ZodStringV3, ZodStringV4, extendInteropZodObject, getInteropZodDefaultGetter, getInteropZodObjectShape, getSchemaDescription, interopParse, interopParseAsync, interopSafeParse, interopSafeParseAsync, interopZodObjectMakeFieldsOptional, interopZodObjectPartial, interopZodObjectPassthrough, interopZodObjectStrict, interopZodTransformInputSchema, isInteropZodObject, isInteropZodSchema, isShapelessZodSchema, isSimpleStringZodSchema, isZodArrayV4, isZodObjectV3, isZodObjectV4, isZodSchema, isZodSchemaV3, isZodSchemaV4 };
|
|
16
16
|
//# sourceMappingURL=index.d.cts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InferInteropZodInput, InferInteropZodOutput, InteropZodIssue, InteropZodObject, InteropZodObjectShape, InteropZodType, Mutable, ZodObjectV3, ZodObjectV4, ZodStringV3, ZodStringV4, extendInteropZodObject, getInteropZodDefaultGetter, getInteropZodObjectShape, getSchemaDescription, interopParse, interopParseAsync, interopSafeParse, interopSafeParseAsync, interopZodObjectPartial, interopZodObjectPassthrough, interopZodObjectStrict, interopZodTransformInputSchema, isInteropZodObject, isInteropZodSchema, isShapelessZodSchema, isSimpleStringZodSchema, isZodArrayV4, isZodObjectV3, isZodObjectV4, isZodSchema, isZodSchemaV3, isZodSchemaV4 } from "./zod.js";
|
|
1
|
+
import { InferInteropZodInput, InferInteropZodOutput, InteropZodDefault, InteropZodIssue, InteropZodObject, InteropZodObjectShape, InteropZodOptional, InteropZodType, Mutable, ZodDefaultV3, ZodDefaultV4, ZodObjectV3, ZodObjectV4, ZodOptionalV3, ZodOptionalV4, ZodStringV3, ZodStringV4, extendInteropZodObject, getInteropZodDefaultGetter, getInteropZodObjectShape, getSchemaDescription, interopParse, interopParseAsync, interopSafeParse, interopSafeParseAsync, interopZodObjectMakeFieldsOptional, interopZodObjectPartial, interopZodObjectPassthrough, interopZodObjectStrict, interopZodTransformInputSchema, isInteropZodObject, isInteropZodSchema, isShapelessZodSchema, isSimpleStringZodSchema, isZodArrayV4, isZodObjectV3, isZodObjectV4, isZodSchema, isZodSchemaV3, isZodSchemaV4 } from "./zod.js";
|
|
2
2
|
|
|
3
3
|
//#region src/utils/types/index.d.ts
|
|
4
4
|
|
|
@@ -12,5 +12,5 @@ type PartialValues<K extends string = string> = Record<K, string | (() => Promis
|
|
|
12
12
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
13
|
type ChainValues = Record<string, any>;
|
|
14
14
|
//#endregion
|
|
15
|
-
export { ChainValues, InferInteropZodInput, InferInteropZodOutput, InputValues, InteropZodIssue, InteropZodObject, InteropZodObjectShape, InteropZodType, Mutable, PartialValues, StringWithAutocomplete, ZodObjectV3, ZodObjectV4, ZodStringV3, ZodStringV4, extendInteropZodObject, getInteropZodDefaultGetter, getInteropZodObjectShape, getSchemaDescription, interopParse, interopParseAsync, interopSafeParse, interopSafeParseAsync, interopZodObjectPartial, interopZodObjectPassthrough, interopZodObjectStrict, interopZodTransformInputSchema, isInteropZodObject, isInteropZodSchema, isShapelessZodSchema, isSimpleStringZodSchema, isZodArrayV4, isZodObjectV3, isZodObjectV4, isZodSchema, isZodSchemaV3, isZodSchemaV4 };
|
|
15
|
+
export { ChainValues, InferInteropZodInput, InferInteropZodOutput, InputValues, InteropZodDefault, InteropZodIssue, InteropZodObject, InteropZodObjectShape, InteropZodOptional, InteropZodType, Mutable, PartialValues, StringWithAutocomplete, ZodDefaultV3, ZodDefaultV4, ZodObjectV3, ZodObjectV4, ZodOptionalV3, ZodOptionalV4, ZodStringV3, ZodStringV4, extendInteropZodObject, getInteropZodDefaultGetter, getInteropZodObjectShape, getSchemaDescription, interopParse, interopParseAsync, interopSafeParse, interopSafeParseAsync, interopZodObjectMakeFieldsOptional, interopZodObjectPartial, interopZodObjectPassthrough, interopZodObjectStrict, interopZodTransformInputSchema, isInteropZodObject, isInteropZodSchema, isShapelessZodSchema, isSimpleStringZodSchema, isZodArrayV4, isZodObjectV3, isZodObjectV4, isZodSchema, isZodSchemaV3, isZodSchemaV4 };
|
|
16
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __export } from "../../_virtual/rolldown_runtime.js";
|
|
2
|
-
import { extendInteropZodObject, getInteropZodDefaultGetter, getInteropZodObjectShape, getSchemaDescription, interopParse, interopParseAsync, interopSafeParse, interopSafeParseAsync, interopZodObjectPartial, interopZodObjectPassthrough, interopZodObjectStrict, interopZodTransformInputSchema, isInteropZodObject, isInteropZodSchema, isShapelessZodSchema, isSimpleStringZodSchema, isZodArrayV4, isZodObjectV3, isZodObjectV4, isZodSchema, isZodSchemaV3, isZodSchemaV4 } from "./zod.js";
|
|
2
|
+
import { extendInteropZodObject, getInteropZodDefaultGetter, getInteropZodObjectShape, getSchemaDescription, interopParse, interopParseAsync, interopSafeParse, interopSafeParseAsync, interopZodObjectMakeFieldsOptional, interopZodObjectPartial, interopZodObjectPassthrough, interopZodObjectStrict, interopZodTransformInputSchema, isInteropZodObject, isInteropZodSchema, isShapelessZodSchema, isSimpleStringZodSchema, isZodArrayV4, isZodObjectV3, isZodObjectV4, isZodSchema, isZodSchemaV3, isZodSchemaV4 } from "./zod.js";
|
|
3
3
|
|
|
4
4
|
//#region src/utils/types/index.ts
|
|
5
5
|
var types_exports = {};
|
|
@@ -12,6 +12,7 @@ __export(types_exports, {
|
|
|
12
12
|
interopParseAsync: () => interopParseAsync,
|
|
13
13
|
interopSafeParse: () => interopSafeParse,
|
|
14
14
|
interopSafeParseAsync: () => interopSafeParseAsync,
|
|
15
|
+
interopZodObjectMakeFieldsOptional: () => interopZodObjectMakeFieldsOptional,
|
|
15
16
|
interopZodObjectPartial: () => interopZodObjectPartial,
|
|
16
17
|
interopZodObjectPassthrough: () => interopZodObjectPassthrough,
|
|
17
18
|
interopZodObjectStrict: () => interopZodObjectStrict,
|
|
@@ -29,5 +30,5 @@ __export(types_exports, {
|
|
|
29
30
|
});
|
|
30
31
|
|
|
31
32
|
//#endregion
|
|
32
|
-
export { extendInteropZodObject, getInteropZodDefaultGetter, getInteropZodObjectShape, getSchemaDescription, interopParse, interopParseAsync, interopSafeParse, interopSafeParseAsync, interopZodObjectPartial, interopZodObjectPassthrough, interopZodObjectStrict, interopZodTransformInputSchema, isInteropZodObject, isInteropZodSchema, isShapelessZodSchema, isSimpleStringZodSchema, isZodArrayV4, isZodObjectV3, isZodObjectV4, isZodSchema, isZodSchemaV3, isZodSchemaV4, types_exports };
|
|
33
|
+
export { extendInteropZodObject, getInteropZodDefaultGetter, getInteropZodObjectShape, getSchemaDescription, interopParse, interopParseAsync, interopSafeParse, interopSafeParseAsync, interopZodObjectMakeFieldsOptional, interopZodObjectPartial, interopZodObjectPassthrough, interopZodObjectStrict, interopZodTransformInputSchema, isInteropZodObject, isInteropZodSchema, isShapelessZodSchema, isSimpleStringZodSchema, isZodArrayV4, isZodObjectV3, isZodObjectV4, isZodSchema, isZodSchemaV3, isZodSchemaV4, types_exports };
|
|
33
34
|
//# sourceMappingURL=index.js.map
|
package/dist/utils/types/zod.cjs
CHANGED
|
@@ -57,7 +57,7 @@ async function interopSafeParseAsync(schema, input) {
|
|
|
57
57
|
error
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
|
-
if (isZodSchemaV3(schema)) return schema.
|
|
60
|
+
if (isZodSchemaV3(schema)) return await schema.safeParseAsync(input);
|
|
61
61
|
throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType");
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
@@ -71,8 +71,8 @@ async function interopSafeParseAsync(schema, input) {
|
|
|
71
71
|
* @throws {Error} If parsing fails or the schema is not a recognized Zod v3 or v4 schema.
|
|
72
72
|
*/
|
|
73
73
|
async function interopParseAsync(schema, input) {
|
|
74
|
-
if (isZodSchemaV4(schema)) return (0, zod_v4_core.
|
|
75
|
-
if (isZodSchemaV3(schema)) return schema.
|
|
74
|
+
if (isZodSchemaV4(schema)) return await (0, zod_v4_core.parseAsync)(schema, input);
|
|
75
|
+
if (isZodSchemaV3(schema)) return await schema.parseAsync(input);
|
|
76
76
|
throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType");
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
@@ -414,6 +414,41 @@ function interopZodTransformInputSchema(schema, recursive = false) {
|
|
|
414
414
|
}
|
|
415
415
|
throw new Error("Schema must be an instance of z3.ZodType or z4.$ZodType");
|
|
416
416
|
}
|
|
417
|
+
/**
|
|
418
|
+
* Creates a modified version of a Zod object schema where fields matching a predicate are made optional.
|
|
419
|
+
* Supports both Zod v3 and v4 schemas and preserves the original schema version.
|
|
420
|
+
*
|
|
421
|
+
* @template T - The type of the Zod object schema.
|
|
422
|
+
* @param {T} schema - The Zod object schema instance (either v3 or v4).
|
|
423
|
+
* @param {(key: string, value: InteropZodType) => boolean} predicate - Function to determine which fields should be optional.
|
|
424
|
+
* @returns {InteropZodObject} The modified Zod object schema.
|
|
425
|
+
* @throws {Error} If the schema is not a Zod v3 or v4 object.
|
|
426
|
+
*/
|
|
427
|
+
function interopZodObjectMakeFieldsOptional(schema, predicate) {
|
|
428
|
+
if (isZodSchemaV3(schema)) {
|
|
429
|
+
const shape = getInteropZodObjectShape(schema);
|
|
430
|
+
const modifiedShape = {};
|
|
431
|
+
for (const [key, value] of Object.entries(shape)) if (predicate(key, value)) modifiedShape[key] = value.optional();
|
|
432
|
+
else modifiedShape[key] = value;
|
|
433
|
+
return schema.extend(modifiedShape);
|
|
434
|
+
}
|
|
435
|
+
if (isZodSchemaV4(schema)) {
|
|
436
|
+
const shape = getInteropZodObjectShape(schema);
|
|
437
|
+
const outputShape = { ...schema._zod.def.shape };
|
|
438
|
+
for (const [key, value] of Object.entries(shape)) if (predicate(key, value)) outputShape[key] = new zod_v4_core.$ZodOptional({
|
|
439
|
+
type: "optional",
|
|
440
|
+
innerType: value
|
|
441
|
+
});
|
|
442
|
+
const modifiedSchema = (0, zod_v4_core.clone)(schema, {
|
|
443
|
+
...schema._zod.def,
|
|
444
|
+
shape: outputShape
|
|
445
|
+
});
|
|
446
|
+
const meta = zod_v4_core.globalRegistry.get(schema);
|
|
447
|
+
if (meta) zod_v4_core.globalRegistry.add(modifiedSchema, meta);
|
|
448
|
+
return modifiedSchema;
|
|
449
|
+
}
|
|
450
|
+
throw new Error("Schema must be an instance of z3.ZodObject or z4.$ZodObject");
|
|
451
|
+
}
|
|
417
452
|
|
|
418
453
|
//#endregion
|
|
419
454
|
exports.extendInteropZodObject = extendInteropZodObject;
|
|
@@ -424,6 +459,7 @@ exports.interopParse = interopParse;
|
|
|
424
459
|
exports.interopParseAsync = interopParseAsync;
|
|
425
460
|
exports.interopSafeParse = interopSafeParse;
|
|
426
461
|
exports.interopSafeParseAsync = interopSafeParseAsync;
|
|
462
|
+
exports.interopZodObjectMakeFieldsOptional = interopZodObjectMakeFieldsOptional;
|
|
427
463
|
exports.interopZodObjectPartial = interopZodObjectPartial;
|
|
428
464
|
exports.interopZodObjectPassthrough = interopZodObjectPassthrough;
|
|
429
465
|
exports.interopZodObjectStrict = interopZodObjectStrict;
|