From 0904d3dc5d20d73d3dacd975647f03bb453973d8 Mon Sep 17 00:00:00 2001 From: Yi Ding <yi.s.ding@gmail.com> Date: Fri, 11 Aug 2023 19:35:00 -0700 Subject: [PATCH] allow adding of nodes with hash comparisons Allows our scripts to be run repeatedly with vector store backing and persistence without throwing an error. This is rudimentary support which doesn't work if the document has changed over time. Also added the insert and delete functions so that documents can be added manually. --- apps/docs/docs/api/classes/Anthropic.md | 26 +- apps/docs/docs/api/classes/BaseIndex.md | 81 ++- apps/docs/docs/api/classes/BaseNode.md | 73 +-- apps/docs/docs/api/classes/Document.md | 98 ++-- apps/docs/docs/api/classes/IndexDict.md | 38 +- apps/docs/docs/api/classes/IndexList.md | 8 +- apps/docs/docs/api/classes/IndexNode.md | 86 ++-- apps/docs/docs/api/classes/ListIndex.md | 152 ++++-- apps/docs/docs/api/classes/LlamaDeuce.md | 65 ++- .../docs/api/classes/SimpleDocumentStore.md | 480 ++++++++++++++++++ .../docs/docs/api/classes/SimpleIndexStore.md | 234 +++++++++ .../docs/api/classes/SimpleVectorStore.md | 283 +++++++++++ apps/docs/docs/api/classes/TextNode.md | 88 ++-- .../docs/docs/api/classes/VectorStoreIndex.md | 98 +++- apps/docs/docs/api/enums/DeuceChatStrategy.md | 16 +- apps/docs/docs/api/enums/ListRetrieverMode.md | 4 +- apps/docs/docs/api/enums/MetadataMode.md | 8 +- apps/docs/docs/api/enums/NodeRelationship.md | 10 +- apps/docs/docs/api/enums/ObjectType.md | 8 +- .../docs/docs/api/interfaces/BaseIndexInit.md | 12 +- .../docs/api/interfaces/NodeWithEmbedding.md | 4 +- .../docs/docs/api/interfaces/NodeWithScore.md | 4 +- .../docs/api/interfaces/RelatedNodeInfo.md | 8 +- .../interfaces/VectorIndexConstructorProps.md | 12 +- .../docs/api/interfaces/VectorIndexOptions.md | 10 +- apps/docs/docs/api/interfaces/VectorStore.md | 4 + apps/docs/docs/api/modules.md | 24 +- apps/simple/chatEngine.ts | 19 +- apps/simple/gptllama.ts | 10 +- apps/simple/listIndex.ts | 9 +- apps/simple/pdf.ts | 1 - apps/simple/split.ts | 9 +- apps/simple/storageContext.ts | 8 +- apps/simple/subquestion.ts | 6 +- apps/simple/vectorIndex.ts | 14 +- apps/simple/vectorIndexAnthropic.ts | 16 +- apps/simple/vectorIndexCustomize.ts | 26 +- apps/simple/vectorIndexGPT4.ts | 17 +- examples/chatEngine.ts | 19 +- examples/gptllama.ts | 9 +- examples/listIndex.ts | 9 +- examples/llamadeuce.ts | 4 +- examples/pdf.ts | 1 - examples/split.ts | 16 + examples/storageContext.ts | 8 +- examples/subquestion.ts | 6 +- examples/vectorIndex.ts | 14 +- examples/vectorIndexAnthropic.ts | 16 +- examples/vectorIndexCustomize.ts | 26 +- examples/vectorIndexGPT4.ts | 17 +- package.json | 4 +- packages/core/src/Node.ts | 52 +- packages/core/src/indices/BaseIndex.ts | 33 +- packages/core/src/indices/list/ListIndex.ts | 83 ++- .../indices/vectorStore/VectorStoreIndex.ts | 139 +++-- packages/core/src/llm/LLM.ts | 32 +- .../src/storage/docStore/KVDocumentStore.ts | 26 +- packages/core/src/storage/docStore/types.ts | 16 +- pnpm-lock.yaml | 139 ++--- prettier.config.js | 2 +- 60 files changed, 2023 insertions(+), 717 deletions(-) create mode 100644 apps/docs/docs/api/classes/SimpleDocumentStore.md create mode 100644 apps/docs/docs/api/classes/SimpleIndexStore.md create mode 100644 apps/docs/docs/api/classes/SimpleVectorStore.md create mode 100644 examples/split.ts diff --git a/apps/docs/docs/api/classes/Anthropic.md b/apps/docs/docs/api/classes/Anthropic.md index 4e519dee8..3eda5dbee 100644 --- a/apps/docs/docs/api/classes/Anthropic.md +++ b/apps/docs/docs/api/classes/Anthropic.md @@ -26,7 +26,7 @@ Anthropic LLM implementation #### Defined in -[llm/LLM.ts:387](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L387) +[llm/LLM.ts:449](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L449) ## Properties @@ -36,7 +36,7 @@ Anthropic LLM implementation #### Defined in -[llm/LLM.ts:380](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L380) +[llm/LLM.ts:442](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L442) ___ @@ -46,7 +46,7 @@ ___ #### Defined in -[llm/LLM.ts:385](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L385) +[llm/LLM.ts:447](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L447) ___ @@ -56,7 +56,7 @@ ___ #### Defined in -[llm/LLM.ts:381](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L381) +[llm/LLM.ts:443](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L443) ___ @@ -66,7 +66,7 @@ ___ #### Defined in -[llm/LLM.ts:377](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L377) +[llm/LLM.ts:439](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L439) ___ @@ -76,7 +76,7 @@ ___ #### Defined in -[llm/LLM.ts:374](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L374) +[llm/LLM.ts:436](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L436) ___ @@ -86,7 +86,7 @@ ___ #### Defined in -[llm/LLM.ts:383](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L383) +[llm/LLM.ts:445](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L445) ___ @@ -96,7 +96,7 @@ ___ #### Defined in -[llm/LLM.ts:375](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L375) +[llm/LLM.ts:437](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L437) ___ @@ -106,7 +106,7 @@ ___ #### Defined in -[llm/LLM.ts:382](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L382) +[llm/LLM.ts:444](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L444) ___ @@ -116,7 +116,7 @@ ___ #### Defined in -[llm/LLM.ts:376](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L376) +[llm/LLM.ts:438](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L438) ## Methods @@ -143,7 +143,7 @@ Get a chat response from the LLM #### Defined in -[llm/LLM.ts:422](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L422) +[llm/LLM.ts:484](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L484) ___ @@ -170,7 +170,7 @@ Get a prompt completion from the LLM #### Defined in -[llm/LLM.ts:440](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L440) +[llm/LLM.ts:502](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L502) ___ @@ -190,4 +190,4 @@ ___ #### Defined in -[llm/LLM.ts:407](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L407) +[llm/LLM.ts:469](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L469) diff --git a/apps/docs/docs/api/classes/BaseIndex.md b/apps/docs/docs/api/classes/BaseIndex.md index d83ceab2e..281301afa 100644 --- a/apps/docs/docs/api/classes/BaseIndex.md +++ b/apps/docs/docs/api/classes/BaseIndex.md @@ -43,7 +43,7 @@ they can be retrieved for our queries. #### Defined in -[indices/BaseIndex.ts:127](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L127) +[indices/BaseIndex.ts:130](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L130) ## Properties @@ -53,7 +53,7 @@ they can be retrieved for our queries. #### Defined in -[indices/BaseIndex.ts:122](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L122) +[indices/BaseIndex.ts:125](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L125) ___ @@ -63,7 +63,7 @@ ___ #### Defined in -[indices/BaseIndex.ts:124](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L124) +[indices/BaseIndex.ts:127](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L127) ___ @@ -73,7 +73,7 @@ ___ #### Defined in -[indices/BaseIndex.ts:125](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L125) +[indices/BaseIndex.ts:128](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L128) ___ @@ -83,7 +83,7 @@ ___ #### Defined in -[indices/BaseIndex.ts:120](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L120) +[indices/BaseIndex.ts:123](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L123) ___ @@ -93,7 +93,7 @@ ___ #### Defined in -[indices/BaseIndex.ts:121](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L121) +[indices/BaseIndex.ts:124](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L124) ___ @@ -103,7 +103,7 @@ ___ #### Defined in -[indices/BaseIndex.ts:123](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L123) +[indices/BaseIndex.ts:126](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L126) ## Methods @@ -128,7 +128,7 @@ and response synthezier if they are not provided. #### Defined in -[indices/BaseIndex.ts:147](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L147) +[indices/BaseIndex.ts:150](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L150) ___ @@ -150,4 +150,67 @@ Create a new retriever from the index. #### Defined in -[indices/BaseIndex.ts:140](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L140) +[indices/BaseIndex.ts:143](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L143) + +___ + +### deleteRefDoc + +▸ `Abstract` **deleteRefDoc**(`refDocId`, `deleteFromDocStore?`): `Promise`<`void`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `refDocId` | `string` | +| `deleteFromDocStore?` | `boolean` | + +#### Returns + +`Promise`<`void`\> + +#### Defined in + +[indices/BaseIndex.ts:168](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L168) + +___ + +### insert + +▸ **insert**(`document`): `Promise`<`void`\> + +Insert a document into the index. + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `document` | [`Document`](Document.md) | + +#### Returns + +`Promise`<`void`\> + +#### Defined in + +[indices/BaseIndex.ts:159](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L159) + +___ + +### insertNodes + +▸ `Abstract` **insertNodes**(`nodes`): `Promise`<`void`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `nodes` | [`BaseNode`](BaseNode.md)[] | + +#### Returns + +`Promise`<`void`\> + +#### Defined in + +[indices/BaseIndex.ts:167](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L167) diff --git a/apps/docs/docs/api/classes/BaseNode.md b/apps/docs/docs/api/classes/BaseNode.md index 3c50c2093..b7b26c456 100644 --- a/apps/docs/docs/api/classes/BaseNode.md +++ b/apps/docs/docs/api/classes/BaseNode.md @@ -28,7 +28,7 @@ Generic abstract class for retrievable nodes #### Defined in -[Node.ts:48](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L48) +[Node.ts:55](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L55) ## Properties @@ -38,7 +38,7 @@ Generic abstract class for retrievable nodes #### Defined in -[Node.ts:39](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L39) +[Node.ts:46](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L46) ___ @@ -48,7 +48,7 @@ ___ #### Defined in -[Node.ts:43](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L43) +[Node.ts:50](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L50) ___ @@ -58,7 +58,7 @@ ___ #### Defined in -[Node.ts:44](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L44) +[Node.ts:51](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L51) ___ @@ -68,7 +68,7 @@ ___ #### Defined in -[Node.ts:46](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L46) +[Node.ts:53](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L53) ___ @@ -76,9 +76,14 @@ ___ • **id\_**: `string` +The unique ID of the Node/Document. The trailing underscore is here +to avoid collisions with the id keyword in Python. + +Set to a UUID by default. + #### Defined in -[Node.ts:38](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L38) +[Node.ts:45](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L45) ___ @@ -88,7 +93,7 @@ ___ #### Defined in -[Node.ts:42](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L42) +[Node.ts:49](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L49) ___ @@ -98,7 +103,7 @@ ___ #### Defined in -[Node.ts:45](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L45) +[Node.ts:52](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L52) ## Accessors @@ -112,7 +117,7 @@ ___ #### Defined in -[Node.ts:104](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L104) +[Node.ts:107](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L107) ___ @@ -126,21 +131,7 @@ ___ #### Defined in -[Node.ts:84](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L84) - -___ - -### nodeId - -• `get` **nodeId**(): `string` - -#### Returns - -`string` - -#### Defined in - -[Node.ts:58](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L58) +[Node.ts:87](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L87) ___ @@ -154,7 +145,7 @@ ___ #### Defined in -[Node.ts:94](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L94) +[Node.ts:97](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L97) ___ @@ -168,7 +159,7 @@ ___ #### Defined in -[Node.ts:72](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L72) +[Node.ts:75](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L75) ___ @@ -182,7 +173,7 @@ ___ #### Defined in -[Node.ts:62](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L62) +[Node.ts:65](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L65) ## Methods @@ -196,7 +187,21 @@ ___ #### Defined in -[Node.ts:124](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L124) +[Node.ts:129](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L129) + +___ + +### generateHash + +▸ `Abstract` **generateHash**(): `string` + +#### Returns + +`string` + +#### Defined in + +[Node.ts:119](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L119) ___ @@ -216,7 +221,7 @@ ___ #### Defined in -[Node.ts:54](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L54) +[Node.ts:61](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L61) ___ @@ -230,7 +235,7 @@ ___ #### Defined in -[Node.ts:116](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L116) +[Node.ts:121](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L121) ___ @@ -250,7 +255,7 @@ ___ #### Defined in -[Node.ts:55](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L55) +[Node.ts:62](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L62) ___ @@ -264,7 +269,7 @@ ___ #### Defined in -[Node.ts:52](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L52) +[Node.ts:59](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L59) ___ @@ -284,7 +289,7 @@ ___ #### Defined in -[Node.ts:56](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L56) +[Node.ts:63](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L63) ___ @@ -300,4 +305,4 @@ Used with built in JSON.stringify #### Defined in -[Node.ts:136](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L136) +[Node.ts:141](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L141) diff --git a/apps/docs/docs/api/classes/Document.md b/apps/docs/docs/api/classes/Document.md index 07b20bc41..fac22af13 100644 --- a/apps/docs/docs/api/classes/Document.md +++ b/apps/docs/docs/api/classes/Document.md @@ -32,7 +32,7 @@ A document is just a special text node with a docId. #### Defined in -[Node.ts:229](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L229) +[Node.ts:257](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L257) ## Properties @@ -46,7 +46,7 @@ A document is just a special text node with a docId. #### Defined in -[Node.ts:39](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L39) +[Node.ts:46](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L46) ___ @@ -60,7 +60,7 @@ ___ #### Defined in -[Node.ts:147](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L147) +[Node.ts:152](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L152) ___ @@ -74,7 +74,7 @@ ___ #### Defined in -[Node.ts:43](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L43) +[Node.ts:50](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L50) ___ @@ -88,7 +88,7 @@ ___ #### Defined in -[Node.ts:44](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L44) +[Node.ts:51](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L51) ___ @@ -102,7 +102,7 @@ ___ #### Defined in -[Node.ts:46](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L46) +[Node.ts:53](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L53) ___ @@ -110,13 +110,18 @@ ___ • **id\_**: `string` +The unique ID of the Node/Document. The trailing underscore is here +to avoid collisions with the id keyword in Python. + +Set to a UUID by default. + #### Inherited from [TextNode](TextNode.md).[id_](TextNode.md#id_) #### Defined in -[Node.ts:38](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L38) +[Node.ts:45](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L45) ___ @@ -130,7 +135,7 @@ ___ #### Defined in -[Node.ts:42](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L42) +[Node.ts:49](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L49) ___ @@ -144,7 +149,7 @@ ___ #### Defined in -[Node.ts:150](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L150) +[Node.ts:155](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L155) ___ @@ -158,7 +163,7 @@ ___ #### Defined in -[Node.ts:45](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L45) +[Node.ts:52](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L52) ___ @@ -172,7 +177,7 @@ ___ #### Defined in -[Node.ts:146](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L146) +[Node.ts:151](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L151) ___ @@ -186,7 +191,7 @@ ___ #### Defined in -[Node.ts:145](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L145) +[Node.ts:150](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L150) ## Accessors @@ -204,21 +209,7 @@ TextNode.childNodes #### Defined in -[Node.ts:104](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L104) - -___ - -### docId - -• `get` **docId**(): `string` - -#### Returns - -`string` - -#### Defined in - -[Node.ts:238](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L238) +[Node.ts:107](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L107) ___ @@ -236,25 +227,7 @@ TextNode.nextNode #### Defined in -[Node.ts:84](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L84) - -___ - -### nodeId - -• `get` **nodeId**(): `string` - -#### Returns - -`string` - -#### Inherited from - -TextNode.nodeId - -#### Defined in - -[Node.ts:58](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L58) +[Node.ts:87](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L87) ___ @@ -272,7 +245,7 @@ TextNode.parentNode #### Defined in -[Node.ts:94](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L94) +[Node.ts:97](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L97) ___ @@ -290,7 +263,7 @@ TextNode.prevNode #### Defined in -[Node.ts:72](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L72) +[Node.ts:75](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L75) ___ @@ -308,7 +281,7 @@ TextNode.sourceNode #### Defined in -[Node.ts:62](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L62) +[Node.ts:65](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L65) ## Methods @@ -326,17 +299,20 @@ TextNode.sourceNode #### Defined in -[Node.ts:124](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L124) +[Node.ts:129](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L129) ___ ### generateHash -▸ **generateHash**(): `void` +▸ **generateHash**(): `string` + +Generate a hash of the text node. +The ID is not part of the hash as it can change independent of content. #### Returns -`void` +`string` #### Inherited from @@ -344,7 +320,7 @@ ___ #### Defined in -[Node.ts:157](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L157) +[Node.ts:173](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L173) ___ @@ -368,7 +344,7 @@ ___ #### Defined in -[Node.ts:165](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L165) +[Node.ts:187](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L187) ___ @@ -386,7 +362,7 @@ ___ #### Defined in -[Node.ts:116](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L116) +[Node.ts:121](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L121) ___ @@ -410,7 +386,7 @@ ___ #### Defined in -[Node.ts:170](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L170) +[Node.ts:192](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L192) ___ @@ -433,7 +409,7 @@ ___ #### Defined in -[Node.ts:195](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L195) +[Node.ts:219](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L219) ___ @@ -451,7 +427,7 @@ ___ #### Defined in -[Node.ts:199](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L199) +[Node.ts:223](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L223) ___ @@ -469,7 +445,7 @@ ___ #### Defined in -[Node.ts:234](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L234) +[Node.ts:266](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L266) ___ @@ -493,7 +469,7 @@ ___ #### Defined in -[Node.ts:191](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L191) +[Node.ts:213](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L213) ___ @@ -513,4 +489,4 @@ Used with built in JSON.stringify #### Defined in -[Node.ts:136](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L136) +[Node.ts:141](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L141) diff --git a/apps/docs/docs/api/classes/IndexDict.md b/apps/docs/docs/api/classes/IndexDict.md index 16610fe99..73d1320fa 100644 --- a/apps/docs/docs/api/classes/IndexDict.md +++ b/apps/docs/docs/api/classes/IndexDict.md @@ -37,16 +37,6 @@ The underlying structure of each index. ## Properties -### docStore - -• **docStore**: `Record`<`string`, [`Document`](Document.md)\> = `{}` - -#### Defined in - -[indices/BaseIndex.ts:46](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L46) - -___ - ### indexId • **indexId**: `string` @@ -91,7 +81,7 @@ ___ #### Defined in -[indices/BaseIndex.ts:47](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L47) +[indices/BaseIndex.ts:46](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L46) ## Methods @@ -112,7 +102,27 @@ ___ #### Defined in -[indices/BaseIndex.ts:56](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L56) +[indices/BaseIndex.ts:55](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L55) + +___ + +### delete + +▸ **delete**(`nodeId`): `void` + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `nodeId` | `string` | + +#### Returns + +`void` + +#### Defined in + +[indices/BaseIndex.ts:68](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L68) ___ @@ -130,7 +140,7 @@ ___ #### Defined in -[indices/BaseIndex.ts:49](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L49) +[indices/BaseIndex.ts:48](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L48) ___ @@ -148,4 +158,4 @@ ___ #### Defined in -[indices/BaseIndex.ts:61](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L61) +[indices/BaseIndex.ts:60](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L60) diff --git a/apps/docs/docs/api/classes/IndexList.md b/apps/docs/docs/api/classes/IndexList.md index 810786996..3ef694aa1 100644 --- a/apps/docs/docs/api/classes/IndexList.md +++ b/apps/docs/docs/api/classes/IndexList.md @@ -57,7 +57,7 @@ ___ #### Defined in -[indices/BaseIndex.ts:90](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L90) +[indices/BaseIndex.ts:93](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L93) ___ @@ -81,7 +81,7 @@ ___ #### Defined in -[indices/BaseIndex.ts:91](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L91) +[indices/BaseIndex.ts:94](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L94) ## Methods @@ -101,7 +101,7 @@ ___ #### Defined in -[indices/BaseIndex.ts:93](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L93) +[indices/BaseIndex.ts:96](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L96) ___ @@ -137,4 +137,4 @@ ___ #### Defined in -[indices/BaseIndex.ts:97](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L97) +[indices/BaseIndex.ts:100](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L100) diff --git a/apps/docs/docs/api/classes/IndexNode.md b/apps/docs/docs/api/classes/IndexNode.md index ab4478a6f..c7169d171 100644 --- a/apps/docs/docs/api/classes/IndexNode.md +++ b/apps/docs/docs/api/classes/IndexNode.md @@ -32,7 +32,7 @@ TextNode is the default node type for text. Most common node type in LlamaIndex. #### Defined in -[Node.ts:215](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L215) +[Node.ts:239](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L239) ## Properties @@ -46,7 +46,7 @@ TextNode is the default node type for text. Most common node type in LlamaIndex. #### Defined in -[Node.ts:39](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L39) +[Node.ts:46](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L46) ___ @@ -60,7 +60,7 @@ ___ #### Defined in -[Node.ts:147](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L147) +[Node.ts:152](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L152) ___ @@ -74,7 +74,7 @@ ___ #### Defined in -[Node.ts:43](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L43) +[Node.ts:50](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L50) ___ @@ -88,7 +88,7 @@ ___ #### Defined in -[Node.ts:44](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L44) +[Node.ts:51](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L51) ___ @@ -102,7 +102,7 @@ ___ #### Defined in -[Node.ts:46](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L46) +[Node.ts:53](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L53) ___ @@ -110,13 +110,18 @@ ___ • **id\_**: `string` +The unique ID of the Node/Document. The trailing underscore is here +to avoid collisions with the id keyword in Python. + +Set to a UUID by default. + #### Inherited from [TextNode](TextNode.md).[id_](TextNode.md#id_) #### Defined in -[Node.ts:38](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L38) +[Node.ts:45](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L45) ___ @@ -126,7 +131,7 @@ ___ #### Defined in -[Node.ts:213](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L213) +[Node.ts:237](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L237) ___ @@ -140,7 +145,7 @@ ___ #### Defined in -[Node.ts:42](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L42) +[Node.ts:49](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L49) ___ @@ -154,7 +159,7 @@ ___ #### Defined in -[Node.ts:150](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L150) +[Node.ts:155](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L155) ___ @@ -168,7 +173,7 @@ ___ #### Defined in -[Node.ts:45](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L45) +[Node.ts:52](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L52) ___ @@ -182,7 +187,7 @@ ___ #### Defined in -[Node.ts:146](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L146) +[Node.ts:151](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L151) ___ @@ -196,7 +201,7 @@ ___ #### Defined in -[Node.ts:145](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L145) +[Node.ts:150](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L150) ## Accessors @@ -214,7 +219,7 @@ TextNode.childNodes #### Defined in -[Node.ts:104](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L104) +[Node.ts:107](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L107) ___ @@ -232,25 +237,7 @@ TextNode.nextNode #### Defined in -[Node.ts:84](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L84) - -___ - -### nodeId - -• `get` **nodeId**(): `string` - -#### Returns - -`string` - -#### Inherited from - -TextNode.nodeId - -#### Defined in - -[Node.ts:58](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L58) +[Node.ts:87](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L87) ___ @@ -268,7 +255,7 @@ TextNode.parentNode #### Defined in -[Node.ts:94](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L94) +[Node.ts:97](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L97) ___ @@ -286,7 +273,7 @@ TextNode.prevNode #### Defined in -[Node.ts:72](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L72) +[Node.ts:75](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L75) ___ @@ -304,7 +291,7 @@ TextNode.sourceNode #### Defined in -[Node.ts:62](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L62) +[Node.ts:65](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L65) ## Methods @@ -322,17 +309,20 @@ TextNode.sourceNode #### Defined in -[Node.ts:124](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L124) +[Node.ts:129](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L129) ___ ### generateHash -▸ **generateHash**(): `void` +▸ **generateHash**(): `string` + +Generate a hash of the text node. +The ID is not part of the hash as it can change independent of content. #### Returns -`void` +`string` #### Inherited from @@ -340,7 +330,7 @@ ___ #### Defined in -[Node.ts:157](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L157) +[Node.ts:173](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L173) ___ @@ -364,7 +354,7 @@ ___ #### Defined in -[Node.ts:165](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L165) +[Node.ts:187](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L187) ___ @@ -382,7 +372,7 @@ ___ #### Defined in -[Node.ts:116](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L116) +[Node.ts:121](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L121) ___ @@ -406,7 +396,7 @@ ___ #### Defined in -[Node.ts:170](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L170) +[Node.ts:192](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L192) ___ @@ -429,7 +419,7 @@ ___ #### Defined in -[Node.ts:195](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L195) +[Node.ts:219](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L219) ___ @@ -447,7 +437,7 @@ ___ #### Defined in -[Node.ts:199](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L199) +[Node.ts:223](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L223) ___ @@ -465,7 +455,7 @@ ___ #### Defined in -[Node.ts:220](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L220) +[Node.ts:248](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L248) ___ @@ -489,7 +479,7 @@ ___ #### Defined in -[Node.ts:191](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L191) +[Node.ts:213](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L213) ___ @@ -509,4 +499,4 @@ Used with built in JSON.stringify #### Defined in -[Node.ts:136](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L136) +[Node.ts:141](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L141) diff --git a/apps/docs/docs/api/classes/ListIndex.md b/apps/docs/docs/api/classes/ListIndex.md index 436482332..e1b91a574 100644 --- a/apps/docs/docs/api/classes/ListIndex.md +++ b/apps/docs/docs/api/classes/ListIndex.md @@ -32,7 +32,7 @@ A ListIndex keeps nodes in a sequential list structure #### Defined in -[indices/list/ListIndex.ts:43](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L43) +[indices/list/ListIndex.ts:47](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L47) ## Properties @@ -46,7 +46,7 @@ A ListIndex keeps nodes in a sequential list structure #### Defined in -[indices/BaseIndex.ts:122](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L122) +[indices/BaseIndex.ts:125](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L125) ___ @@ -60,7 +60,7 @@ ___ #### Defined in -[indices/BaseIndex.ts:124](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L124) +[indices/BaseIndex.ts:127](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L127) ___ @@ -74,7 +74,7 @@ ___ #### Defined in -[indices/BaseIndex.ts:125](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L125) +[indices/BaseIndex.ts:128](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L128) ___ @@ -88,7 +88,7 @@ ___ #### Defined in -[indices/BaseIndex.ts:120](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L120) +[indices/BaseIndex.ts:123](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L123) ___ @@ -102,7 +102,7 @@ ___ #### Defined in -[indices/BaseIndex.ts:121](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L121) +[indices/BaseIndex.ts:124](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L124) ___ @@ -116,123 +116,179 @@ ___ #### Defined in -[indices/BaseIndex.ts:123](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L123) +[indices/BaseIndex.ts:126](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L126) ## Methods -### \_deleteNode +### asQueryEngine + +▸ **asQueryEngine**(`options?`): [`BaseQueryEngine`](../interfaces/BaseQueryEngine.md) + +Create a new query engine from the index. It will also create a retriever +and response synthezier if they are not provided. + +#### Parameters + +| Name | Type | Description | +| :------ | :------ | :------ | +| `options?` | `Object` | you can supply your own custom Retriever and ResponseSynthesizer | +| `options.responseSynthesizer?` | [`ResponseSynthesizer`](ResponseSynthesizer.md) | - | +| `options.retriever?` | [`BaseRetriever`](../interfaces/BaseRetriever.md) | - | + +#### Returns + +[`BaseQueryEngine`](../interfaces/BaseQueryEngine.md) + +#### Overrides + +[BaseIndex](BaseIndex.md).[asQueryEngine](BaseIndex.md#asqueryengine) + +#### Defined in + +[indices/list/ListIndex.ts:155](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L155) + +___ + +### asRetriever -▸ `Protected` **_deleteNode**(`nodeId`): `void` +▸ **asRetriever**(`options?`): [`BaseRetriever`](../interfaces/BaseRetriever.md) + +Create a new retriever from the index. #### Parameters | Name | Type | | :------ | :------ | -| `nodeId` | `string` | +| `options?` | `Object` | +| `options.mode` | [`ListRetrieverMode`](../enums/ListRetrieverMode.md) | #### Returns -`void` +[`BaseRetriever`](../interfaces/BaseRetriever.md) + +#### Overrides + +[BaseIndex](BaseIndex.md).[asRetriever](BaseIndex.md#asretriever) #### Defined in -[indices/list/ListIndex.ts:193](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L193) +[indices/list/ListIndex.ts:142](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L142) ___ -### \_insert +### deleteNodes -▸ `Protected` **_insert**(`nodes`): `void` +▸ **deleteNodes**(`nodeIds`, `deleteFromDocStore`): `Promise`<`void`\> #### Parameters | Name | Type | | :------ | :------ | -| `nodes` | [`BaseNode`](BaseNode.md)[] | +| `nodeIds` | `string`[] | +| `deleteFromDocStore` | `boolean` | #### Returns -`void` +`Promise`<`void`\> #### Defined in -[indices/list/ListIndex.ts:187](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L187) +[indices/list/ListIndex.ts:216](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L216) ___ -### asQueryEngine - -▸ **asQueryEngine**(`options?`): [`BaseQueryEngine`](../interfaces/BaseQueryEngine.md) +### deleteRefDoc -Create a new query engine from the index. It will also create a retriever -and response synthezier if they are not provided. +▸ **deleteRefDoc**(`refDocId`, `deleteFromDocStore?`): `Promise`<`void`\> #### Parameters -| Name | Type | Description | -| :------ | :------ | :------ | -| `options?` | `Object` | you can supply your own custom Retriever and ResponseSynthesizer | -| `options.responseSynthesizer?` | [`ResponseSynthesizer`](ResponseSynthesizer.md) | - | -| `options.retriever?` | [`BaseRetriever`](../interfaces/BaseRetriever.md) | - | +| Name | Type | +| :------ | :------ | +| `refDocId` | `string` | +| `deleteFromDocStore?` | `boolean` | #### Returns -[`BaseQueryEngine`](../interfaces/BaseQueryEngine.md) +`Promise`<`void`\> #### Overrides -[BaseIndex](BaseIndex.md).[asQueryEngine](BaseIndex.md#asqueryengine) +[BaseIndex](BaseIndex.md).[deleteRefDoc](BaseIndex.md#deleterefdoc) #### Defined in -[indices/list/ListIndex.ts:151](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L151) +[indices/list/ListIndex.ts:197](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L197) ___ -### asRetriever +### getRefDocInfo -▸ **asRetriever**(`options?`): [`BaseRetriever`](../interfaces/BaseRetriever.md) +▸ **getRefDocInfo**(): `Promise`<`Record`<`string`, `RefDocInfo`\>\> -Create a new retriever from the index. +#### Returns + +`Promise`<`Record`<`string`, `RefDocInfo`\>\> + +#### Defined in + +[indices/list/ListIndex.ts:230](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L230) + +___ + +### insert + +▸ **insert**(`document`): `Promise`<`void`\> + +Insert a document into the index. #### Parameters | Name | Type | | :------ | :------ | -| `options?` | `Object` | -| `options.mode` | [`ListRetrieverMode`](../enums/ListRetrieverMode.md) | +| `document` | [`Document`](Document.md) | #### Returns -[`BaseRetriever`](../interfaces/BaseRetriever.md) +`Promise`<`void`\> -#### Overrides +#### Inherited from -[BaseIndex](BaseIndex.md).[asRetriever](BaseIndex.md#asretriever) +[BaseIndex](BaseIndex.md).[insert](BaseIndex.md#insert) #### Defined in -[indices/list/ListIndex.ts:138](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L138) +[indices/BaseIndex.ts:159](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L159) ___ -### getRefDocInfo +### insertNodes -▸ **getRefDocInfo**(): `Promise`<`Record`<`string`, `RefDocInfo`\>\> +▸ **insertNodes**(`nodes`): `Promise`<`void`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `nodes` | [`BaseNode`](BaseNode.md)[] | #### Returns -`Promise`<`Record`<`string`, `RefDocInfo`\>\> +`Promise`<`void`\> + +#### Overrides + +[BaseIndex](BaseIndex.md).[insertNodes](BaseIndex.md#insertnodes) #### Defined in -[indices/list/ListIndex.ts:199](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L199) +[indices/list/ListIndex.ts:191](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L191) ___ -### \_buildIndexFromNodes +### buildIndexFromNodes -▸ `Static` **_buildIndexFromNodes**(`nodes`, `docStore`, `indexStruct?`): `Promise`<[`IndexList`](IndexList.md)\> +▸ `Static` **buildIndexFromNodes**(`nodes`, `docStore`, `indexStruct?`): `Promise`<[`IndexList`](IndexList.md)\> #### Parameters @@ -248,7 +304,7 @@ ___ #### Defined in -[indices/list/ListIndex.ts:172](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L172) +[indices/list/ListIndex.ts:176](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L176) ___ @@ -271,7 +327,7 @@ ___ #### Defined in -[indices/list/ListIndex.ts:112](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L112) +[indices/list/ListIndex.ts:116](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L116) ___ @@ -291,4 +347,4 @@ ___ #### Defined in -[indices/list/ListIndex.ts:47](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L47) +[indices/list/ListIndex.ts:51](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L51) diff --git a/apps/docs/docs/api/classes/LlamaDeuce.md b/apps/docs/docs/api/classes/LlamaDeuce.md index 6806e07cf..22d0be854 100644 --- a/apps/docs/docs/api/classes/LlamaDeuce.md +++ b/apps/docs/docs/api/classes/LlamaDeuce.md @@ -26,7 +26,7 @@ Llama2 LLM implementation #### Defined in -[llm/LLM.ts:242](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L242) +[llm/LLM.ts:266](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L266) ## Properties @@ -36,7 +36,7 @@ Llama2 LLM implementation #### Defined in -[llm/LLM.ts:236](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L236) +[llm/LLM.ts:260](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L260) ___ @@ -46,17 +46,17 @@ ___ #### Defined in -[llm/LLM.ts:239](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L239) +[llm/LLM.ts:263](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L263) ___ ### model -• **model**: ``"Llama-2-70b-chat"`` \| ``"Llama-2-13b-chat"`` \| ``"Llama-2-7b-chat"`` +• **model**: ``"Llama-2-70b-chat-old"`` \| ``"Llama-2-70b-chat-4bit"`` \| ``"Llama-2-13b-chat"`` \| ``"Llama-2-13b-chat-4bit"`` \| ``"Llama-2-7b-chat"`` \| ``"Llama-2-7b-chat-4bit"`` #### Defined in -[llm/LLM.ts:235](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L235) +[llm/LLM.ts:259](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L259) ___ @@ -66,7 +66,7 @@ ___ #### Defined in -[llm/LLM.ts:240](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L240) +[llm/LLM.ts:264](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L264) ___ @@ -76,7 +76,7 @@ ___ #### Defined in -[llm/LLM.ts:237](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L237) +[llm/LLM.ts:261](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L261) ___ @@ -86,7 +86,7 @@ ___ #### Defined in -[llm/LLM.ts:238](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L238) +[llm/LLM.ts:262](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L262) ## Methods @@ -113,7 +113,7 @@ Get a chat response from the LLM #### Defined in -[llm/LLM.ts:333](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L333) +[llm/LLM.ts:385](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L385) ___ @@ -140,7 +140,7 @@ Get a prompt completion from the LLM #### Defined in -[llm/LLM.ts:360](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L360) +[llm/LLM.ts:422](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L422) ___ @@ -160,13 +160,13 @@ ___ #### Defined in -[llm/LLM.ts:274](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L274) +[llm/LLM.ts:309](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L309) ___ ### mapMessagesToPrompt -▸ **mapMessagesToPrompt**(`messages`): `string` +▸ **mapMessagesToPrompt**(`messages`): `Object` #### Parameters @@ -176,17 +176,22 @@ ___ #### Returns -`string` +`Object` + +| Name | Type | +| :------ | :------ | +| `prompt` | `string` | +| `systemPrompt` | `undefined` \| `string` | #### Defined in -[llm/LLM.ts:251](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L251) +[llm/LLM.ts:281](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L281) ___ ### mapMessagesToPromptA16Z -▸ **mapMessagesToPromptA16Z**(`messages`): `string` +▸ **mapMessagesToPromptA16Z**(`messages`): `Object` #### Parameters @@ -196,29 +201,41 @@ ___ #### Returns -`string` +`Object` + +| Name | Type | +| :------ | :------ | +| `prompt` | `string` | +| `systemPrompt` | `undefined` | #### Defined in -[llm/LLM.ts:263](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L263) +[llm/LLM.ts:295](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L295) ___ ### mapMessagesToPromptMeta -▸ **mapMessagesToPromptMeta**(`messages`, `withBos?`): `string` +▸ **mapMessagesToPromptMeta**(`messages`, `opts?`): `Object` #### Parameters -| Name | Type | Default value | -| :------ | :------ | :------ | -| `messages` | [`ChatMessage`](../interfaces/ChatMessage.md)[] | `undefined` | -| `withBos` | `boolean` | `false` | +| Name | Type | +| :------ | :------ | +| `messages` | [`ChatMessage`](../interfaces/ChatMessage.md)[] | +| `opts?` | `Object` | +| `opts.replicate4Bit?` | `boolean` | +| `opts.withBos?` | `boolean` | #### Returns -`string` +`Object` + +| Name | Type | +| :------ | :------ | +| `prompt` | `string` | +| `systemPrompt` | `undefined` \| `string` | #### Defined in -[llm/LLM.ts:287](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L287) +[llm/LLM.ts:322](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L322) diff --git a/apps/docs/docs/api/classes/SimpleDocumentStore.md b/apps/docs/docs/api/classes/SimpleDocumentStore.md new file mode 100644 index 000000000..5e84033c4 --- /dev/null +++ b/apps/docs/docs/api/classes/SimpleDocumentStore.md @@ -0,0 +1,480 @@ +--- +id: "SimpleDocumentStore" +title: "Class: SimpleDocumentStore" +sidebar_label: "SimpleDocumentStore" +sidebar_position: 0 +custom_edit_url: null +--- + +## Hierarchy + +- `KVDocumentStore` + + ↳ **`SimpleDocumentStore`** + +## Constructors + +### constructor + +• **new SimpleDocumentStore**(`kvStore?`, `namespace?`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `kvStore?` | `SimpleKVStore` | +| `namespace?` | `string` | + +#### Overrides + +KVDocumentStore.constructor + +#### Defined in + +[storage/docStore/SimpleDocumentStore.ts:19](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/docStore/SimpleDocumentStore.ts#L19) + +## Properties + +### kvStore + +• `Private` **kvStore**: `SimpleKVStore` + +#### Defined in + +[storage/docStore/SimpleDocumentStore.ts:17](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/docStore/SimpleDocumentStore.ts#L17) + +## Methods + +### addDocuments + +▸ **addDocuments**(`docs`, `allowUpdate?`): `Promise`<`void`\> + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `docs` | [`BaseNode`](BaseNode.md)[] | `undefined` | +| `allowUpdate` | `boolean` | `true` | + +#### Returns + +`Promise`<`void`\> + +#### Inherited from + +KVDocumentStore.addDocuments + +#### Defined in + +[storage/docStore/KVDocumentStore.ts:33](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/docStore/KVDocumentStore.ts#L33) + +___ + +### deleteDocument + +▸ **deleteDocument**(`docId`, `raiseError?`, `removeRefDocNode?`): `Promise`<`void`\> + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `docId` | `string` | `undefined` | +| `raiseError` | `boolean` | `true` | +| `removeRefDocNode` | `boolean` | `true` | + +#### Returns + +`Promise`<`void`\> + +#### Inherited from + +KVDocumentStore.deleteDocument + +#### Defined in + +[storage/docStore/KVDocumentStore.ts:131](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/docStore/KVDocumentStore.ts#L131) + +___ + +### deleteRefDoc + +▸ **deleteRefDoc**(`refDocId`, `raiseError?`): `Promise`<`void`\> + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `refDocId` | `string` | `undefined` | +| `raiseError` | `boolean` | `true` | + +#### Returns + +`Promise`<`void`\> + +#### Inherited from + +KVDocumentStore.deleteRefDoc + +#### Defined in + +[storage/docStore/KVDocumentStore.ts:148](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/docStore/KVDocumentStore.ts#L148) + +___ + +### docs + +▸ **docs**(): `Promise`<`Record`<`string`, [`BaseNode`](BaseNode.md)\>\> + +#### Returns + +`Promise`<`Record`<`string`, [`BaseNode`](BaseNode.md)\>\> + +#### Inherited from + +KVDocumentStore.docs + +#### Defined in + +[storage/docStore/KVDocumentStore.ts:24](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/docStore/KVDocumentStore.ts#L24) + +___ + +### documentExists + +▸ **documentExists**(`docId`): `Promise`<`boolean`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `docId` | `string` | + +#### Returns + +`Promise`<`boolean`\> + +#### Inherited from + +KVDocumentStore.documentExists + +#### Defined in + +[storage/docStore/KVDocumentStore.ts:105](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/docStore/KVDocumentStore.ts#L105) + +___ + +### getAllRefDocInfo + +▸ **getAllRefDocInfo**(): `Promise`<`undefined` \| `Record`<`string`, `RefDocInfo`\>\> + +#### Returns + +`Promise`<`undefined` \| `Record`<`string`, `RefDocInfo`\>\> + +#### Inherited from + +KVDocumentStore.getAllRefDocInfo + +#### Defined in + +[storage/docStore/KVDocumentStore.ts:93](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/docStore/KVDocumentStore.ts#L93) + +___ + +### getDocument + +▸ **getDocument**(`docId`, `raiseError?`): `Promise`<`undefined` \| [`BaseNode`](BaseNode.md)\> + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `docId` | `string` | `undefined` | +| `raiseError` | `boolean` | `true` | + +#### Returns + +`Promise`<`undefined` \| [`BaseNode`](BaseNode.md)\> + +#### Inherited from + +KVDocumentStore.getDocument + +#### Defined in + +[storage/docStore/KVDocumentStore.ts:73](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/docStore/KVDocumentStore.ts#L73) + +___ + +### getDocumentHash + +▸ **getDocumentHash**(`docId`): `Promise`<`undefined` \| `string`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `docId` | `string` | + +#### Returns + +`Promise`<`undefined` \| `string`\> + +#### Inherited from + +KVDocumentStore.getDocumentHash + +#### Defined in + +[storage/docStore/KVDocumentStore.ts:174](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/docStore/KVDocumentStore.ts#L174) + +___ + +### getNode + +▸ **getNode**(`nodeId`, `raiseError?`): `Promise`<[`BaseNode`](BaseNode.md)\> + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `nodeId` | `string` | `undefined` | +| `raiseError` | `boolean` | `true` | + +#### Returns + +`Promise`<[`BaseNode`](BaseNode.md)\> + +#### Inherited from + +KVDocumentStore.getNode + +#### Defined in + +[storage/docStore/types.ts:57](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/docStore/types.ts#L57) + +___ + +### getNodeDict + +▸ **getNodeDict**(`nodeIdDict`): `Promise`<`Record`<`number`, [`BaseNode`](BaseNode.md)\>\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `nodeIdDict` | `Object` | + +#### Returns + +`Promise`<`Record`<`number`, [`BaseNode`](BaseNode.md)\>\> + +#### Inherited from + +KVDocumentStore.getNodeDict + +#### Defined in + +[storage/docStore/types.ts:65](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/docStore/types.ts#L65) + +___ + +### getNodes + +▸ **getNodes**(`nodeIds`, `raiseError?`): `Promise`<[`BaseNode`](BaseNode.md)[]\> + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `nodeIds` | `string`[] | `undefined` | +| `raiseError` | `boolean` | `true` | + +#### Returns + +`Promise`<[`BaseNode`](BaseNode.md)[]\> + +#### Inherited from + +KVDocumentStore.getNodes + +#### Defined in + +[storage/docStore/types.ts:51](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/docStore/types.ts#L51) + +___ + +### getRefDocInfo + +▸ **getRefDocInfo**(`refDocId`): `Promise`<`undefined` \| `RefDocInfo`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `refDocId` | `string` | + +#### Returns + +`Promise`<`undefined` \| `RefDocInfo`\> + +#### Inherited from + +KVDocumentStore.getRefDocInfo + +#### Defined in + +[storage/docStore/KVDocumentStore.ts:88](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/docStore/KVDocumentStore.ts#L88) + +___ + +### persist + +▸ **persist**(`persistPath?`, `fs?`): `Promise`<`void`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `persistPath` | `string` | +| `fs?` | [`GenericFileSystem`](../interfaces/GenericFileSystem.md) | + +#### Returns + +`Promise`<`void`\> + +#### Overrides + +KVDocumentStore.persist + +#### Defined in + +[storage/docStore/SimpleDocumentStore.ts:52](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/docStore/SimpleDocumentStore.ts#L52) + +___ + +### refDocExists + +▸ **refDocExists**(`refDocId`): `Promise`<`boolean`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `refDocId` | `string` | + +#### Returns + +`Promise`<`boolean`\> + +#### Inherited from + +KVDocumentStore.refDocExists + +#### Defined in + +[storage/docStore/KVDocumentStore.ts:101](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/docStore/KVDocumentStore.ts#L101) + +___ + +### setDocumentHash + +▸ **setDocumentHash**(`docId`, `docHash`): `Promise`<`void`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `docId` | `string` | +| `docHash` | `string` | + +#### Returns + +`Promise`<`void`\> + +#### Inherited from + +KVDocumentStore.setDocumentHash + +#### Defined in + +[storage/docStore/KVDocumentStore.ts:169](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/docStore/KVDocumentStore.ts#L169) + +___ + +### toDict + +▸ **toDict**(): `SaveDict` + +#### Returns + +`SaveDict` + +#### Defined in + +[storage/docStore/SimpleDocumentStore.ts:73](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/docStore/SimpleDocumentStore.ts#L73) + +___ + +### fromDict + +▸ `Static` **fromDict**(`saveDict`, `namespace?`): [`SimpleDocumentStore`](SimpleDocumentStore.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `saveDict` | `SaveDict` | +| `namespace?` | `string` | + +#### Returns + +[`SimpleDocumentStore`](SimpleDocumentStore.md) + +#### Defined in + +[storage/docStore/SimpleDocumentStore.ts:68](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/docStore/SimpleDocumentStore.ts#L68) + +___ + +### fromPersistDir + +▸ `Static` **fromPersistDir**(`persistDir?`, `namespace?`, `fsModule?`): `Promise`<[`SimpleDocumentStore`](SimpleDocumentStore.md)\> + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `persistDir` | `string` | `DEFAULT_PERSIST_DIR` | +| `namespace?` | `string` | `undefined` | +| `fsModule?` | [`GenericFileSystem`](../interfaces/GenericFileSystem.md) | `undefined` | + +#### Returns + +`Promise`<[`SimpleDocumentStore`](SimpleDocumentStore.md)\> + +#### Defined in + +[storage/docStore/SimpleDocumentStore.ts:26](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/docStore/SimpleDocumentStore.ts#L26) + +___ + +### fromPersistPath + +▸ `Static` **fromPersistPath**(`persistPath`, `namespace?`, `fs?`): `Promise`<[`SimpleDocumentStore`](SimpleDocumentStore.md)\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `persistPath` | `string` | +| `namespace?` | `string` | +| `fs?` | [`GenericFileSystem`](../interfaces/GenericFileSystem.md) | + +#### Returns + +`Promise`<[`SimpleDocumentStore`](SimpleDocumentStore.md)\> + +#### Defined in + +[storage/docStore/SimpleDocumentStore.ts:42](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/docStore/SimpleDocumentStore.ts#L42) diff --git a/apps/docs/docs/api/classes/SimpleIndexStore.md b/apps/docs/docs/api/classes/SimpleIndexStore.md new file mode 100644 index 000000000..ca0669ad5 --- /dev/null +++ b/apps/docs/docs/api/classes/SimpleIndexStore.md @@ -0,0 +1,234 @@ +--- +id: "SimpleIndexStore" +title: "Class: SimpleIndexStore" +sidebar_label: "SimpleIndexStore" +sidebar_position: 0 +custom_edit_url: null +--- + +## Hierarchy + +- `KVIndexStore` + + ↳ **`SimpleIndexStore`** + +## Constructors + +### constructor + +• **new SimpleIndexStore**(`kvStore?`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `kvStore?` | `BaseInMemoryKVStore` | + +#### Overrides + +KVIndexStore.constructor + +#### Defined in + +[storage/indexStore/SimpleIndexStore.ts:16](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/indexStore/SimpleIndexStore.ts#L16) + +## Properties + +### kvStore + +• `Private` **kvStore**: `BaseInMemoryKVStore` + +#### Defined in + +[storage/indexStore/SimpleIndexStore.ts:14](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/indexStore/SimpleIndexStore.ts#L14) + +## Methods + +### addIndexStruct + +▸ **addIndexStruct**(`indexStruct`): `Promise`<`void`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `indexStruct` | [`IndexStruct`](IndexStruct.md) | + +#### Returns + +`Promise`<`void`\> + +#### Inherited from + +KVIndexStore.addIndexStruct + +#### Defined in + +[storage/indexStore/KVIndexStore.ts:17](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/indexStore/KVIndexStore.ts#L17) + +___ + +### deleteIndexStruct + +▸ **deleteIndexStruct**(`key`): `Promise`<`void`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `key` | `string` | + +#### Returns + +`Promise`<`void`\> + +#### Inherited from + +KVIndexStore.deleteIndexStruct + +#### Defined in + +[storage/indexStore/KVIndexStore.ts:23](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/indexStore/KVIndexStore.ts#L23) + +___ + +### getIndexStruct + +▸ **getIndexStruct**(`structId?`): `Promise`<`undefined` \| [`IndexStruct`](IndexStruct.md)\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `structId?` | `string` | + +#### Returns + +`Promise`<`undefined` \| [`IndexStruct`](IndexStruct.md)\> + +#### Inherited from + +KVIndexStore.getIndexStruct + +#### Defined in + +[storage/indexStore/KVIndexStore.ts:27](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/indexStore/KVIndexStore.ts#L27) + +___ + +### getIndexStructs + +▸ **getIndexStructs**(): `Promise`<[`IndexStruct`](IndexStruct.md)[]\> + +#### Returns + +`Promise`<[`IndexStruct`](IndexStruct.md)[]\> + +#### Inherited from + +KVIndexStore.getIndexStructs + +#### Defined in + +[storage/indexStore/KVIndexStore.ts:43](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/indexStore/KVIndexStore.ts#L43) + +___ + +### persist + +▸ **persist**(`persistPath?`, `fs?`): `Promise`<`void`\> + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `persistPath` | `string` | `DEFAULT_PERSIST_DIR` | +| `fs` | [`GenericFileSystem`](../interfaces/GenericFileSystem.md) | `DEFAULT_FS` | + +#### Returns + +`Promise`<`void`\> + +#### Overrides + +KVIndexStore.persist + +#### Defined in + +[storage/indexStore/SimpleIndexStore.ts:41](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/indexStore/SimpleIndexStore.ts#L41) + +___ + +### toDict + +▸ **toDict**(): `Record`<`string`, `unknown`\> + +#### Returns + +`Record`<`string`, `unknown`\> + +#### Defined in + +[storage/indexStore/SimpleIndexStore.ts:53](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/indexStore/SimpleIndexStore.ts#L53) + +___ + +### fromDict + +▸ `Static` **fromDict**(`saveDict`): [`SimpleIndexStore`](SimpleIndexStore.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `saveDict` | `DataType` | + +#### Returns + +[`SimpleIndexStore`](SimpleIndexStore.md) + +#### Defined in + +[storage/indexStore/SimpleIndexStore.ts:48](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/indexStore/SimpleIndexStore.ts#L48) + +___ + +### fromPersistDir + +▸ `Static` **fromPersistDir**(`persistDir?`, `fs?`): `Promise`<[`SimpleIndexStore`](SimpleIndexStore.md)\> + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `persistDir` | `string` | `DEFAULT_PERSIST_DIR` | +| `fs` | [`GenericFileSystem`](../interfaces/GenericFileSystem.md) | `DEFAULT_FS` | + +#### Returns + +`Promise`<[`SimpleIndexStore`](SimpleIndexStore.md)\> + +#### Defined in + +[storage/indexStore/SimpleIndexStore.ts:22](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/indexStore/SimpleIndexStore.ts#L22) + +___ + +### fromPersistPath + +▸ `Static` **fromPersistPath**(`persistPath`, `fs?`): `Promise`<[`SimpleIndexStore`](SimpleIndexStore.md)\> + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `persistPath` | `string` | `undefined` | +| `fs` | [`GenericFileSystem`](../interfaces/GenericFileSystem.md) | `DEFAULT_FS` | + +#### Returns + +`Promise`<[`SimpleIndexStore`](SimpleIndexStore.md)\> + +#### Defined in + +[storage/indexStore/SimpleIndexStore.ts:33](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/indexStore/SimpleIndexStore.ts#L33) diff --git a/apps/docs/docs/api/classes/SimpleVectorStore.md b/apps/docs/docs/api/classes/SimpleVectorStore.md new file mode 100644 index 000000000..6b5fbef83 --- /dev/null +++ b/apps/docs/docs/api/classes/SimpleVectorStore.md @@ -0,0 +1,283 @@ +--- +id: "SimpleVectorStore" +title: "Class: SimpleVectorStore" +sidebar_label: "SimpleVectorStore" +sidebar_position: 0 +custom_edit_url: null +--- + +## Implements + +- [`VectorStore`](../interfaces/VectorStore.md) + +## Constructors + +### constructor + +• **new SimpleVectorStore**(`data?`, `fs?`) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `data?` | `SimpleVectorStoreData` | +| `fs?` | [`GenericFileSystem`](../interfaces/GenericFileSystem.md) | + +#### Defined in + +[storage/vectorStore/SimpleVectorStore.ts:37](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/SimpleVectorStore.ts#L37) + +## Properties + +### data + +• `Private` **data**: `SimpleVectorStoreData` + +#### Defined in + +[storage/vectorStore/SimpleVectorStore.ts:33](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/SimpleVectorStore.ts#L33) + +___ + +### fs + +• `Private` **fs**: [`GenericFileSystem`](../interfaces/GenericFileSystem.md) = `DEFAULT_FS` + +#### Defined in + +[storage/vectorStore/SimpleVectorStore.ts:34](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/SimpleVectorStore.ts#L34) + +___ + +### persistPath + +• `Private` **persistPath**: `undefined` \| `string` + +#### Defined in + +[storage/vectorStore/SimpleVectorStore.ts:35](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/SimpleVectorStore.ts#L35) + +___ + +### storesText + +• **storesText**: `boolean` = `false` + +#### Implementation of + +[VectorStore](../interfaces/VectorStore.md).[storesText](../interfaces/VectorStore.md#storestext) + +#### Defined in + +[storage/vectorStore/SimpleVectorStore.ts:32](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/SimpleVectorStore.ts#L32) + +## Accessors + +### client + +• `get` **client**(): `any` + +#### Returns + +`any` + +#### Implementation of + +VectorStore.client + +#### Defined in + +[storage/vectorStore/SimpleVectorStore.ts:50](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/SimpleVectorStore.ts#L50) + +## Methods + +### add + +▸ **add**(`embeddingResults`): `Promise`<`string`[]\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `embeddingResults` | [`NodeWithEmbedding`](../interfaces/NodeWithEmbedding.md)[] | + +#### Returns + +`Promise`<`string`[]\> + +#### Implementation of + +[VectorStore](../interfaces/VectorStore.md).[add](../interfaces/VectorStore.md#add) + +#### Defined in + +[storage/vectorStore/SimpleVectorStore.ts:58](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/SimpleVectorStore.ts#L58) + +___ + +### delete + +▸ **delete**(`refDocId`): `Promise`<`void`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `refDocId` | `string` | + +#### Returns + +`Promise`<`void`\> + +#### Implementation of + +[VectorStore](../interfaces/VectorStore.md).[delete](../interfaces/VectorStore.md#delete) + +#### Defined in + +[storage/vectorStore/SimpleVectorStore.ts:78](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/SimpleVectorStore.ts#L78) + +___ + +### get + +▸ **get**(`textId`): `Promise`<`number`[]\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `textId` | `string` | + +#### Returns + +`Promise`<`number`[]\> + +#### Defined in + +[storage/vectorStore/SimpleVectorStore.ts:54](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/SimpleVectorStore.ts#L54) + +___ + +### persist + +▸ **persist**(`persistPath?`, `fs?`): `Promise`<`void`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `persistPath` | `string` | +| `fs?` | [`GenericFileSystem`](../interfaces/GenericFileSystem.md) | + +#### Returns + +`Promise`<`void`\> + +#### Implementation of + +[VectorStore](../interfaces/VectorStore.md).[persist](../interfaces/VectorStore.md#persist) + +#### Defined in + +[storage/vectorStore/SimpleVectorStore.ts:147](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/SimpleVectorStore.ts#L147) + +___ + +### query + +▸ **query**(`query`): `Promise`<[`VectorStoreQueryResult`](../interfaces/VectorStoreQueryResult.md)\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `query` | [`VectorStoreQuery`](../interfaces/VectorStoreQuery.md) | + +#### Returns + +`Promise`<[`VectorStoreQueryResult`](../interfaces/VectorStoreQueryResult.md)\> + +#### Implementation of + +[VectorStore](../interfaces/VectorStore.md).[query](../interfaces/VectorStore.md#query) + +#### Defined in + +[storage/vectorStore/SimpleVectorStore.ts:89](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/SimpleVectorStore.ts#L89) + +___ + +### toDict + +▸ **toDict**(): `SimpleVectorStoreData` + +#### Returns + +`SimpleVectorStoreData` + +#### Defined in + +[storage/vectorStore/SimpleVectorStore.ts:197](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/SimpleVectorStore.ts#L197) + +___ + +### fromDict + +▸ `Static` **fromDict**(`saveDict`): [`SimpleVectorStore`](SimpleVectorStore.md) + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `saveDict` | `SimpleVectorStoreData` | + +#### Returns + +[`SimpleVectorStore`](SimpleVectorStore.md) + +#### Defined in + +[storage/vectorStore/SimpleVectorStore.ts:190](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/SimpleVectorStore.ts#L190) + +___ + +### fromPersistDir + +▸ `Static` **fromPersistDir**(`persistDir?`, `fs?`): `Promise`<[`SimpleVectorStore`](SimpleVectorStore.md)\> + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `persistDir` | `string` | `DEFAULT_PERSIST_DIR` | +| `fs` | [`GenericFileSystem`](../interfaces/GenericFileSystem.md) | `DEFAULT_FS` | + +#### Returns + +`Promise`<[`SimpleVectorStore`](SimpleVectorStore.md)\> + +#### Defined in + +[storage/vectorStore/SimpleVectorStore.ts:42](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/SimpleVectorStore.ts#L42) + +___ + +### fromPersistPath + +▸ `Static` **fromPersistPath**(`persistPath`, `fs?`): `Promise`<[`SimpleVectorStore`](SimpleVectorStore.md)\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `persistPath` | `string` | +| `fs?` | [`GenericFileSystem`](../interfaces/GenericFileSystem.md) | + +#### Returns + +`Promise`<[`SimpleVectorStore`](SimpleVectorStore.md)\> + +#### Defined in + +[storage/vectorStore/SimpleVectorStore.ts:160](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/SimpleVectorStore.ts#L160) diff --git a/apps/docs/docs/api/classes/TextNode.md b/apps/docs/docs/api/classes/TextNode.md index 644859c52..2c7daea23 100644 --- a/apps/docs/docs/api/classes/TextNode.md +++ b/apps/docs/docs/api/classes/TextNode.md @@ -36,7 +36,7 @@ TextNode is the default node type for text. Most common node type in LlamaIndex. #### Defined in -[Node.ts:152](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L152) +[Node.ts:157](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L157) ## Properties @@ -50,7 +50,7 @@ TextNode is the default node type for text. Most common node type in LlamaIndex. #### Defined in -[Node.ts:39](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L39) +[Node.ts:46](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L46) ___ @@ -60,7 +60,7 @@ ___ #### Defined in -[Node.ts:147](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L147) +[Node.ts:152](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L152) ___ @@ -74,7 +74,7 @@ ___ #### Defined in -[Node.ts:43](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L43) +[Node.ts:50](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L50) ___ @@ -88,7 +88,7 @@ ___ #### Defined in -[Node.ts:44](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L44) +[Node.ts:51](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L51) ___ @@ -102,7 +102,7 @@ ___ #### Defined in -[Node.ts:46](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L46) +[Node.ts:53](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L53) ___ @@ -110,13 +110,18 @@ ___ • **id\_**: `string` +The unique ID of the Node/Document. The trailing underscore is here +to avoid collisions with the id keyword in Python. + +Set to a UUID by default. + #### Inherited from [BaseNode](BaseNode.md).[id_](BaseNode.md#id_) #### Defined in -[Node.ts:38](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L38) +[Node.ts:45](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L45) ___ @@ -130,7 +135,7 @@ ___ #### Defined in -[Node.ts:42](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L42) +[Node.ts:49](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L49) ___ @@ -140,7 +145,7 @@ ___ #### Defined in -[Node.ts:150](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L150) +[Node.ts:155](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L155) ___ @@ -154,7 +159,7 @@ ___ #### Defined in -[Node.ts:45](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L45) +[Node.ts:52](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L52) ___ @@ -164,7 +169,7 @@ ___ #### Defined in -[Node.ts:146](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L146) +[Node.ts:151](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L151) ___ @@ -174,7 +179,7 @@ ___ #### Defined in -[Node.ts:145](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L145) +[Node.ts:150](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L150) ## Accessors @@ -192,7 +197,7 @@ BaseNode.childNodes #### Defined in -[Node.ts:104](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L104) +[Node.ts:107](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L107) ___ @@ -210,25 +215,7 @@ BaseNode.nextNode #### Defined in -[Node.ts:84](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L84) - -___ - -### nodeId - -• `get` **nodeId**(): `string` - -#### Returns - -`string` - -#### Inherited from - -BaseNode.nodeId - -#### Defined in - -[Node.ts:58](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L58) +[Node.ts:87](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L87) ___ @@ -246,7 +233,7 @@ BaseNode.parentNode #### Defined in -[Node.ts:94](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L94) +[Node.ts:97](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L97) ___ @@ -264,7 +251,7 @@ BaseNode.prevNode #### Defined in -[Node.ts:72](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L72) +[Node.ts:75](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L75) ___ @@ -282,7 +269,7 @@ BaseNode.sourceNode #### Defined in -[Node.ts:62](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L62) +[Node.ts:65](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L65) ## Methods @@ -300,21 +287,28 @@ BaseNode.sourceNode #### Defined in -[Node.ts:124](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L124) +[Node.ts:129](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L129) ___ ### generateHash -▸ **generateHash**(): `void` +▸ **generateHash**(): `string` + +Generate a hash of the text node. +The ID is not part of the hash as it can change independent of content. #### Returns -`void` +`string` + +#### Overrides + +[BaseNode](BaseNode.md).[generateHash](BaseNode.md#generatehash) #### Defined in -[Node.ts:157](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L157) +[Node.ts:173](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L173) ___ @@ -338,7 +332,7 @@ ___ #### Defined in -[Node.ts:165](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L165) +[Node.ts:187](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L187) ___ @@ -356,7 +350,7 @@ ___ #### Defined in -[Node.ts:116](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L116) +[Node.ts:121](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L121) ___ @@ -380,7 +374,7 @@ ___ #### Defined in -[Node.ts:170](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L170) +[Node.ts:192](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L192) ___ @@ -399,7 +393,7 @@ ___ #### Defined in -[Node.ts:195](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L195) +[Node.ts:219](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L219) ___ @@ -413,7 +407,7 @@ ___ #### Defined in -[Node.ts:199](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L199) +[Node.ts:223](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L223) ___ @@ -431,7 +425,7 @@ ___ #### Defined in -[Node.ts:161](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L161) +[Node.ts:183](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L183) ___ @@ -455,7 +449,7 @@ ___ #### Defined in -[Node.ts:191](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L191) +[Node.ts:213](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L213) ___ @@ -475,4 +469,4 @@ Used with built in JSON.stringify #### Defined in -[Node.ts:136](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L136) +[Node.ts:141](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L141) diff --git a/apps/docs/docs/api/classes/VectorStoreIndex.md b/apps/docs/docs/api/classes/VectorStoreIndex.md index c6641a311..32f6a9eb9 100644 --- a/apps/docs/docs/api/classes/VectorStoreIndex.md +++ b/apps/docs/docs/api/classes/VectorStoreIndex.md @@ -46,7 +46,7 @@ The VectorStoreIndex, an index that stores the nodes only according to their vec #### Defined in -[indices/BaseIndex.ts:122](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L122) +[indices/BaseIndex.ts:125](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L125) ___ @@ -60,7 +60,7 @@ ___ #### Defined in -[indices/BaseIndex.ts:124](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L124) +[indices/BaseIndex.ts:127](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L127) ___ @@ -74,7 +74,7 @@ ___ #### Defined in -[indices/BaseIndex.ts:125](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L125) +[indices/BaseIndex.ts:128](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L128) ___ @@ -88,7 +88,7 @@ ___ #### Defined in -[indices/BaseIndex.ts:120](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L120) +[indices/BaseIndex.ts:123](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L123) ___ @@ -102,7 +102,7 @@ ___ #### Defined in -[indices/BaseIndex.ts:121](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L121) +[indices/BaseIndex.ts:124](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L124) ___ @@ -145,7 +145,7 @@ and response synthezier if they are not provided. #### Defined in -[indices/vectorStore/VectorStoreIndex.ts:215](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/vectorStore/VectorStoreIndex.ts#L215) +[indices/vectorStore/VectorStoreIndex.ts:223](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/vectorStore/VectorStoreIndex.ts#L223) ___ @@ -171,13 +171,88 @@ Create a new retriever from the index. #### Defined in -[indices/vectorStore/VectorStoreIndex.ts:211](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/vectorStore/VectorStoreIndex.ts#L211) +[indices/vectorStore/VectorStoreIndex.ts:219](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/vectorStore/VectorStoreIndex.ts#L219) + +___ + +### deleteRefDoc + +▸ **deleteRefDoc**(`refDocId`, `deleteFromDocStore?`): `Promise`<`void`\> + +#### Parameters + +| Name | Type | Default value | +| :------ | :------ | :------ | +| `refDocId` | `string` | `undefined` | +| `deleteFromDocStore` | `boolean` | `true` | + +#### Returns + +`Promise`<`void`\> + +#### Overrides + +[BaseIndex](BaseIndex.md).[deleteRefDoc](BaseIndex.md#deleterefdoc) + +#### Defined in + +[indices/vectorStore/VectorStoreIndex.ts:259](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/vectorStore/VectorStoreIndex.ts#L259) + +___ + +### insert + +▸ **insert**(`document`): `Promise`<`void`\> + +Insert a document into the index. + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `document` | [`Document`](Document.md) | + +#### Returns + +`Promise`<`void`\> + +#### Inherited from + +[BaseIndex](BaseIndex.md).[insert](BaseIndex.md#insert) + +#### Defined in + +[indices/BaseIndex.ts:159](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L159) + +___ + +### insertNodes + +▸ **insertNodes**(`nodes`): `Promise`<`void`\> + +#### Parameters + +| Name | Type | +| :------ | :------ | +| `nodes` | [`BaseNode`](BaseNode.md)[] | + +#### Returns + +`Promise`<`void`\> + +#### Overrides + +[BaseIndex](BaseIndex.md).[insertNodes](BaseIndex.md#insertnodes) + +#### Defined in + +[indices/vectorStore/VectorStoreIndex.ts:234](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/vectorStore/VectorStoreIndex.ts#L234) ___ ### buildIndexFromNodes -▸ `Static` **buildIndexFromNodes**(`nodes`, `serviceContext`, `vectorStore`, `docStore`): `Promise`<[`IndexDict`](IndexDict.md)\> +▸ `Static` **buildIndexFromNodes**(`nodes`, `serviceContext`, `vectorStore`, `docStore`, `indexDict?`): `Promise`<[`IndexDict`](IndexDict.md)\> Get embeddings for nodes and place them into the index. @@ -189,6 +264,7 @@ Get embeddings for nodes and place them into the index. | `serviceContext` | [`ServiceContext`](../interfaces/ServiceContext.md) | | `vectorStore` | [`VectorStore`](../interfaces/VectorStore.md) | | `docStore` | `BaseDocumentStore` | +| `indexDict?` | [`IndexDict`](IndexDict.md) | #### Returns @@ -196,7 +272,7 @@ Get embeddings for nodes and place them into the index. #### Defined in -[indices/vectorStore/VectorStoreIndex.ts:151](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/vectorStore/VectorStoreIndex.ts#L151) +[indices/vectorStore/VectorStoreIndex.ts:147](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/vectorStore/VectorStoreIndex.ts#L147) ___ @@ -221,7 +297,7 @@ High level API: split documents, get embeddings, and build index. #### Defined in -[indices/vectorStore/VectorStoreIndex.ts:186](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/vectorStore/VectorStoreIndex.ts#L186) +[indices/vectorStore/VectorStoreIndex.ts:194](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/vectorStore/VectorStoreIndex.ts#L194) ___ @@ -245,7 +321,7 @@ Get the embeddings for nodes. #### Defined in -[indices/vectorStore/VectorStoreIndex.ts:123](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/vectorStore/VectorStoreIndex.ts#L123) +[indices/vectorStore/VectorStoreIndex.ts:119](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/vectorStore/VectorStoreIndex.ts#L119) ___ diff --git a/apps/docs/docs/api/enums/DeuceChatStrategy.md b/apps/docs/docs/api/enums/DeuceChatStrategy.md index dbf1b62f6..52d01443e 100644 --- a/apps/docs/docs/api/enums/DeuceChatStrategy.md +++ b/apps/docs/docs/api/enums/DeuceChatStrategy.md @@ -14,7 +14,7 @@ custom_edit_url: null #### Defined in -[llm/LLM.ts:224](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L224) +[llm/LLM.ts:246](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L246) ___ @@ -24,7 +24,7 @@ ___ #### Defined in -[llm/LLM.ts:225](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L225) +[llm/LLM.ts:247](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L247) ___ @@ -34,4 +34,14 @@ ___ #### Defined in -[llm/LLM.ts:226](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L226) +[llm/LLM.ts:248](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L248) + +___ + +### REPLICATE4BIT + +• **REPLICATE4BIT** = ``"replicate4bit"`` + +#### Defined in + +[llm/LLM.ts:251](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L251) diff --git a/apps/docs/docs/api/enums/ListRetrieverMode.md b/apps/docs/docs/api/enums/ListRetrieverMode.md index fe1addec4..5a88cb553 100644 --- a/apps/docs/docs/api/enums/ListRetrieverMode.md +++ b/apps/docs/docs/api/enums/ListRetrieverMode.md @@ -14,7 +14,7 @@ custom_edit_url: null #### Defined in -[indices/list/ListIndex.ts:26](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L26) +[indices/list/ListIndex.ts:30](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L30) ___ @@ -24,4 +24,4 @@ ___ #### Defined in -[indices/list/ListIndex.ts:28](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L28) +[indices/list/ListIndex.ts:32](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L32) diff --git a/apps/docs/docs/api/enums/MetadataMode.md b/apps/docs/docs/api/enums/MetadataMode.md index 732189f33..b9ad91d64 100644 --- a/apps/docs/docs/api/enums/MetadataMode.md +++ b/apps/docs/docs/api/enums/MetadataMode.md @@ -14,7 +14,7 @@ custom_edit_url: null #### Defined in -[Node.ts:19](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L19) +[Node.ts:20](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L20) ___ @@ -24,7 +24,7 @@ ___ #### Defined in -[Node.ts:20](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L20) +[Node.ts:21](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L21) ___ @@ -34,7 +34,7 @@ ___ #### Defined in -[Node.ts:21](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L21) +[Node.ts:22](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L22) ___ @@ -44,4 +44,4 @@ ___ #### Defined in -[Node.ts:22](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L22) +[Node.ts:23](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L23) diff --git a/apps/docs/docs/api/enums/NodeRelationship.md b/apps/docs/docs/api/enums/NodeRelationship.md index 3e65d05bf..77ec61b3f 100644 --- a/apps/docs/docs/api/enums/NodeRelationship.md +++ b/apps/docs/docs/api/enums/NodeRelationship.md @@ -14,7 +14,7 @@ custom_edit_url: null #### Defined in -[Node.ts:8](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L8) +[Node.ts:9](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L9) ___ @@ -24,7 +24,7 @@ ___ #### Defined in -[Node.ts:6](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L6) +[Node.ts:7](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L7) ___ @@ -34,7 +34,7 @@ ___ #### Defined in -[Node.ts:7](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L7) +[Node.ts:8](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L8) ___ @@ -44,7 +44,7 @@ ___ #### Defined in -[Node.ts:5](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L5) +[Node.ts:6](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L6) ___ @@ -54,4 +54,4 @@ ___ #### Defined in -[Node.ts:4](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L4) +[Node.ts:5](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L5) diff --git a/apps/docs/docs/api/enums/ObjectType.md b/apps/docs/docs/api/enums/ObjectType.md index 397aac1bc..5a2ac946c 100644 --- a/apps/docs/docs/api/enums/ObjectType.md +++ b/apps/docs/docs/api/enums/ObjectType.md @@ -14,7 +14,7 @@ custom_edit_url: null #### Defined in -[Node.ts:15](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L15) +[Node.ts:16](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L16) ___ @@ -24,7 +24,7 @@ ___ #### Defined in -[Node.ts:13](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L13) +[Node.ts:14](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L14) ___ @@ -34,7 +34,7 @@ ___ #### Defined in -[Node.ts:14](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L14) +[Node.ts:15](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L15) ___ @@ -44,4 +44,4 @@ ___ #### Defined in -[Node.ts:12](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L12) +[Node.ts:13](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L13) diff --git a/apps/docs/docs/api/interfaces/BaseIndexInit.md b/apps/docs/docs/api/interfaces/BaseIndexInit.md index 89d0f60f1..0d25b4ba5 100644 --- a/apps/docs/docs/api/interfaces/BaseIndexInit.md +++ b/apps/docs/docs/api/interfaces/BaseIndexInit.md @@ -26,7 +26,7 @@ custom_edit_url: null #### Defined in -[indices/BaseIndex.ts:109](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L109) +[indices/BaseIndex.ts:112](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L112) ___ @@ -36,7 +36,7 @@ ___ #### Defined in -[indices/BaseIndex.ts:111](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L111) +[indices/BaseIndex.ts:114](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L114) ___ @@ -46,7 +46,7 @@ ___ #### Defined in -[indices/BaseIndex.ts:112](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L112) +[indices/BaseIndex.ts:115](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L115) ___ @@ -56,7 +56,7 @@ ___ #### Defined in -[indices/BaseIndex.ts:107](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L107) +[indices/BaseIndex.ts:110](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L110) ___ @@ -66,7 +66,7 @@ ___ #### Defined in -[indices/BaseIndex.ts:108](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L108) +[indices/BaseIndex.ts:111](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L111) ___ @@ -76,4 +76,4 @@ ___ #### Defined in -[indices/BaseIndex.ts:110](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L110) +[indices/BaseIndex.ts:113](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L113) diff --git a/apps/docs/docs/api/interfaces/NodeWithEmbedding.md b/apps/docs/docs/api/interfaces/NodeWithEmbedding.md index 38b41b51e..e8b99ab64 100644 --- a/apps/docs/docs/api/interfaces/NodeWithEmbedding.md +++ b/apps/docs/docs/api/interfaces/NodeWithEmbedding.md @@ -16,7 +16,7 @@ A node with an embedding #### Defined in -[Node.ts:277](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L277) +[Node.ts:305](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L305) ___ @@ -26,4 +26,4 @@ ___ #### Defined in -[Node.ts:276](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L276) +[Node.ts:304](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L304) diff --git a/apps/docs/docs/api/interfaces/NodeWithScore.md b/apps/docs/docs/api/interfaces/NodeWithScore.md index 0af378c23..6a2b5c731 100644 --- a/apps/docs/docs/api/interfaces/NodeWithScore.md +++ b/apps/docs/docs/api/interfaces/NodeWithScore.md @@ -16,7 +16,7 @@ A node with a similarity score #### Defined in -[Node.ts:268](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L268) +[Node.ts:296](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L296) ___ @@ -26,4 +26,4 @@ ___ #### Defined in -[Node.ts:269](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L269) +[Node.ts:297](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L297) diff --git a/apps/docs/docs/api/interfaces/RelatedNodeInfo.md b/apps/docs/docs/api/interfaces/RelatedNodeInfo.md index 7797dee0e..d88fa9642 100644 --- a/apps/docs/docs/api/interfaces/RelatedNodeInfo.md +++ b/apps/docs/docs/api/interfaces/RelatedNodeInfo.md @@ -14,7 +14,7 @@ custom_edit_url: null #### Defined in -[Node.ts:29](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L29) +[Node.ts:30](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L30) ___ @@ -24,7 +24,7 @@ ___ #### Defined in -[Node.ts:28](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L28) +[Node.ts:29](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L29) ___ @@ -34,7 +34,7 @@ ___ #### Defined in -[Node.ts:26](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L26) +[Node.ts:27](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L27) ___ @@ -44,4 +44,4 @@ ___ #### Defined in -[Node.ts:27](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L27) +[Node.ts:28](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L28) diff --git a/apps/docs/docs/api/interfaces/VectorIndexConstructorProps.md b/apps/docs/docs/api/interfaces/VectorIndexConstructorProps.md index 60e5bc864..e6962047c 100644 --- a/apps/docs/docs/api/interfaces/VectorIndexConstructorProps.md +++ b/apps/docs/docs/api/interfaces/VectorIndexConstructorProps.md @@ -24,7 +24,7 @@ custom_edit_url: null #### Defined in -[indices/BaseIndex.ts:109](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L109) +[indices/BaseIndex.ts:112](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L112) ___ @@ -38,7 +38,7 @@ ___ #### Defined in -[indices/BaseIndex.ts:111](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L111) +[indices/BaseIndex.ts:114](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L114) ___ @@ -52,7 +52,7 @@ ___ #### Defined in -[indices/BaseIndex.ts:112](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L112) +[indices/BaseIndex.ts:115](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L115) ___ @@ -66,7 +66,7 @@ ___ #### Defined in -[indices/BaseIndex.ts:107](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L107) +[indices/BaseIndex.ts:110](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L110) ___ @@ -80,7 +80,7 @@ ___ #### Defined in -[indices/BaseIndex.ts:108](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L108) +[indices/BaseIndex.ts:111](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L111) ___ @@ -94,4 +94,4 @@ ___ #### Defined in -[indices/BaseIndex.ts:162](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L162) +[indices/BaseIndex.ts:183](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L183) diff --git a/apps/docs/docs/api/interfaces/VectorIndexOptions.md b/apps/docs/docs/api/interfaces/VectorIndexOptions.md index 7c99f9990..c913c749a 100644 --- a/apps/docs/docs/api/interfaces/VectorIndexOptions.md +++ b/apps/docs/docs/api/interfaces/VectorIndexOptions.md @@ -14,7 +14,7 @@ custom_edit_url: null #### Defined in -[indices/BaseIndex.ts:156](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L156) +[indices/BaseIndex.ts:177](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L177) ___ @@ -24,7 +24,7 @@ ___ #### Defined in -[indices/BaseIndex.ts:155](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L155) +[indices/BaseIndex.ts:176](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L176) ___ @@ -34,7 +34,7 @@ ___ #### Defined in -[indices/BaseIndex.ts:154](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L154) +[indices/BaseIndex.ts:175](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L175) ___ @@ -44,7 +44,7 @@ ___ #### Defined in -[indices/BaseIndex.ts:157](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L157) +[indices/BaseIndex.ts:178](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L178) ___ @@ -54,4 +54,4 @@ ___ #### Defined in -[indices/BaseIndex.ts:158](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L158) +[indices/BaseIndex.ts:179](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L179) diff --git a/apps/docs/docs/api/interfaces/VectorStore.md b/apps/docs/docs/api/interfaces/VectorStore.md index 09c0187eb..9f47de8ae 100644 --- a/apps/docs/docs/api/interfaces/VectorStore.md +++ b/apps/docs/docs/api/interfaces/VectorStore.md @@ -6,6 +6,10 @@ sidebar_position: 0 custom_edit_url: null --- +## Implemented by + +- [`SimpleVectorStore`](../classes/SimpleVectorStore.md) + ## Properties ### isEmbeddingQuery diff --git a/apps/docs/docs/api/modules.md b/apps/docs/docs/api/modules.md index b9c96d4d9..5dd4b6dcd 100644 --- a/apps/docs/docs/api/modules.md +++ b/apps/docs/docs/api/modules.md @@ -48,8 +48,11 @@ custom_edit_url: null - [SentenceSplitter](classes/SentenceSplitter.md) - [SimpleChatEngine](classes/SimpleChatEngine.md) - [SimpleDirectoryReader](classes/SimpleDirectoryReader.md) +- [SimpleDocumentStore](classes/SimpleDocumentStore.md) +- [SimpleIndexStore](classes/SimpleIndexStore.md) - [SimpleNodeParser](classes/SimpleNodeParser.md) - [SimpleResponseBuilder](classes/SimpleResponseBuilder.md) +- [SimpleVectorStore](classes/SimpleVectorStore.md) - [SubQuestionOutputParser](classes/SubQuestionOutputParser.md) - [SubQuestionQueryEngine](classes/SubQuestionQueryEngine.md) - [TextFileReader](classes/TextFileReader.md) @@ -157,7 +160,7 @@ ___ #### Defined in -[Node.ts:32](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L32) +[Node.ts:33](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L33) ___ @@ -219,12 +222,21 @@ NOTE 2: we default to empty string to make it easy to calculate prompt sizes | `Llama-2-13b-chat` | { `contextWindow`: `number` = 4096; `replicateApi`: `string` = "a16z-infra/llama13b-v2-chat:df7690f1994d94e96ad9d568eac121aecf50684a0b0963b25a41cc40061269e5" } | | `Llama-2-13b-chat.contextWindow` | `number` | | `Llama-2-13b-chat.replicateApi` | `string` | -| `Llama-2-70b-chat` | { `contextWindow`: `number` = 4096; `replicateApi`: `string` = "replicate/llama70b-v2-chat:e951f18578850b652510200860fc4ea62b3b16fac280f83ff32282f87bbd2e48" } | -| `Llama-2-70b-chat.contextWindow` | `number` | -| `Llama-2-70b-chat.replicateApi` | `string` | +| `Llama-2-13b-chat-4bit` | { `contextWindow`: `number` = 4096; `replicateApi`: `string` = "a16z-infra/llama13b-v2-chat:2a7f981751ec7fdf87b5b91ad4db53683a98082e9ff7bfd12c8cd5ea85980a52" } | +| `Llama-2-13b-chat-4bit.contextWindow` | `number` | +| `Llama-2-13b-chat-4bit.replicateApi` | `string` | +| `Llama-2-70b-chat-4bit` | { `contextWindow`: `number` = 4096; `replicateApi`: `string` = "replicate/llama70b-v2-chat:2c1608e18606fad2812020dc541930f2d0495ce32eee50074220b87300bc16e1" } | +| `Llama-2-70b-chat-4bit.contextWindow` | `number` | +| `Llama-2-70b-chat-4bit.replicateApi` | `string` | +| `Llama-2-70b-chat-old` | { `contextWindow`: `number` = 4096; `replicateApi`: `string` = "replicate/llama70b-v2-chat:e951f18578850b652510200860fc4ea62b3b16fac280f83ff32282f87bbd2e48" } | +| `Llama-2-70b-chat-old.contextWindow` | `number` | +| `Llama-2-70b-chat-old.replicateApi` | `string` | | `Llama-2-7b-chat` | { `contextWindow`: `number` = 4096; `replicateApi`: `string` = "a16z-infra/llama7b-v2-chat:4f0a4744c7295c024a1de15e1a63c880d3da035fa1f49bfd344fe076074c8eea" } | | `Llama-2-7b-chat.contextWindow` | `number` | | `Llama-2-7b-chat.replicateApi` | `string` | +| `Llama-2-7b-chat-4bit` | { `contextWindow`: `number` = 4096; `replicateApi`: `string` = "a16z-infra/llama7b-v2-chat:4f0b260b6a13eb53a6b1891f089d57c08f41003ae79458be5011303d81a394dc" } | +| `Llama-2-7b-chat-4bit.contextWindow` | `number` | +| `Llama-2-7b-chat-4bit.replicateApi` | `string` | #### Defined in @@ -858,7 +870,7 @@ ___ #### Defined in -[indices/BaseIndex.ts:70](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L70) +[indices/BaseIndex.ts:73](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L73) ___ @@ -878,7 +890,7 @@ ___ #### Defined in -[Node.ts:243](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L243) +[Node.ts:271](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L271) ___ diff --git a/apps/simple/chatEngine.ts b/apps/simple/chatEngine.ts index 7dabde557..728c6287d 100644 --- a/apps/simple/chatEngine.ts +++ b/apps/simple/chatEngine.ts @@ -1,22 +1,23 @@ -// @ts-ignore -import * as readline from "node:readline/promises"; -// @ts-ignore import { stdin as input, stdout as output } from "node:process"; +// readline/promises is still experimental so not in @types/node yet +// @ts-ignore +import readline from "node:readline/promises"; + import { - Document, - VectorStoreIndex, ContextChatEngine, + Document, serviceContextFromDefaults, + VectorStoreIndex, } from "llamaindex"; + import essay from "./essay"; async function main() { const document = new Document({ text: essay }); const serviceContext = serviceContextFromDefaults({ chunkSize: 512 }); - const index = await VectorStoreIndex.fromDocuments( - [document], - { serviceContext } - ); + const index = await VectorStoreIndex.fromDocuments([document], { + serviceContext, + }); const retriever = index.asRetriever(); retriever.similarityTopK = 5; const chatEngine = new ContextChatEngine({ retriever }); diff --git a/apps/simple/gptllama.ts b/apps/simple/gptllama.ts index 7e4c91cc5..1ecb2a1b0 100644 --- a/apps/simple/gptllama.ts +++ b/apps/simple/gptllama.ts @@ -1,7 +1,9 @@ -import { OpenAI, LlamaDeuce, ChatMessage, DeuceChatStrategy } from "llamaindex"; -// @ts-ignore -import * as readline from "node:readline/promises"; import { stdin as input, stdout as output } from "node:process"; +// readline/promises is still experimental so not in @types/node yet +// @ts-ignore +import readline from "node:readline/promises"; + +import { ChatMessage, LlamaDeuce, OpenAI } from "llamaindex"; (async () => { const gpt4 = new OpenAI({ model: "gpt-4", temperature: 0.9 }); @@ -27,7 +29,7 @@ import { stdin as input, stdout as output } from "node:process"; history.map(({ content, role }) => ({ content, role: next === l2 ? role : role === "user" ? "assistant" : "user", - })) + })), ); history.push({ content: r.message.content, diff --git a/apps/simple/listIndex.ts b/apps/simple/listIndex.ts index 0271e9d6b..aabae237e 100644 --- a/apps/simple/listIndex.ts +++ b/apps/simple/listIndex.ts @@ -13,16 +13,13 @@ async function main() { chunkSize: 40, }), }); - const document = new Document({ text: essay }); - const index = await ListIndex.fromDocuments( - [document], - { serviceContext } - ); + const document = new Document({ text: essay, id_: "essay" }); + const index = await ListIndex.fromDocuments([document], { serviceContext }); const queryEngine = index.asQueryEngine({ retriever: index.asRetriever({ mode: ListRetrieverMode.LLM }), }); const response = await queryEngine.query( - "What did the author do growing up?" + "What did the author do growing up?", ); console.log(response.toString()); } diff --git a/apps/simple/pdf.ts b/apps/simple/pdf.ts index d8fa2d447..95eef1e1f 100644 --- a/apps/simple/pdf.ts +++ b/apps/simple/pdf.ts @@ -1,4 +1,3 @@ -import fs from "fs/promises"; import { PDFReader, VectorStoreIndex } from "llamaindex"; async function main() { diff --git a/apps/simple/split.ts b/apps/simple/split.ts index c3cedb071..ca077f826 100644 --- a/apps/simple/split.ts +++ b/apps/simple/split.ts @@ -1,11 +1,10 @@ -import fs from "fs/promises"; +import fs from "node:fs/promises"; + import { SentenceSplitter } from "llamaindex"; async function main() { - const essay = await fs.readFile( - "node_modules/llamaindex/examples/abramov.txt", - "utf-8" - ); + const path = "node_modules/llamaindex/examples/abramov.txt"; + const essay = await fs.readFile(path, "utf-8"); const textSplitter = new SentenceSplitter(); diff --git a/apps/simple/storageContext.ts b/apps/simple/storageContext.ts index cb9c7102b..7326bbdba 100644 --- a/apps/simple/storageContext.ts +++ b/apps/simple/storageContext.ts @@ -1,13 +1,13 @@ import { Document, - VectorStoreIndex, storageContextFromDefaults, + VectorStoreIndex, } from "llamaindex"; import essay from "./essay"; async function main() { // Create Document object with essay - const document = new Document({ text: essay }); + const document = new Document({ text: essay, id_: "essay" }); // Split text and create embeddings. Store them in a VectorStoreIndex // persist the vector store automatically with the storage context @@ -21,7 +21,7 @@ async function main() { // Query the index const queryEngine = index.asQueryEngine(); const response = await queryEngine.query( - "What did the author do in college?" + "What did the author do in college?", ); // Output response @@ -36,7 +36,7 @@ async function main() { }); const loadedQueryEngine = loadedIndex.asQueryEngine(); const loadedResponse = await loadedQueryEngine.query( - "What did the author do growing up?" + "What did the author do growing up?", ); console.log(loadedResponse.toString()); } diff --git a/apps/simple/subquestion.ts b/apps/simple/subquestion.ts index ff7c8225f..6d46d91b5 100644 --- a/apps/simple/subquestion.ts +++ b/apps/simple/subquestion.ts @@ -1,9 +1,9 @@ -import { Document, VectorStoreIndex, SubQuestionQueryEngine } from "llamaindex"; +import { Document, SubQuestionQueryEngine, VectorStoreIndex } from "llamaindex"; import essay from "./essay"; (async () => { - const document = new Document({ text: essay }); + const document = new Document({ text: essay, id_: essay }); const index = await VectorStoreIndex.fromDocuments([document]); const queryEngine = SubQuestionQueryEngine.fromDefaults({ @@ -19,7 +19,7 @@ import essay from "./essay"; }); const response = await queryEngine.query( - "How was Paul Grahams life different before and after YC?" + "How was Paul Grahams life different before and after YC?", ); console.log(response.toString()); diff --git a/apps/simple/vectorIndex.ts b/apps/simple/vectorIndex.ts index e376d8adc..ff2691624 100644 --- a/apps/simple/vectorIndex.ts +++ b/apps/simple/vectorIndex.ts @@ -1,15 +1,15 @@ -import fs from "fs/promises"; +import fs from "node:fs/promises"; + import { Document, VectorStoreIndex } from "llamaindex"; async function main() { // Load essay from abramov.txt in Node - const essay = await fs.readFile( - "node_modules/llamaindex/examples/abramov.txt", - "utf-8" - ); + const path = "node_modules/llamaindex/examples/abramov.txt"; + + const essay = await fs.readFile(path, "utf-8"); // Create Document object with essay - const document = new Document({ text: essay }); + const document = new Document({ text: essay, id_: path }); // Split text and create embeddings. Store them in a VectorStoreIndex const index = await VectorStoreIndex.fromDocuments([document]); @@ -17,7 +17,7 @@ async function main() { // Query the index const queryEngine = index.asQueryEngine(); const response = await queryEngine.query( - "What did the author do in college?" + "What did the author do in college?", ); // Output response diff --git a/apps/simple/vectorIndexAnthropic.ts b/apps/simple/vectorIndexAnthropic.ts index 2db6645c8..6dc807cd0 100644 --- a/apps/simple/vectorIndexAnthropic.ts +++ b/apps/simple/vectorIndexAnthropic.ts @@ -1,20 +1,20 @@ -import fs from "fs/promises"; +import fs from "node:fs/promises"; + import { Anthropic, Document, - VectorStoreIndex, serviceContextFromDefaults, + VectorStoreIndex, } from "llamaindex"; async function main() { // Load essay from abramov.txt in Node - const essay = await fs.readFile( - "node_modules/llamaindex/examples/abramov.txt", - "utf-8" - ); + const path = "node_modules/llamaindex/examples/abramov.txt"; + + const essay = await fs.readFile(path, "utf-8"); // Create Document object with essay - const document = new Document({ text: essay }); + const document = new Document({ text: essay, id_: path }); // Split text and create embeddings. Store them in a VectorStoreIndex const serviceContext = serviceContextFromDefaults({ llm: new Anthropic() }); @@ -25,7 +25,7 @@ async function main() { // Query the index const queryEngine = index.asQueryEngine(); const response = await queryEngine.query( - "What did the author do in college?" + "What did the author do in college?", ); // Output response diff --git a/apps/simple/vectorIndexCustomize.ts b/apps/simple/vectorIndexCustomize.ts index 69e128dc8..b9dbe8d8b 100644 --- a/apps/simple/vectorIndexCustomize.ts +++ b/apps/simple/vectorIndexCustomize.ts @@ -1,23 +1,31 @@ -import { Document, VectorStoreIndex, RetrieverQueryEngine, OpenAI, serviceContextFromDefaults } from "llamaindex"; +import { + Document, + OpenAI, + RetrieverQueryEngine, + serviceContextFromDefaults, + VectorStoreIndex, +} from "llamaindex"; import essay from "./essay"; // Customize retrieval and query args async function main() { - const document = new Document({ text: essay }); + const document = new Document({ text: essay, id_: "essay" }); - const serviceContext = serviceContextFromDefaults( - { llm: new OpenAI({ model: "gpt-3.5-turbo", temperature: 0.0 }) } - ); + const serviceContext = serviceContextFromDefaults({ + llm: new OpenAI({ model: "gpt-3.5-turbo", temperature: 0.0 }), + }); + + const index = await VectorStoreIndex.fromDocuments([document], { + serviceContext, + }); - const index = await VectorStoreIndex.fromDocuments([document], { serviceContext }); - const retriever = index.asRetriever(); retriever.similarityTopK = 5; // TODO: cannot pass responseSynthesizer into retriever query engine const queryEngine = new RetrieverQueryEngine(retriever); - + const response = await queryEngine.query( - "What did the author do growing up?" + "What did the author do growing up?", ); console.log(response.response); } diff --git a/apps/simple/vectorIndexGPT4.ts b/apps/simple/vectorIndexGPT4.ts index 69f0f349f..6a7516dd5 100644 --- a/apps/simple/vectorIndexGPT4.ts +++ b/apps/simple/vectorIndexGPT4.ts @@ -1,20 +1,19 @@ -import fs from "fs/promises"; +import fs from "node:fs/promises"; + import { - OpenAI, Document, - VectorStoreIndex, + OpenAI, serviceContextFromDefaults, + VectorStoreIndex, } from "llamaindex"; async function main() { // Load essay from abramov.txt in Node - const essay = await fs.readFile( - "node_modules/llamaindex/examples/abramov.txt", - "utf-8" - ); + const path = "node_modules/llamaindex/examples/abramov.txt"; + const essay = await fs.readFile(path, "utf-8"); // Create Document object with essay - const document = new Document({ text: essay }); + const document = new Document({ text: essay, id_: path }); // Split text and create embeddings. Store them in a VectorStoreIndex const serviceContext = serviceContextFromDefaults({ @@ -27,7 +26,7 @@ async function main() { // Query the index const queryEngine = index.asQueryEngine(); const response = await queryEngine.query( - "What did the author do in college?" + "What did the author do in college?", ); // Output response diff --git a/examples/chatEngine.ts b/examples/chatEngine.ts index 7dabde557..728c6287d 100644 --- a/examples/chatEngine.ts +++ b/examples/chatEngine.ts @@ -1,22 +1,23 @@ -// @ts-ignore -import * as readline from "node:readline/promises"; -// @ts-ignore import { stdin as input, stdout as output } from "node:process"; +// readline/promises is still experimental so not in @types/node yet +// @ts-ignore +import readline from "node:readline/promises"; + import { - Document, - VectorStoreIndex, ContextChatEngine, + Document, serviceContextFromDefaults, + VectorStoreIndex, } from "llamaindex"; + import essay from "./essay"; async function main() { const document = new Document({ text: essay }); const serviceContext = serviceContextFromDefaults({ chunkSize: 512 }); - const index = await VectorStoreIndex.fromDocuments( - [document], - { serviceContext } - ); + const index = await VectorStoreIndex.fromDocuments([document], { + serviceContext, + }); const retriever = index.asRetriever(); retriever.similarityTopK = 5; const chatEngine = new ContextChatEngine({ retriever }); diff --git a/examples/gptllama.ts b/examples/gptllama.ts index 0ed1c93cb..1ecb2a1b0 100644 --- a/examples/gptllama.ts +++ b/examples/gptllama.ts @@ -1,6 +1,9 @@ -import { OpenAI, LlamaDeuce, ChatMessage, DeuceChatStrategy } from "llamaindex"; -import * as readline from "node:readline/promises"; import { stdin as input, stdout as output } from "node:process"; +// readline/promises is still experimental so not in @types/node yet +// @ts-ignore +import readline from "node:readline/promises"; + +import { ChatMessage, LlamaDeuce, OpenAI } from "llamaindex"; (async () => { const gpt4 = new OpenAI({ model: "gpt-4", temperature: 0.9 }); @@ -26,7 +29,7 @@ import { stdin as input, stdout as output } from "node:process"; history.map(({ content, role }) => ({ content, role: next === l2 ? role : role === "user" ? "assistant" : "user", - })) + })), ); history.push({ content: r.message.content, diff --git a/examples/listIndex.ts b/examples/listIndex.ts index 0271e9d6b..aabae237e 100644 --- a/examples/listIndex.ts +++ b/examples/listIndex.ts @@ -13,16 +13,13 @@ async function main() { chunkSize: 40, }), }); - const document = new Document({ text: essay }); - const index = await ListIndex.fromDocuments( - [document], - { serviceContext } - ); + const document = new Document({ text: essay, id_: "essay" }); + const index = await ListIndex.fromDocuments([document], { serviceContext }); const queryEngine = index.asQueryEngine({ retriever: index.asRetriever({ mode: ListRetrieverMode.LLM }), }); const response = await queryEngine.query( - "What did the author do growing up?" + "What did the author do growing up?", ); console.log(response.toString()); } diff --git a/examples/llamadeuce.ts b/examples/llamadeuce.ts index d7b309481..373c0c0a2 100644 --- a/examples/llamadeuce.ts +++ b/examples/llamadeuce.ts @@ -1,7 +1,7 @@ -import { LlamaDeuce } from "llamaindex"; +import { DeuceChatStrategy, LlamaDeuce } from "llamaindex"; (async () => { - const deuce = new LlamaDeuce(); + const deuce = new LlamaDeuce({ chatStrategy: DeuceChatStrategy.META }); const result = await deuce.chat([{ content: "Hello, world!", role: "user" }]); console.log(result); })(); diff --git a/examples/pdf.ts b/examples/pdf.ts index d8fa2d447..95eef1e1f 100644 --- a/examples/pdf.ts +++ b/examples/pdf.ts @@ -1,4 +1,3 @@ -import fs from "fs/promises"; import { PDFReader, VectorStoreIndex } from "llamaindex"; async function main() { diff --git a/examples/split.ts b/examples/split.ts new file mode 100644 index 000000000..ca077f826 --- /dev/null +++ b/examples/split.ts @@ -0,0 +1,16 @@ +import fs from "node:fs/promises"; + +import { SentenceSplitter } from "llamaindex"; + +async function main() { + const path = "node_modules/llamaindex/examples/abramov.txt"; + const essay = await fs.readFile(path, "utf-8"); + + const textSplitter = new SentenceSplitter(); + + const chunks = textSplitter.splitTextWithOverlaps(essay); + + console.log(chunks); +} + +main(); diff --git a/examples/storageContext.ts b/examples/storageContext.ts index cb9c7102b..7326bbdba 100644 --- a/examples/storageContext.ts +++ b/examples/storageContext.ts @@ -1,13 +1,13 @@ import { Document, - VectorStoreIndex, storageContextFromDefaults, + VectorStoreIndex, } from "llamaindex"; import essay from "./essay"; async function main() { // Create Document object with essay - const document = new Document({ text: essay }); + const document = new Document({ text: essay, id_: "essay" }); // Split text and create embeddings. Store them in a VectorStoreIndex // persist the vector store automatically with the storage context @@ -21,7 +21,7 @@ async function main() { // Query the index const queryEngine = index.asQueryEngine(); const response = await queryEngine.query( - "What did the author do in college?" + "What did the author do in college?", ); // Output response @@ -36,7 +36,7 @@ async function main() { }); const loadedQueryEngine = loadedIndex.asQueryEngine(); const loadedResponse = await loadedQueryEngine.query( - "What did the author do growing up?" + "What did the author do growing up?", ); console.log(loadedResponse.toString()); } diff --git a/examples/subquestion.ts b/examples/subquestion.ts index ff7c8225f..6d46d91b5 100644 --- a/examples/subquestion.ts +++ b/examples/subquestion.ts @@ -1,9 +1,9 @@ -import { Document, VectorStoreIndex, SubQuestionQueryEngine } from "llamaindex"; +import { Document, SubQuestionQueryEngine, VectorStoreIndex } from "llamaindex"; import essay from "./essay"; (async () => { - const document = new Document({ text: essay }); + const document = new Document({ text: essay, id_: essay }); const index = await VectorStoreIndex.fromDocuments([document]); const queryEngine = SubQuestionQueryEngine.fromDefaults({ @@ -19,7 +19,7 @@ import essay from "./essay"; }); const response = await queryEngine.query( - "How was Paul Grahams life different before and after YC?" + "How was Paul Grahams life different before and after YC?", ); console.log(response.toString()); diff --git a/examples/vectorIndex.ts b/examples/vectorIndex.ts index e376d8adc..ff2691624 100644 --- a/examples/vectorIndex.ts +++ b/examples/vectorIndex.ts @@ -1,15 +1,15 @@ -import fs from "fs/promises"; +import fs from "node:fs/promises"; + import { Document, VectorStoreIndex } from "llamaindex"; async function main() { // Load essay from abramov.txt in Node - const essay = await fs.readFile( - "node_modules/llamaindex/examples/abramov.txt", - "utf-8" - ); + const path = "node_modules/llamaindex/examples/abramov.txt"; + + const essay = await fs.readFile(path, "utf-8"); // Create Document object with essay - const document = new Document({ text: essay }); + const document = new Document({ text: essay, id_: path }); // Split text and create embeddings. Store them in a VectorStoreIndex const index = await VectorStoreIndex.fromDocuments([document]); @@ -17,7 +17,7 @@ async function main() { // Query the index const queryEngine = index.asQueryEngine(); const response = await queryEngine.query( - "What did the author do in college?" + "What did the author do in college?", ); // Output response diff --git a/examples/vectorIndexAnthropic.ts b/examples/vectorIndexAnthropic.ts index 2db6645c8..6dc807cd0 100644 --- a/examples/vectorIndexAnthropic.ts +++ b/examples/vectorIndexAnthropic.ts @@ -1,20 +1,20 @@ -import fs from "fs/promises"; +import fs from "node:fs/promises"; + import { Anthropic, Document, - VectorStoreIndex, serviceContextFromDefaults, + VectorStoreIndex, } from "llamaindex"; async function main() { // Load essay from abramov.txt in Node - const essay = await fs.readFile( - "node_modules/llamaindex/examples/abramov.txt", - "utf-8" - ); + const path = "node_modules/llamaindex/examples/abramov.txt"; + + const essay = await fs.readFile(path, "utf-8"); // Create Document object with essay - const document = new Document({ text: essay }); + const document = new Document({ text: essay, id_: path }); // Split text and create embeddings. Store them in a VectorStoreIndex const serviceContext = serviceContextFromDefaults({ llm: new Anthropic() }); @@ -25,7 +25,7 @@ async function main() { // Query the index const queryEngine = index.asQueryEngine(); const response = await queryEngine.query( - "What did the author do in college?" + "What did the author do in college?", ); // Output response diff --git a/examples/vectorIndexCustomize.ts b/examples/vectorIndexCustomize.ts index 69e128dc8..b9dbe8d8b 100644 --- a/examples/vectorIndexCustomize.ts +++ b/examples/vectorIndexCustomize.ts @@ -1,23 +1,31 @@ -import { Document, VectorStoreIndex, RetrieverQueryEngine, OpenAI, serviceContextFromDefaults } from "llamaindex"; +import { + Document, + OpenAI, + RetrieverQueryEngine, + serviceContextFromDefaults, + VectorStoreIndex, +} from "llamaindex"; import essay from "./essay"; // Customize retrieval and query args async function main() { - const document = new Document({ text: essay }); + const document = new Document({ text: essay, id_: "essay" }); - const serviceContext = serviceContextFromDefaults( - { llm: new OpenAI({ model: "gpt-3.5-turbo", temperature: 0.0 }) } - ); + const serviceContext = serviceContextFromDefaults({ + llm: new OpenAI({ model: "gpt-3.5-turbo", temperature: 0.0 }), + }); + + const index = await VectorStoreIndex.fromDocuments([document], { + serviceContext, + }); - const index = await VectorStoreIndex.fromDocuments([document], { serviceContext }); - const retriever = index.asRetriever(); retriever.similarityTopK = 5; // TODO: cannot pass responseSynthesizer into retriever query engine const queryEngine = new RetrieverQueryEngine(retriever); - + const response = await queryEngine.query( - "What did the author do growing up?" + "What did the author do growing up?", ); console.log(response.response); } diff --git a/examples/vectorIndexGPT4.ts b/examples/vectorIndexGPT4.ts index 69f0f349f..6a7516dd5 100644 --- a/examples/vectorIndexGPT4.ts +++ b/examples/vectorIndexGPT4.ts @@ -1,20 +1,19 @@ -import fs from "fs/promises"; +import fs from "node:fs/promises"; + import { - OpenAI, Document, - VectorStoreIndex, + OpenAI, serviceContextFromDefaults, + VectorStoreIndex, } from "llamaindex"; async function main() { // Load essay from abramov.txt in Node - const essay = await fs.readFile( - "node_modules/llamaindex/examples/abramov.txt", - "utf-8" - ); + const path = "node_modules/llamaindex/examples/abramov.txt"; + const essay = await fs.readFile(path, "utf-8"); // Create Document object with essay - const document = new Document({ text: essay }); + const document = new Document({ text: essay, id_: path }); // Split text and create embeddings. Store them in a VectorStoreIndex const serviceContext = serviceContextFromDefaults({ @@ -27,7 +26,7 @@ async function main() { // Query the index const queryEngine = index.asQueryEngine(); const response = await queryEngine.query( - "What did the author do in college?" + "What did the author do in college?", ); // Output response diff --git a/package.json b/package.json index baecad3a0..fb76342c6 100644 --- a/package.json +++ b/package.json @@ -17,8 +17,8 @@ "eslint-config-custom": "workspace:*", "husky": "^8.0.3", "jest": "^29.6.2", - "prettier": "^2.8.8", - "prettier-plugin-tailwindcss": "^0.3.0", + "prettier": "^3.0.1", + "prettier-plugin-organize-imports": "^3.2.3", "ts-jest": "^29.1.1", "turbo": "^1.10.12" }, diff --git a/packages/core/src/Node.ts b/packages/core/src/Node.ts index a77599015..510351b77 100644 --- a/packages/core/src/Node.ts +++ b/packages/core/src/Node.ts @@ -1,3 +1,4 @@ +import crypto from "crypto"; // TODO Node dependency import { v4 as uuidv4 } from "uuid"; export enum NodeRelationship { @@ -35,6 +36,12 @@ export type RelatedNodeType = RelatedNodeInfo | RelatedNodeInfo[]; * Generic abstract class for retrievable nodes */ export abstract class BaseNode { + /** + * The unique ID of the Node/Document. The trailing underscore is here + * to avoid collisions with the id keyword in Python. + * + * Set to a UUID by default. + */ id_: string = uuidv4(); embedding?: number[]; @@ -55,10 +62,6 @@ export abstract class BaseNode { abstract getMetadataStr(metadataMode: MetadataMode): string; abstract setContent(value: any): void; - get nodeId(): string { - return this.id_; - } - get sourceNode(): RelatedNodeInfo | undefined { const relationship = this.relationships[NodeRelationship.SOURCE]; @@ -74,7 +77,7 @@ export abstract class BaseNode { if (Array.isArray(relationship)) { throw new Error( - "Previous object must be a single RelatedNodeInfo object" + "Previous object must be a single RelatedNodeInfo object", ); } @@ -106,13 +109,15 @@ export abstract class BaseNode { if (!Array.isArray(relationship)) { throw new Error( - "Child object must be a an array of RelatedNodeInfo objects" + "Child object must be a an array of RelatedNodeInfo objects", ); } return relationship; } + abstract generateHash(): string; + getEmbedding(): number[] { if (this.embedding === undefined) { throw new Error("Embedding not set"); @@ -123,7 +128,7 @@ export abstract class BaseNode { asRelatedNodeInfo(): RelatedNodeInfo { return { - nodeId: this.nodeId, + nodeId: this.id_, metadata: this.metadata, hash: this.hash, }; @@ -152,10 +157,27 @@ export class TextNode extends BaseNode { constructor(init?: Partial<TextNode>) { super(init); Object.assign(this, init); + + if (new.target === TextNode) { + // Don't generate the hash repeatedly so only do it if this is + // constructing the derived class + this.hash = this.generateHash(); + } } + /** + * Generate a hash of the text node. + * The ID is not part of the hash as it can change independent of content. + * @returns + */ generateHash() { - throw new Error("Not implemented"); + const hashFunction = crypto.createHash("sha256"); + hashFunction.update(`type=${this.getType()}`); + hashFunction.update( + `startCharIdx=${this.startCharIdx} endCharIdx=${this.endCharIdx}`, + ); + hashFunction.update(this.getContent(MetadataMode.ALL)); + return hashFunction.digest("base64"); } getType(): ObjectType { @@ -190,6 +212,8 @@ export class TextNode extends BaseNode { setContent(value: string) { this.text = value; + + this.hash = this.generateHash(); } getNodeInfo() { @@ -215,6 +239,10 @@ export class IndexNode extends TextNode { constructor(init?: Partial<IndexNode>) { super(init); Object.assign(this, init); + + if (new.target === IndexNode) { + this.hash = this.generateHash(); + } } getType(): ObjectType { @@ -229,15 +257,15 @@ export class Document extends TextNode { constructor(init?: Partial<Document>) { super(init); Object.assign(this, init); + + if (new.target === Document) { + this.hash = this.generateHash(); + } } getType() { return ObjectType.DOCUMENT; } - - get docId() { - return this.id_; - } } export function jsonToNode(json: any) { diff --git a/packages/core/src/indices/BaseIndex.ts b/packages/core/src/indices/BaseIndex.ts index 27c4e17da..0df4f5e62 100644 --- a/packages/core/src/indices/BaseIndex.ts +++ b/packages/core/src/indices/BaseIndex.ts @@ -1,13 +1,13 @@ -import { Document, BaseNode, jsonToNode } from "../Node"; import { v4 as uuidv4 } from "uuid"; +import { BaseNode, Document, jsonToNode } from "../Node"; +import { BaseQueryEngine } from "../QueryEngine"; +import { ResponseSynthesizer } from "../ResponseSynthesizer"; import { BaseRetriever } from "../Retriever"; import { ServiceContext } from "../ServiceContext"; -import { StorageContext } from "../storage/StorageContext"; import { BaseDocumentStore } from "../storage/docStore/types"; -import { VectorStore } from "../storage/vectorStore/types"; import { BaseIndexStore } from "../storage/indexStore/types"; -import { BaseQueryEngine } from "../QueryEngine"; -import { ResponseSynthesizer } from "../ResponseSynthesizer"; +import { StorageContext } from "../storage/StorageContext"; +import { VectorStore } from "../storage/vectorStore/types"; /** * The underlying structure of each index. @@ -43,7 +43,6 @@ export enum IndexStructType { export class IndexDict extends IndexStruct { nodesDict: Record<string, BaseNode> = {}; - docStore: Record<string, Document> = {}; // FIXME: this should be implemented in storageContext type: IndexStructType = IndexStructType.SIMPLE_DICT; getSummary(): string { @@ -65,6 +64,10 @@ export class IndexDict extends IndexStruct { type: this.type, }; } + + delete(nodeId: string) { + delete this.nodesDict[nodeId]; + } } export function jsonToIndexStruct(json: any): IndexStruct { @@ -148,6 +151,24 @@ export abstract class BaseIndex<T> { retriever?: BaseRetriever; responseSynthesizer?: ResponseSynthesizer; }): BaseQueryEngine; + + /** + * Insert a document into the index. + * @param document + */ + async insert(document: Document) { + const nodes = this.serviceContext.nodeParser.getNodesFromDocuments([ + document, + ]); + await this.insertNodes(nodes); + this.docStore.setDocumentHash(document.id_, document.hash); + } + + abstract insertNodes(nodes: BaseNode[]): Promise<void>; + abstract deleteRefDoc( + refDocId: string, + deleteFromDocStore?: boolean, + ): Promise<void>; } export interface VectorIndexOptions { diff --git a/packages/core/src/indices/list/ListIndex.ts b/packages/core/src/indices/list/ListIndex.ts index d52752355..21b6ad40b 100644 --- a/packages/core/src/indices/list/ListIndex.ts +++ b/packages/core/src/indices/list/ListIndex.ts @@ -1,26 +1,30 @@ +import _ from "lodash"; import { BaseNode, Document } from "../../Node"; -import { BaseIndex, BaseIndexInit, IndexList } from "../BaseIndex"; import { BaseQueryEngine, RetrieverQueryEngine } from "../../QueryEngine"; import { - StorageContext, - storageContextFromDefaults, -} from "../../storage/StorageContext"; + CompactAndRefine, + ResponseSynthesizer, +} from "../../ResponseSynthesizer"; import { BaseRetriever } from "../../Retriever"; -import { - ListIndexRetriever, - ListIndexLLMRetriever, -} from "./ListIndexRetriever"; import { ServiceContext, serviceContextFromDefaults, } from "../../ServiceContext"; import { BaseDocumentStore, RefDocInfo } from "../../storage/docStore/types"; -import _ from "lodash"; import { - ResponseSynthesizer, - CompactAndRefine, -} from "../../ResponseSynthesizer"; -import { IndexStructType } from "../BaseIndex"; + StorageContext, + storageContextFromDefaults, +} from "../../storage/StorageContext"; +import { + BaseIndex, + BaseIndexInit, + IndexList, + IndexStructType, +} from "../BaseIndex"; +import { + ListIndexLLMRetriever, + ListIndexRetriever, +} from "./ListIndexRetriever"; export enum ListRetrieverMode { DEFAULT = "default", @@ -57,7 +61,7 @@ export class ListIndex extends BaseIndex<IndexList> { if (options.indexStruct && indexStructs.length > 0) { throw new Error( - "Cannot initialize index with both indexStruct and indexStore" + "Cannot initialize index with both indexStruct and indexStore", ); } @@ -67,7 +71,7 @@ export class ListIndex extends BaseIndex<IndexList> { indexStruct = indexStructs[0]; } else if (indexStructs.length > 1 && options.indexId) { indexStruct = (await indexStore.getIndexStruct( - options.indexId + options.indexId, )) as IndexList; } else { indexStruct = null; @@ -76,25 +80,25 @@ export class ListIndex extends BaseIndex<IndexList> { // check indexStruct type if (indexStruct && indexStruct.type !== IndexStructType.LIST) { throw new Error( - "Attempting to initialize ListIndex with non-list indexStruct" + "Attempting to initialize ListIndex with non-list indexStruct", ); } if (indexStruct) { if (options.nodes) { throw new Error( - "Cannot initialize VectorStoreIndex with both nodes and indexStruct" + "Cannot initialize VectorStoreIndex with both nodes and indexStruct", ); } } else { if (!options.nodes) { throw new Error( - "Cannot initialize VectorStoreIndex without nodes or indexStruct" + "Cannot initialize VectorStoreIndex without nodes or indexStruct", ); } - indexStruct = await ListIndex._buildIndexFromNodes( + indexStruct = await ListIndex.buildIndexFromNodes( options.nodes, - storageContext.docStore + storageContext.docStore, ); await indexStore.addIndexStruct(indexStruct); @@ -114,7 +118,7 @@ export class ListIndex extends BaseIndex<IndexList> { args: { storageContext?: StorageContext; serviceContext?: ServiceContext; - } = {} + } = {}, ): Promise<ListIndex> { let { storageContext, serviceContext } = args; storageContext = storageContext ?? (await storageContextFromDefaults({})); @@ -169,10 +173,10 @@ export class ListIndex extends BaseIndex<IndexList> { return new RetrieverQueryEngine(retriever, responseSynthesizer); } - static async _buildIndexFromNodes( + static async buildIndexFromNodes( nodes: BaseNode[], docStore: BaseDocumentStore, - indexStruct?: IndexList + indexStruct?: IndexList, ): Promise<IndexList> { indexStruct = indexStruct || new IndexList(); @@ -184,16 +188,43 @@ export class ListIndex extends BaseIndex<IndexList> { return indexStruct; } - protected _insert(nodes: BaseNode[]): void { + async insertNodes(nodes: BaseNode[]): Promise<void> { for (const node of nodes) { this.indexStruct.addNode(node); } } - protected _deleteNode(nodeId: string): void { + async deleteRefDoc( + refDocId: string, + deleteFromDocStore?: boolean, + ): Promise<void> { + const refDocInfo = await this.docStore.getRefDocInfo(refDocId); + + if (!refDocInfo) { + return; + } + + await this.deleteNodes(refDocInfo.nodeIds, false); + + if (deleteFromDocStore) { + await this.docStore.deleteRefDoc(refDocId, false); + } + + return; + } + + async deleteNodes(nodeIds: string[], deleteFromDocStore: boolean) { this.indexStruct.nodes = this.indexStruct.nodes.filter( - (existingNodeId: string) => existingNodeId !== nodeId + (existingNodeId: string) => !nodeIds.includes(existingNodeId), ); + + if (deleteFromDocStore) { + for (const nodeId of nodeIds) { + await this.docStore.deleteDocument(nodeId, false); + } + } + + await this.storageContext.indexStore.addIndexStruct(this.indexStruct); } async getRefDocInfo(): Promise<Record<string, RefDocInfo>> { diff --git a/packages/core/src/indices/vectorStore/VectorStoreIndex.ts b/packages/core/src/indices/vectorStore/VectorStoreIndex.ts index 5b3a4d9c8..04624bc89 100644 --- a/packages/core/src/indices/vectorStore/VectorStoreIndex.ts +++ b/packages/core/src/indices/vectorStore/VectorStoreIndex.ts @@ -1,15 +1,17 @@ import { - Document, BaseNode, + Document, MetadataMode, NodeWithEmbedding, } from "../../Node"; import { BaseQueryEngine, RetrieverQueryEngine } from "../../QueryEngine"; -import { VectorIndexRetriever } from "./VectorIndexRetriever"; +import { ResponseSynthesizer } from "../../ResponseSynthesizer"; +import { BaseRetriever } from "../../Retriever"; import { ServiceContext, serviceContextFromDefaults, } from "../../ServiceContext"; +import { BaseDocumentStore } from "../../storage/docStore/types"; import { StorageContext, storageContextFromDefaults, @@ -18,13 +20,11 @@ import { VectorStore } from "../../storage/vectorStore/types"; import { BaseIndex, IndexDict, + IndexStructType, VectorIndexConstructorProps, VectorIndexOptions, - IndexStructType } from "../BaseIndex"; -import { BaseRetriever } from "../../Retriever"; -import { ResponseSynthesizer } from "../../ResponseSynthesizer"; -import { BaseDocumentStore } from "../../storage/docStore/types"; +import { VectorIndexRetriever } from "./VectorIndexRetriever"; /** * The VectorStoreIndex, an index that stores the nodes only according to their vector embedings. @@ -55,11 +55,11 @@ export class VectorStoreIndex extends BaseIndex<IndexDict> { // Setup IndexStruct from storage let indexStructs = (await indexStore.getIndexStructs()) as IndexDict[]; - let indexStruct: IndexDict | null; + let indexStruct: IndexDict | undefined; if (options.indexStruct && indexStructs.length > 0) { throw new Error( - "Cannot initialize index with both indexStruct and indexStore" + "Cannot initialize index with both indexStruct and indexStore", ); } @@ -69,41 +69,37 @@ export class VectorStoreIndex extends BaseIndex<IndexDict> { indexStruct = indexStructs[0]; } else if (indexStructs.length > 1 && options.indexId) { indexStruct = (await indexStore.getIndexStruct( - options.indexId + options.indexId, )) as IndexDict; } else { - indexStruct = null; + indexStruct = undefined; } // check indexStruct type if (indexStruct && indexStruct.type !== IndexStructType.SIMPLE_DICT) { throw new Error( - "Attempting to initialize VectorStoreIndex with non-vector indexStruct" + "Attempting to initialize VectorStoreIndex with non-vector indexStruct", ); } - if (indexStruct) { - if (options.nodes) { - throw new Error( - "Cannot initialize VectorStoreIndex with both nodes and indexStruct" - ); - } - } else { - if (!options.nodes) { - throw new Error( - "Cannot initialize VectorStoreIndex without nodes or indexStruct" - ); - } - indexStruct = await VectorStoreIndex.buildIndexFromNodes( - options.nodes, - serviceContext, - vectorStore, - docStore + if (!indexStruct && !options.nodes) { + throw new Error( + "Cannot initialize VectorStoreIndex without nodes or indexStruct", ); - - await indexStore.addIndexStruct(indexStruct); } + const nodes = options.nodes ?? []; + + indexStruct = await VectorStoreIndex.buildIndexFromNodes( + nodes, + serviceContext, + vectorStore, + docStore, + indexStruct, + ); + + await indexStore.addIndexStruct(indexStruct); + return new VectorStoreIndex({ storageContext, serviceContext, @@ -123,7 +119,7 @@ export class VectorStoreIndex extends BaseIndex<IndexDict> { static async getNodeEmbeddingResults( nodes: BaseNode[], serviceContext: ServiceContext, - logProgress = false + logProgress = false, ) { const nodesWithEmbeddings: NodeWithEmbedding[] = []; @@ -133,7 +129,7 @@ export class VectorStoreIndex extends BaseIndex<IndexDict> { console.log(`getting embedding for node ${i}/${nodes.length}`); } const embedding = await serviceContext.embedModel.getTextEmbedding( - node.getContent(MetadataMode.EMBED) + node.getContent(MetadataMode.EMBED), ); nodesWithEmbeddings.push({ node, embedding }); } @@ -152,23 +148,35 @@ export class VectorStoreIndex extends BaseIndex<IndexDict> { nodes: BaseNode[], serviceContext: ServiceContext, vectorStore: VectorStore, - docStore: BaseDocumentStore + docStore: BaseDocumentStore, + indexDict?: IndexDict, ): Promise<IndexDict> { + indexDict = indexDict ?? new IndexDict(); + + // Check if the index already has nodes with the same hash + const newNodes = nodes.filter((node) => + Object.entries(indexDict!.nodesDict).reduce((acc, [key, value]) => { + if (value.hash === node.hash) { + acc = false; + } + return acc; + }, true), + ); + const embeddingResults = await this.getNodeEmbeddingResults( - nodes, - serviceContext + newNodes, + serviceContext, ); - vectorStore.add(embeddingResults); + await vectorStore.add(embeddingResults); if (!vectorStore.storesText) { await docStore.addDocuments( embeddingResults.map((result) => result.node), - true + true, ); } - const indexDict = new IndexDict(); for (const { node } of embeddingResults) { indexDict.addNode(node); } @@ -188,7 +196,7 @@ export class VectorStoreIndex extends BaseIndex<IndexDict> { args: { storageContext?: StorageContext; serviceContext?: ServiceContext; - } = {} + } = {}, ): Promise<VectorStoreIndex> { let { storageContext, serviceContext } = args; storageContext = storageContext ?? (await storageContextFromDefaults({})); @@ -217,6 +225,57 @@ export class VectorStoreIndex extends BaseIndex<IndexDict> { responseSynthesizer?: ResponseSynthesizer; }): BaseQueryEngine { const { retriever, responseSynthesizer } = options ?? {}; - return new RetrieverQueryEngine(retriever ?? this.asRetriever(), responseSynthesizer); + return new RetrieverQueryEngine( + retriever ?? this.asRetriever(), + responseSynthesizer, + ); + } + + async insertNodes(nodes: BaseNode[]): Promise<void> { + const embeddingResults = await VectorStoreIndex.getNodeEmbeddingResults( + nodes, + this.serviceContext, + ); + + const newIds = await this.vectorStore.add(embeddingResults); + + if (!this.vectorStore.storesText) { + for (let i = 0; i < nodes.length; ++i) { + this.indexStruct.addNode(nodes[i], newIds[i]); + this.docStore.addDocuments([nodes[i]], true); + } + } else { + for (let i = 0; i < nodes.length; ++i) { + if (nodes[i].getType() === "INDEX") { + this.indexStruct.addNode(nodes[i], newIds[i]); + this.docStore.addDocuments([nodes[i]], true); + } + } + } + + await this.storageContext.indexStore.addIndexStruct(this.indexStruct); + } + + async deleteRefDoc( + refDocId: string, + deleteFromDocStore: boolean = true, + ): Promise<void> { + this.vectorStore.delete(refDocId); + + if (!this.vectorStore.storesText) { + const refDocInfo = await this.docStore.getRefDocInfo(refDocId); + + if (refDocInfo) { + for (const nodeId of refDocInfo.nodeIds) { + this.indexStruct.delete(nodeId); + } + } + + await this.storageContext.indexStore.addIndexStruct(this.indexStruct); + } + + if (deleteFromDocStore) { + await this.docStore.deleteDocument(refDocId, false); + } } } diff --git a/packages/core/src/llm/LLM.ts b/packages/core/src/llm/LLM.ts index 08e5342c9..5304099e4 100644 --- a/packages/core/src/llm/LLM.ts +++ b/packages/core/src/llm/LLM.ts @@ -1,21 +1,21 @@ +import OpenAILLM from "openai"; import { CallbackManager, Event } from "../callbacks/CallbackManager"; import { handleOpenAIStream } from "../callbacks/utility/handleOpenAIStream"; -import { OpenAISession, getOpenAISession } from "./openai"; -import OpenAILLM from "openai"; -import { ReplicateSession } from "./replicate"; import { + AnthropicSession, ANTHROPIC_AI_PROMPT, ANTHROPIC_HUMAN_PROMPT, - AnthropicSession, getAnthropicSession, } from "./anthropic"; import { AzureOpenAIConfig, + getAzureBaseUrl, getAzureConfigFromEnv, getAzureModel, - getAzureBaseUrl, shouldUseAzure, } from "./azure"; +import { getOpenAISession, OpenAISession } from "./openai"; +import { ReplicateSession } from "./replicate"; export type MessageType = | "user" @@ -108,7 +108,7 @@ export class OpenAI implements LLM { if (!azureConfig.apiKey) { throw new Error( - "Azure API key is required for OpenAI Azure models. Please set the AZURE_OPENAI_KEY environment variable." + "Azure API key is required for OpenAI Azure models. Please set the AZURE_OPENAI_KEY environment variable.", ); } @@ -138,7 +138,7 @@ export class OpenAI implements LLM { } mapMessageType( - messageType: MessageType + messageType: MessageType, ): "user" | "assistant" | "system" | "function" { switch (messageType) { case "user": @@ -156,7 +156,7 @@ export class OpenAI implements LLM { async chat( messages: ChatMessage[], - parentEvent?: Event + parentEvent?: Event, ): Promise<ChatResponse> { const baseRequestParams: OpenAILLM.Chat.CompletionCreateParams = { model: this.model, @@ -196,7 +196,7 @@ export class OpenAI implements LLM { async complete( prompt: string, - parentEvent?: Event + parentEvent?: Event, ): Promise<CompletionResponse> { return this.chat([{ content: prompt, role: "user" }], parentEvent); } @@ -321,7 +321,7 @@ export class LlamaDeuce implements LLM { mapMessagesToPromptMeta( messages: ChatMessage[], - opts?: { withBos?: boolean; replicate4Bit?: boolean } + opts?: { withBos?: boolean; replicate4Bit?: boolean }, ) { const { withBos = false, replicate4Bit = false } = opts ?? {}; const DEFAULT_SYSTEM_PROMPT = `You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature. @@ -354,7 +354,7 @@ If a question does not make any sense, or is not factually coherent, explain why // @ts-ignore if (messages[0].role !== "user") { throw new Error( - "LlamaDeuce: if there is a system message, the second message must be a user message." + "LlamaDeuce: if there is a system message, the second message must be a user message.", ); } @@ -384,7 +384,7 @@ If a question does not make any sense, or is not factually coherent, explain why async chat( messages: ChatMessage[], - _parentEvent?: Event + _parentEvent?: Event, ): Promise<ChatResponse> { const api = ALL_AVAILABLE_LLAMADEUCE_MODELS[this.model] .replicateApi as `${string}/${string}:${string}`; @@ -408,7 +408,7 @@ If a question does not make any sense, or is not factually coherent, explain why const response = await this.replicateSession.replicate.run( api, - replicateOptions + replicateOptions, ); return { message: { @@ -421,7 +421,7 @@ If a question does not make any sense, or is not factually coherent, explain why async complete( prompt: string, - parentEvent?: Event + parentEvent?: Event, ): Promise<CompletionResponse> { return this.chat([{ content: prompt, role: "user" }], parentEvent); } @@ -483,7 +483,7 @@ export class Anthropic implements LLM { async chat( messages: ChatMessage[], - parentEvent?: Event | undefined + parentEvent?: Event | undefined, ): Promise<ChatResponse> { const response = await this.session.anthropic.completions.create({ model: this.model, @@ -501,7 +501,7 @@ export class Anthropic implements LLM { } async complete( prompt: string, - parentEvent?: Event | undefined + parentEvent?: Event | undefined, ): Promise<CompletionResponse> { return this.chat([{ content: prompt, role: "user" }], parentEvent); } diff --git a/packages/core/src/storage/docStore/KVDocumentStore.ts b/packages/core/src/storage/docStore/KVDocumentStore.ts index 027672e6d..868b81deb 100644 --- a/packages/core/src/storage/docStore/KVDocumentStore.ts +++ b/packages/core/src/storage/docStore/KVDocumentStore.ts @@ -1,9 +1,9 @@ -import { BaseNode, Document, ObjectType, TextNode } from "../../Node"; -import { BaseDocumentStore, RefDocInfo } from "./types"; -import { BaseKVStore } from "../kvStore/types"; import _, * as lodash from "lodash"; -import { docToJson, jsonToDoc } from "./utils"; +import { BaseNode, ObjectType } from "../../Node"; import { DEFAULT_NAMESPACE } from "../constants"; +import { BaseKVStore } from "../kvStore/types"; +import { BaseDocumentStore, RefDocInfo } from "./types"; +import { docToJson, jsonToDoc } from "./utils"; type DocMetaData = { docHash: string; refDocId?: string }; @@ -32,7 +32,7 @@ export class KVDocumentStore extends BaseDocumentStore { async addDocuments( docs: BaseNode[], - allowUpdate: boolean = true + allowUpdate: boolean = true, ): Promise<void> { for (var idx = 0; idx < docs.length; idx++) { const doc = docs[idx]; @@ -41,7 +41,7 @@ export class KVDocumentStore extends BaseDocumentStore { } if (!allowUpdate && (await this.documentExists(doc.id_))) { throw new Error( - `doc_id ${doc.id_} already exists. Set allow_update to True to overwrite.` + `doc_id ${doc.id_} already exists. Set allow_update to True to overwrite.`, ); } let nodeKey = doc.id_; @@ -51,17 +51,17 @@ export class KVDocumentStore extends BaseDocumentStore { if (doc.getType() === ObjectType.TEXT && doc.sourceNode !== undefined) { let refDocInfo = (await this.getRefDocInfo(doc.sourceNode.nodeId)) || { - docIds: [], + nodeIds: [], extraInfo: {}, }; - refDocInfo.docIds.push(doc.id_); + refDocInfo.nodeIds.push(doc.id_); if (_.isEmpty(refDocInfo.extraInfo)) { refDocInfo.extraInfo = {}; } await this.kvstore.put( doc.sourceNode.nodeId, refDocInfo, - this.refDocCollection + this.refDocCollection, ); metadata.refDocId = doc.sourceNode.nodeId!; } @@ -72,7 +72,7 @@ export class KVDocumentStore extends BaseDocumentStore { async getDocument( docId: string, - raiseError: boolean = true + raiseError: boolean = true, ): Promise<BaseNode | undefined> { let json = await this.kvstore.get(docId, this.nodeCollection); if (_.isNil(json)) { @@ -131,7 +131,7 @@ export class KVDocumentStore extends BaseDocumentStore { async deleteDocument( docId: string, raiseError: boolean = true, - removeRefDocNode: boolean = true + removeRefDocNode: boolean = true, ): Promise<void> { if (removeRefDocNode) { await this.removeRefDocNode(docId); @@ -147,7 +147,7 @@ export class KVDocumentStore extends BaseDocumentStore { async deleteRefDoc( refDocId: string, - raiseError: boolean = true + raiseError: boolean = true, ): Promise<void> { let refDocInfo = await this.getRefDocInfo(refDocId); if (_.isNil(refDocInfo)) { @@ -158,7 +158,7 @@ export class KVDocumentStore extends BaseDocumentStore { } } - for (let docId of refDocInfo.docIds) { + for (let docId of refDocInfo.nodeIds) { await this.deleteDocument(docId, false, false); } diff --git a/packages/core/src/storage/docStore/types.ts b/packages/core/src/storage/docStore/types.ts index e744fe060..7ef032cd5 100644 --- a/packages/core/src/storage/docStore/types.ts +++ b/packages/core/src/storage/docStore/types.ts @@ -1,14 +1,14 @@ import { BaseNode } from "../../Node"; -import { GenericFileSystem } from "../FileSystem"; import { - DEFAULT_PERSIST_DIR, DEFAULT_DOC_STORE_PERSIST_FILENAME, + DEFAULT_PERSIST_DIR, } from "../constants"; +import { GenericFileSystem } from "../FileSystem"; const defaultPersistPath = `${DEFAULT_PERSIST_DIR}/${DEFAULT_DOC_STORE_PERSIST_FILENAME}`; export interface RefDocInfo { - docIds: string[]; + nodeIds: string[]; extraInfo: Record<string, any>; } @@ -16,7 +16,7 @@ export abstract class BaseDocumentStore { // Save/load persist( persistPath: string = defaultPersistPath, - fs?: GenericFileSystem + fs?: GenericFileSystem, ): void { // Persist the docstore to a file. } @@ -24,14 +24,14 @@ export abstract class BaseDocumentStore { // Main interface abstract docs(): Promise<Record<string, BaseNode>>; - abstract addDocuments(docs: BaseNode[], allowUpdate: boolean): void; + abstract addDocuments(docs: BaseNode[], allowUpdate: boolean): Promise<void>; abstract getDocument( docId: string, - raiseError: boolean + raiseError: boolean, ): Promise<BaseNode | undefined>; - abstract deleteDocument(docId: string, raiseError: boolean): void; + abstract deleteDocument(docId: string, raiseError: boolean): Promise<void>; abstract documentExists(docId: string): Promise<boolean>; @@ -50,7 +50,7 @@ export abstract class BaseDocumentStore { // Nodes getNodes(nodeIds: string[], raiseError: boolean = true): Promise<BaseNode[]> { return Promise.all( - nodeIds.map((nodeId) => this.getNode(nodeId, raiseError)) + nodeIds.map((nodeId) => this.getNode(nodeId, raiseError)), ); } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 993169bf2..d596d96c8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -17,7 +17,7 @@ importers: devDependencies: '@turbo/gen': specifier: ^1.10.12 - version: 1.10.12(@types/node@18.17.1)(typescript@4.9.5) + version: 1.10.12(@types/node@20.4.5)(typescript@4.9.5) '@types/jest': specifier: ^29.5.3 version: 29.5.3 @@ -32,13 +32,13 @@ importers: version: 8.0.3 jest: specifier: ^29.6.2 - version: 29.6.2(@types/node@18.17.1) + version: 29.6.2(@types/node@20.4.5) prettier: - specifier: ^2.8.8 - version: 2.8.8 - prettier-plugin-tailwindcss: - specifier: ^0.3.0 - version: 0.3.0(prettier@2.8.8) + specifier: ^3.0.1 + version: 3.0.1 + prettier-plugin-organize-imports: + specifier: ^3.2.3 + version: 3.2.3(prettier@3.0.1)(typescript@4.9.5) ts-jest: specifier: ^29.1.1 version: 29.1.1(@babel/core@7.22.9)(jest@29.6.2)(typescript@4.9.5) @@ -3652,7 +3652,7 @@ packages: resolution: {integrity: sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==} dev: true - /@turbo/gen@1.10.12(@types/node@18.17.1)(typescript@4.9.5): + /@turbo/gen@1.10.12(@types/node@20.4.5)(typescript@4.9.5): resolution: {integrity: sha512-noop5+3MBFsgPQ7O2vQpS6YYiah+ZrOioa4cDDpZceUVsKVXvUHFmC2nEVyKSJZhO/8SLvbDE/esB/MGw5b2tw==} hasBin: true dependencies: @@ -3664,7 +3664,7 @@ packages: node-plop: 0.26.3 proxy-agent: 6.3.0 semver: 7.5.4 - ts-node: 10.9.1(@types/node@18.17.1)(typescript@4.9.5) + ts-node: 10.9.1(@types/node@20.4.5)(typescript@4.9.5) update-check: 1.5.4 validate-npm-package-name: 5.0.0 transitivePeerDependencies: @@ -8632,7 +8632,7 @@ packages: - supports-color dev: true - /jest-cli@29.6.2(@types/node@18.17.1): + /jest-cli@29.6.2(@types/node@20.4.5): resolution: {integrity: sha512-TT6O247v6dCEX2UGHGyflMpxhnrL0DNqP2fRTKYm3nJJpCTfXX3GCMQPGFjXDoj0i5/Blp3jriKXFgdfmbYB6Q==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} hasBin: true @@ -8649,7 +8649,7 @@ packages: exit: 0.1.2 graceful-fs: 4.2.11 import-local: 3.1.0 - jest-config: 29.6.2(@types/node@18.17.1) + jest-config: 29.6.2(@types/node@20.4.5) jest-util: 29.6.2 jest-validate: 29.6.2 prompts: 2.4.2 @@ -8661,46 +8661,6 @@ packages: - ts-node dev: true - /jest-config@29.6.2(@types/node@18.17.1): - resolution: {integrity: sha512-VxwFOC8gkiJbuodG9CPtMRjBUNZEHxwfQXmIudSTzFWxaci3Qub1ddTRbFNQlD/zUeaifLndh/eDccFX4wCMQw==} - engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - peerDependencies: - '@types/node': '*' - ts-node: '>=9.0.0' - peerDependenciesMeta: - '@types/node': - optional: true - ts-node: - optional: true - dependencies: - '@babel/core': 7.22.9 - '@jest/test-sequencer': 29.6.2 - '@jest/types': 29.6.1 - '@types/node': 18.17.1 - babel-jest: 29.6.2(@babel/core@7.22.9) - chalk: 4.1.2 - ci-info: 3.8.0 - deepmerge: 4.3.1 - glob: 7.2.3 - graceful-fs: 4.2.11 - jest-circus: 29.6.2 - jest-environment-node: 29.6.2 - jest-get-type: 29.4.3 - jest-regex-util: 29.4.3 - jest-resolve: 29.6.2 - jest-runner: 29.6.2 - jest-util: 29.6.2 - jest-validate: 29.6.2 - micromatch: 4.0.5 - parse-json: 5.2.0 - pretty-format: 29.6.2 - slash: 3.0.0 - strip-json-comments: 3.1.1 - transitivePeerDependencies: - - babel-plugin-macros - - supports-color - dev: true - /jest-config@29.6.2(@types/node@20.4.5): resolution: {integrity: sha512-VxwFOC8gkiJbuodG9CPtMRjBUNZEHxwfQXmIudSTzFWxaci3Qub1ddTRbFNQlD/zUeaifLndh/eDccFX4wCMQw==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} @@ -9030,7 +8990,7 @@ packages: merge-stream: 2.0.0 supports-color: 8.1.1 - /jest@29.6.2(@types/node@18.17.1): + /jest@29.6.2(@types/node@20.4.5): resolution: {integrity: sha512-8eQg2mqFbaP7CwfsTpCxQ+sHzw1WuNWL5UUvjnWP4hx2riGz9fPSzYOaU5q8/GqWn1TfgZIVTqYJygbGbWAANg==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} hasBin: true @@ -9043,7 +9003,7 @@ packages: '@jest/core': 29.6.2 '@jest/types': 29.6.1 import-local: 3.1.0 - jest-cli: 29.6.2(@types/node@18.17.1) + jest-cli: 29.6.2(@types/node@20.4.5) transitivePeerDependencies: - '@types/node' - babel-plugin-macros @@ -10828,65 +10788,34 @@ packages: engines: {node: '>=4'} dev: false - /prettier-plugin-tailwindcss@0.3.0(prettier@2.8.8): - resolution: {integrity: sha512-009/Xqdy7UmkcTBpwlq7jsViDqXAYSOMLDrHAdTMlVZOrKfM2o9Ci7EMWTMZ7SkKBFTG04UM9F9iM2+4i6boDA==} - engines: {node: '>=12.17.0'} - peerDependencies: - '@ianvs/prettier-plugin-sort-imports': '*' - '@prettier/plugin-pug': '*' - '@shopify/prettier-plugin-liquid': '*' - '@shufo/prettier-plugin-blade': '*' - '@trivago/prettier-plugin-sort-imports': '*' - prettier: '>=2.2.0' - prettier-plugin-astro: '*' - prettier-plugin-css-order: '*' - prettier-plugin-import-sort: '*' - prettier-plugin-jsdoc: '*' - prettier-plugin-marko: '*' - prettier-plugin-organize-attributes: '*' - prettier-plugin-organize-imports: '*' - prettier-plugin-style-order: '*' - prettier-plugin-svelte: '*' - prettier-plugin-twig-melody: '*' + /prettier-plugin-organize-imports@3.2.3(prettier@3.0.1)(typescript@4.9.5): + resolution: {integrity: sha512-KFvk8C/zGyvUaE3RvxN2MhCLwzV6OBbFSkwZ2OamCrs9ZY4i5L77jQ/w4UmUr+lqX8qbaqVq6bZZkApn+IgJSg==} + peerDependencies: + '@volar/vue-language-plugin-pug': ^1.0.4 + '@volar/vue-typescript': ^1.0.4 + prettier: '>=2.0' + typescript: '>=2.9' peerDependenciesMeta: - '@ianvs/prettier-plugin-sort-imports': - optional: true - '@prettier/plugin-pug': - optional: true - '@shopify/prettier-plugin-liquid': - optional: true - '@shufo/prettier-plugin-blade': - optional: true - '@trivago/prettier-plugin-sort-imports': - optional: true - prettier-plugin-astro: - optional: true - prettier-plugin-css-order: - optional: true - prettier-plugin-import-sort: + '@volar/vue-language-plugin-pug': optional: true - prettier-plugin-jsdoc: - optional: true - prettier-plugin-marko: - optional: true - prettier-plugin-organize-attributes: - optional: true - prettier-plugin-organize-imports: - optional: true - prettier-plugin-style-order: - optional: true - prettier-plugin-svelte: - optional: true - prettier-plugin-twig-melody: + '@volar/vue-typescript': optional: true dependencies: - prettier: 2.8.8 + prettier: 3.0.1 + typescript: 4.9.5 dev: true /prettier@2.8.8: resolution: {integrity: sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==} engines: {node: '>=10.13.0'} hasBin: true + dev: false + + /prettier@3.0.1: + resolution: {integrity: sha512-fcOWSnnpCrovBsmFZIGIy9UqK2FaI7Hqax+DIO0A9UxeVoY4iweyaFjS5TavZN97Hfehph0nhsZnjlVKzEQSrQ==} + engines: {node: '>=14'} + hasBin: true + dev: true /pretty-error@4.0.0: resolution: {integrity: sha512-AoJ5YMAcXKYxKhuJGdcvse+Voc6v1RgnsR3nWcYU7q4t6z0Q6T86sv5Zq8VIRbOWWFpvdGE83LtdSMNd+6Y0xw==} @@ -12703,7 +12632,7 @@ packages: '@babel/core': 7.22.9 bs-logger: 0.2.6 fast-json-stable-stringify: 2.1.0 - jest: 29.6.2(@types/node@18.17.1) + jest: 29.6.2(@types/node@20.4.5) jest-util: 29.6.2 json5: 2.2.3 lodash.memoize: 4.1.2 @@ -12713,7 +12642,7 @@ packages: yargs-parser: 21.1.1 dev: true - /ts-node@10.9.1(@types/node@18.17.1)(typescript@4.9.5): + /ts-node@10.9.1(@types/node@20.4.5)(typescript@4.9.5): resolution: {integrity: sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==} hasBin: true peerDependencies: @@ -12732,7 +12661,7 @@ packages: '@tsconfig/node12': 1.0.11 '@tsconfig/node14': 1.0.3 '@tsconfig/node16': 1.0.4 - '@types/node': 18.17.1 + '@types/node': 20.4.5 acorn: 8.10.0 acorn-walk: 8.2.0 arg: 4.1.3 diff --git a/prettier.config.js b/prettier.config.js index f01cc7a68..1fe03c666 100644 --- a/prettier.config.js +++ b/prettier.config.js @@ -1,3 +1,3 @@ module.exports = { - plugins: [require("prettier-plugin-tailwindcss")], + plugins: ["prettier-plugin-organize-imports"], }; -- GitLab