Compare commits

..

7 Commits

81 changed files with 1567 additions and 2869 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"llamaindex": patch
---
Update storage exports (thanks @TomPenguin)
-5
View File
@@ -1,5 +0,0 @@
---
"llamaindex": patch
---
OpenAI v4 (final), Anthropic 0.6, Replicate 0.16.1
-5
View File
@@ -1,5 +0,0 @@
---
"llamaindex": patch
---
Breaking: Removed NodeWithEmbeddings (just use BaseNode)
+13 -13
View File
@@ -26,7 +26,7 @@ Anthropic LLM implementation
#### Defined in
[llm/LLM.ts:449](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L449)
[llm/LLM.ts:387](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L387)
## Properties
@@ -36,7 +36,7 @@ Anthropic LLM implementation
#### Defined in
[llm/LLM.ts:442](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L442)
[llm/LLM.ts:380](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L380)
___
@@ -46,7 +46,7 @@ ___
#### Defined in
[llm/LLM.ts:447](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L447)
[llm/LLM.ts:385](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L385)
___
@@ -56,7 +56,7 @@ ___
#### Defined in
[llm/LLM.ts:443](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L443)
[llm/LLM.ts:381](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L381)
___
@@ -66,7 +66,7 @@ ___
#### Defined in
[llm/LLM.ts:439](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L439)
[llm/LLM.ts:377](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L377)
___
@@ -76,7 +76,7 @@ ___
#### Defined in
[llm/LLM.ts:436](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L436)
[llm/LLM.ts:374](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L374)
___
@@ -86,7 +86,7 @@ ___
#### Defined in
[llm/LLM.ts:445](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L445)
[llm/LLM.ts:383](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L383)
___
@@ -96,7 +96,7 @@ ___
#### Defined in
[llm/LLM.ts:437](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L437)
[llm/LLM.ts:375](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L375)
___
@@ -106,7 +106,7 @@ ___
#### Defined in
[llm/LLM.ts:444](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L444)
[llm/LLM.ts:382](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L382)
___
@@ -116,7 +116,7 @@ ___
#### Defined in
[llm/LLM.ts:438](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L438)
[llm/LLM.ts:376](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L376)
## Methods
@@ -143,7 +143,7 @@ Get a chat response from the LLM
#### Defined in
[llm/LLM.ts:484](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L484)
[llm/LLM.ts:422](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L422)
___
@@ -170,7 +170,7 @@ Get a prompt completion from the LLM
#### Defined in
[llm/LLM.ts:502](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L502)
[llm/LLM.ts:440](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L440)
___
@@ -190,4 +190,4 @@ ___
#### Defined in
[llm/LLM.ts:469](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L469)
[llm/LLM.ts:407](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L407)
+9 -72
View File
@@ -43,7 +43,7 @@ they can be retrieved for our queries.
#### Defined in
[indices/BaseIndex.ts:130](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L130)
[indices/BaseIndex.ts:127](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L127)
## Properties
@@ -53,7 +53,7 @@ they can be retrieved for our queries.
#### Defined in
[indices/BaseIndex.ts:125](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L125)
[indices/BaseIndex.ts:122](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L122)
___
@@ -63,7 +63,7 @@ ___
#### Defined in
[indices/BaseIndex.ts:127](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L127)
[indices/BaseIndex.ts:124](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L124)
___
@@ -73,7 +73,7 @@ ___
#### Defined in
[indices/BaseIndex.ts:128](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L128)
[indices/BaseIndex.ts:125](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L125)
___
@@ -83,7 +83,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:120](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L120)
___
@@ -93,7 +93,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:121](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L121)
___
@@ -103,7 +103,7 @@ ___
#### Defined in
[indices/BaseIndex.ts:126](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L126)
[indices/BaseIndex.ts:123](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L123)
## Methods
@@ -128,7 +128,7 @@ and response synthezier if they are not provided.
#### Defined in
[indices/BaseIndex.ts:150](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L150)
[indices/BaseIndex.ts:147](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L147)
___
@@ -150,67 +150,4 @@ Create a new retriever from the index.
#### Defined in
[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)
[indices/BaseIndex.ts:140](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L140)
+34 -39
View File
@@ -28,7 +28,7 @@ Generic abstract class for retrievable nodes
#### Defined in
[Node.ts:55](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L55)
[Node.ts:48](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L48)
## Properties
@@ -38,7 +38,7 @@ Generic abstract class for retrievable nodes
#### Defined in
[Node.ts:46](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L46)
[Node.ts:39](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L39)
___
@@ -48,7 +48,7 @@ ___
#### Defined in
[Node.ts:50](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L50)
[Node.ts:43](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L43)
___
@@ -58,7 +58,7 @@ ___
#### Defined in
[Node.ts:51](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L51)
[Node.ts:44](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L44)
___
@@ -68,7 +68,7 @@ ___
#### Defined in
[Node.ts:53](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L53)
[Node.ts:46](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L46)
___
@@ -76,14 +76,9 @@ ___
**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:45](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L45)
[Node.ts:38](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L38)
___
@@ -93,7 +88,7 @@ ___
#### Defined in
[Node.ts:49](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L49)
[Node.ts:42](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L42)
___
@@ -103,7 +98,7 @@ ___
#### Defined in
[Node.ts:52](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L52)
[Node.ts:45](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L45)
## Accessors
@@ -117,7 +112,7 @@ ___
#### Defined in
[Node.ts:107](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L107)
[Node.ts:104](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L104)
___
@@ -131,7 +126,21 @@ ___
#### Defined in
[Node.ts:87](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L87)
[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)
___
@@ -145,7 +154,7 @@ ___
#### Defined in
[Node.ts:97](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L97)
[Node.ts:94](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L94)
___
@@ -159,7 +168,7 @@ ___
#### Defined in
[Node.ts:75](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L75)
[Node.ts:72](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L72)
___
@@ -173,7 +182,7 @@ ___
#### Defined in
[Node.ts:65](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L65)
[Node.ts:62](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L62)
## Methods
@@ -187,21 +196,7 @@ ___
#### Defined in
[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)
[Node.ts:124](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L124)
___
@@ -221,7 +216,7 @@ ___
#### Defined in
[Node.ts:61](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L61)
[Node.ts:54](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L54)
___
@@ -235,7 +230,7 @@ ___
#### Defined in
[Node.ts:121](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L121)
[Node.ts:116](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L116)
___
@@ -255,7 +250,7 @@ ___
#### Defined in
[Node.ts:62](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L62)
[Node.ts:55](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L55)
___
@@ -269,7 +264,7 @@ ___
#### Defined in
[Node.ts:59](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L59)
[Node.ts:52](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L52)
___
@@ -289,7 +284,7 @@ ___
#### Defined in
[Node.ts:63](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L63)
[Node.ts:56](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L56)
___
@@ -305,4 +300,4 @@ Used with built in JSON.stringify
#### Defined in
[Node.ts:141](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L141)
[Node.ts:136](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L136)
+61 -37
View File
@@ -32,7 +32,7 @@ A document is just a special text node with a docId.
#### Defined in
[Node.ts:257](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L257)
[Node.ts:229](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L229)
## Properties
@@ -46,7 +46,7 @@ A document is just a special text node with a docId.
#### Defined in
[Node.ts:46](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L46)
[Node.ts:39](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L39)
___
@@ -60,7 +60,7 @@ ___
#### Defined in
[Node.ts:152](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L152)
[Node.ts:147](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L147)
___
@@ -74,7 +74,7 @@ ___
#### Defined in
[Node.ts:50](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L50)
[Node.ts:43](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L43)
___
@@ -88,7 +88,7 @@ ___
#### Defined in
[Node.ts:51](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L51)
[Node.ts:44](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L44)
___
@@ -102,7 +102,7 @@ ___
#### Defined in
[Node.ts:53](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L53)
[Node.ts:46](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L46)
___
@@ -110,18 +110,13 @@ ___
**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:45](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L45)
[Node.ts:38](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L38)
___
@@ -135,7 +130,7 @@ ___
#### Defined in
[Node.ts:49](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L49)
[Node.ts:42](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L42)
___
@@ -149,7 +144,7 @@ ___
#### Defined in
[Node.ts:155](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L155)
[Node.ts:150](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L150)
___
@@ -163,7 +158,7 @@ ___
#### Defined in
[Node.ts:52](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L52)
[Node.ts:45](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L45)
___
@@ -177,7 +172,7 @@ ___
#### Defined in
[Node.ts:151](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L151)
[Node.ts:146](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L146)
___
@@ -191,7 +186,7 @@ ___
#### Defined in
[Node.ts:150](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L150)
[Node.ts:145](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L145)
## Accessors
@@ -209,7 +204,21 @@ TextNode.childNodes
#### Defined in
[Node.ts:107](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L107)
[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)
___
@@ -227,7 +236,25 @@ TextNode.nextNode
#### Defined in
[Node.ts:87](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L87)
[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)
___
@@ -245,7 +272,7 @@ TextNode.parentNode
#### Defined in
[Node.ts:97](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L97)
[Node.ts:94](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L94)
___
@@ -263,7 +290,7 @@ TextNode.prevNode
#### Defined in
[Node.ts:75](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L75)
[Node.ts:72](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L72)
___
@@ -281,7 +308,7 @@ TextNode.sourceNode
#### Defined in
[Node.ts:65](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L65)
[Node.ts:62](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L62)
## Methods
@@ -299,20 +326,17 @@ TextNode.sourceNode
#### Defined in
[Node.ts:129](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L129)
[Node.ts:124](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L124)
___
### generateHash
**generateHash**(): `string`
Generate a hash of the text node.
The ID is not part of the hash as it can change independent of content.
**generateHash**(): `void`
#### Returns
`string`
`void`
#### Inherited from
@@ -320,7 +344,7 @@ The ID is not part of the hash as it can change independent of content.
#### Defined in
[Node.ts:173](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L173)
[Node.ts:157](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L157)
___
@@ -344,7 +368,7 @@ ___
#### Defined in
[Node.ts:187](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L187)
[Node.ts:165](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L165)
___
@@ -362,7 +386,7 @@ ___
#### Defined in
[Node.ts:121](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L121)
[Node.ts:116](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L116)
___
@@ -386,7 +410,7 @@ ___
#### Defined in
[Node.ts:192](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L192)
[Node.ts:170](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L170)
___
@@ -409,7 +433,7 @@ ___
#### Defined in
[Node.ts:219](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L219)
[Node.ts:195](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L195)
___
@@ -427,7 +451,7 @@ ___
#### Defined in
[Node.ts:223](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L223)
[Node.ts:199](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L199)
___
@@ -445,7 +469,7 @@ ___
#### Defined in
[Node.ts:266](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L266)
[Node.ts:234](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L234)
___
@@ -469,7 +493,7 @@ ___
#### Defined in
[Node.ts:213](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L213)
[Node.ts:191](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L191)
___
@@ -489,4 +513,4 @@ Used with built in JSON.stringify
#### Defined in
[Node.ts:141](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L141)
[Node.ts:136](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L136)
+14 -24
View File
@@ -37,6 +37,16 @@ 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`
@@ -81,7 +91,7 @@ ___
#### Defined in
[indices/BaseIndex.ts:46](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L46)
[indices/BaseIndex.ts:47](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L47)
## Methods
@@ -102,27 +112,7 @@ ___
#### Defined in
[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)
[indices/BaseIndex.ts:56](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L56)
___
@@ -140,7 +130,7 @@ ___
#### Defined in
[indices/BaseIndex.ts:48](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L48)
[indices/BaseIndex.ts:49](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L49)
___
@@ -158,4 +148,4 @@ ___
#### Defined in
[indices/BaseIndex.ts:60](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L60)
[indices/BaseIndex.ts:61](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L61)
+4 -4
View File
@@ -57,7 +57,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:90](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L90)
___
@@ -81,7 +81,7 @@ ___
#### Defined in
[indices/BaseIndex.ts:94](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L94)
[indices/BaseIndex.ts:91](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L91)
## Methods
@@ -101,7 +101,7 @@ ___
#### Defined in
[indices/BaseIndex.ts:96](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L96)
[indices/BaseIndex.ts:93](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L93)
___
@@ -137,4 +137,4 @@ ___
#### Defined in
[indices/BaseIndex.ts:100](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L100)
[indices/BaseIndex.ts:97](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L97)
+48 -38
View File
@@ -32,7 +32,7 @@ TextNode is the default node type for text. Most common node type in LlamaIndex.
#### Defined in
[Node.ts:239](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L239)
[Node.ts:215](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L215)
## Properties
@@ -46,7 +46,7 @@ TextNode is the default node type for text. Most common node type in LlamaIndex.
#### Defined in
[Node.ts:46](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L46)
[Node.ts:39](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L39)
___
@@ -60,7 +60,7 @@ ___
#### Defined in
[Node.ts:152](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L152)
[Node.ts:147](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L147)
___
@@ -74,7 +74,7 @@ ___
#### Defined in
[Node.ts:50](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L50)
[Node.ts:43](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L43)
___
@@ -88,7 +88,7 @@ ___
#### Defined in
[Node.ts:51](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L51)
[Node.ts:44](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L44)
___
@@ -102,7 +102,7 @@ ___
#### Defined in
[Node.ts:53](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L53)
[Node.ts:46](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L46)
___
@@ -110,18 +110,13 @@ ___
**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:45](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L45)
[Node.ts:38](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L38)
___
@@ -131,7 +126,7 @@ ___
#### Defined in
[Node.ts:237](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L237)
[Node.ts:213](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L213)
___
@@ -145,7 +140,7 @@ ___
#### Defined in
[Node.ts:49](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L49)
[Node.ts:42](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L42)
___
@@ -159,7 +154,7 @@ ___
#### Defined in
[Node.ts:155](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L155)
[Node.ts:150](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L150)
___
@@ -173,7 +168,7 @@ ___
#### Defined in
[Node.ts:52](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L52)
[Node.ts:45](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L45)
___
@@ -187,7 +182,7 @@ ___
#### Defined in
[Node.ts:151](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L151)
[Node.ts:146](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L146)
___
@@ -201,7 +196,7 @@ ___
#### Defined in
[Node.ts:150](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L150)
[Node.ts:145](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L145)
## Accessors
@@ -219,7 +214,7 @@ TextNode.childNodes
#### Defined in
[Node.ts:107](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L107)
[Node.ts:104](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L104)
___
@@ -237,7 +232,25 @@ TextNode.nextNode
#### Defined in
[Node.ts:87](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L87)
[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)
___
@@ -255,7 +268,7 @@ TextNode.parentNode
#### Defined in
[Node.ts:97](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L97)
[Node.ts:94](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L94)
___
@@ -273,7 +286,7 @@ TextNode.prevNode
#### Defined in
[Node.ts:75](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L75)
[Node.ts:72](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L72)
___
@@ -291,7 +304,7 @@ TextNode.sourceNode
#### Defined in
[Node.ts:65](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L65)
[Node.ts:62](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L62)
## Methods
@@ -309,20 +322,17 @@ TextNode.sourceNode
#### Defined in
[Node.ts:129](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L129)
[Node.ts:124](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L124)
___
### generateHash
**generateHash**(): `string`
Generate a hash of the text node.
The ID is not part of the hash as it can change independent of content.
**generateHash**(): `void`
#### Returns
`string`
`void`
#### Inherited from
@@ -330,7 +340,7 @@ The ID is not part of the hash as it can change independent of content.
#### Defined in
[Node.ts:173](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L173)
[Node.ts:157](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L157)
___
@@ -354,7 +364,7 @@ ___
#### Defined in
[Node.ts:187](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L187)
[Node.ts:165](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L165)
___
@@ -372,7 +382,7 @@ ___
#### Defined in
[Node.ts:121](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L121)
[Node.ts:116](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L116)
___
@@ -396,7 +406,7 @@ ___
#### Defined in
[Node.ts:192](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L192)
[Node.ts:170](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L170)
___
@@ -419,7 +429,7 @@ ___
#### Defined in
[Node.ts:219](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L219)
[Node.ts:195](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L195)
___
@@ -437,7 +447,7 @@ ___
#### Defined in
[Node.ts:223](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L223)
[Node.ts:199](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L199)
___
@@ -455,7 +465,7 @@ ___
#### Defined in
[Node.ts:248](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L248)
[Node.ts:220](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L220)
___
@@ -479,7 +489,7 @@ ___
#### Defined in
[Node.ts:213](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L213)
[Node.ts:191](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L191)
___
@@ -499,4 +509,4 @@ Used with built in JSON.stringify
#### Defined in
[Node.ts:141](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L141)
[Node.ts:136](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L136)
+55 -111
View File
@@ -32,7 +32,7 @@ A ListIndex keeps nodes in a sequential list structure
#### 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:43](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L43)
## Properties
@@ -46,7 +46,7 @@ A ListIndex keeps nodes in a sequential list structure
#### Defined in
[indices/BaseIndex.ts:125](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L125)
[indices/BaseIndex.ts:122](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L122)
___
@@ -60,7 +60,7 @@ ___
#### Defined in
[indices/BaseIndex.ts:127](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L127)
[indices/BaseIndex.ts:124](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L124)
___
@@ -74,7 +74,7 @@ ___
#### Defined in
[indices/BaseIndex.ts:128](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L128)
[indices/BaseIndex.ts:125](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L125)
___
@@ -88,7 +88,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:120](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L120)
___
@@ -102,7 +102,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:121](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L121)
___
@@ -116,10 +116,50 @@ ___
#### Defined in
[indices/BaseIndex.ts:126](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L126)
[indices/BaseIndex.ts:123](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L123)
## Methods
### \_deleteNode
`Protected` **_deleteNode**(`nodeId`): `void`
#### Parameters
| Name | Type |
| :------ | :------ |
| `nodeId` | `string` |
#### Returns
`void`
#### Defined in
[indices/list/ListIndex.ts:193](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L193)
___
### \_insert
`Protected` **_insert**(`nodes`): `void`
#### Parameters
| Name | Type |
| :------ | :------ |
| `nodes` | [`BaseNode`](BaseNode.md)[] |
#### Returns
`void`
#### Defined in
[indices/list/ListIndex.ts:187](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L187)
___
### asQueryEngine
**asQueryEngine**(`options?`): [`BaseQueryEngine`](../interfaces/BaseQueryEngine.md)
@@ -145,7 +185,7 @@ and response synthezier if they are not provided.
#### Defined in
[indices/list/ListIndex.ts:155](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L155)
[indices/list/ListIndex.ts:151](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L151)
___
@@ -172,53 +212,7 @@ Create a new retriever from the index.
#### Defined in
[indices/list/ListIndex.ts:142](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L142)
___
### deleteNodes
**deleteNodes**(`nodeIds`, `deleteFromDocStore`): `Promise`<`void`\>
#### Parameters
| Name | Type |
| :------ | :------ |
| `nodeIds` | `string`[] |
| `deleteFromDocStore` | `boolean` |
#### Returns
`Promise`<`void`\>
#### Defined in
[indices/list/ListIndex.ts:216](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L216)
___
### deleteRefDoc
**deleteRefDoc**(`refDocId`, `deleteFromDocStore?`): `Promise`<`void`\>
#### Parameters
| Name | Type |
| :------ | :------ |
| `refDocId` | `string` |
| `deleteFromDocStore?` | `boolean` |
#### Returns
`Promise`<`void`\>
#### Overrides
[BaseIndex](BaseIndex.md).[deleteRefDoc](BaseIndex.md#deleterefdoc)
#### Defined in
[indices/list/ListIndex.ts:197](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L197)
[indices/list/ListIndex.ts:138](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L138)
___
@@ -232,63 +226,13 @@ ___
#### Defined in
[indices/list/ListIndex.ts:230](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L230)
[indices/list/ListIndex.ts:199](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L199)
___
### insert
### \_buildIndexFromNodes
**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/list/ListIndex.ts:191](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L191)
___
### buildIndexFromNodes
`Static` **buildIndexFromNodes**(`nodes`, `docStore`, `indexStruct?`): `Promise`<[`IndexList`](IndexList.md)\>
`Static` **_buildIndexFromNodes**(`nodes`, `docStore`, `indexStruct?`): `Promise`<[`IndexList`](IndexList.md)\>
#### Parameters
@@ -304,7 +248,7 @@ ___
#### Defined in
[indices/list/ListIndex.ts:176](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L176)
[indices/list/ListIndex.ts:172](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L172)
___
@@ -327,7 +271,7 @@ ___
#### Defined in
[indices/list/ListIndex.ts:116](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L116)
[indices/list/ListIndex.ts:112](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L112)
___
@@ -347,4 +291,4 @@ ___
#### Defined in
[indices/list/ListIndex.ts:51](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L51)
[indices/list/ListIndex.ts:47](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L47)
+24 -41
View File
@@ -26,7 +26,7 @@ Llama2 LLM implementation
#### Defined in
[llm/LLM.ts:266](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L266)
[llm/LLM.ts:242](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L242)
## Properties
@@ -36,7 +36,7 @@ Llama2 LLM implementation
#### Defined in
[llm/LLM.ts:260](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L260)
[llm/LLM.ts:236](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L236)
___
@@ -46,17 +46,17 @@ ___
#### Defined in
[llm/LLM.ts:263](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L263)
[llm/LLM.ts:239](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L239)
___
### model
**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"``
**model**: ``"Llama-2-70b-chat"`` \| ``"Llama-2-13b-chat"`` \| ``"Llama-2-7b-chat"``
#### Defined in
[llm/LLM.ts:259](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L259)
[llm/LLM.ts:235](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L235)
___
@@ -66,7 +66,7 @@ ___
#### Defined in
[llm/LLM.ts:264](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L264)
[llm/LLM.ts:240](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L240)
___
@@ -76,7 +76,7 @@ ___
#### Defined in
[llm/LLM.ts:261](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L261)
[llm/LLM.ts:237](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L237)
___
@@ -86,7 +86,7 @@ ___
#### Defined in
[llm/LLM.ts:262](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L262)
[llm/LLM.ts:238](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L238)
## Methods
@@ -113,7 +113,7 @@ Get a chat response from the LLM
#### Defined in
[llm/LLM.ts:385](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L385)
[llm/LLM.ts:333](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L333)
___
@@ -140,7 +140,7 @@ Get a prompt completion 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:360](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L360)
___
@@ -160,13 +160,13 @@ ___
#### Defined in
[llm/LLM.ts:309](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L309)
[llm/LLM.ts:274](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L274)
___
### mapMessagesToPrompt
▸ **mapMessagesToPrompt**(`messages`): `Object`
▸ **mapMessagesToPrompt**(`messages`): `string`
#### Parameters
@@ -176,22 +176,17 @@ ___
#### Returns
`Object`
| Name | Type |
| :------ | :------ |
| `prompt` | `string` |
| `systemPrompt` | `undefined` \| `string` |
`string`
#### Defined in
[llm/LLM.ts:281](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L281)
[llm/LLM.ts:251](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L251)
___
### mapMessagesToPromptA16Z
▸ **mapMessagesToPromptA16Z**(`messages`): `Object`
▸ **mapMessagesToPromptA16Z**(`messages`): `string`
#### Parameters
@@ -201,41 +196,29 @@ ___
#### Returns
`Object`
| Name | Type |
| :------ | :------ |
| `prompt` | `string` |
| `systemPrompt` | `undefined` |
`string`
#### Defined in
[llm/LLM.ts:295](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L295)
[llm/LLM.ts:263](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L263)
___
### mapMessagesToPromptMeta
▸ **mapMessagesToPromptMeta**(`messages`, `opts?`): `Object`
▸ **mapMessagesToPromptMeta**(`messages`, `withBos?`): `string`
#### Parameters
| Name | Type |
| :------ | :------ |
| `messages` | [`ChatMessage`](../interfaces/ChatMessage.md)[] |
| `opts?` | `Object` |
| `opts.replicate4Bit?` | `boolean` |
| `opts.withBos?` | `boolean` |
| Name | Type | Default value |
| :------ | :------ | :------ |
| `messages` | [`ChatMessage`](../interfaces/ChatMessage.md)[] | `undefined` |
| `withBos` | `boolean` | `false` |
#### Returns
`Object`
| Name | Type |
| :------ | :------ |
| `prompt` | `string` |
| `systemPrompt` | `undefined` \| `string` |
`string`
#### Defined in
[llm/LLM.ts:322](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L322)
[llm/LLM.ts:287](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L287)
@@ -1,480 +0,0 @@
---
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)
@@ -1,234 +0,0 @@
---
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)
@@ -1,283 +0,0 @@
---
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` | [`BaseNode`](BaseNode.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:77](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/SimpleVectorStore.ts#L77)
___
### 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:146](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/SimpleVectorStore.ts#L146)
___
### 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:88](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/SimpleVectorStore.ts#L88)
___
### toDict
**toDict**(): `SimpleVectorStoreData`
#### Returns
`SimpleVectorStoreData`
#### Defined in
[storage/vectorStore/SimpleVectorStore.ts:196](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/SimpleVectorStore.ts#L196)
___
### fromDict
`Static` **fromDict**(`saveDict`): [`SimpleVectorStore`](SimpleVectorStore.md)
#### Parameters
| Name | Type |
| :------ | :------ |
| `saveDict` | `SimpleVectorStoreData` |
#### Returns
[`SimpleVectorStore`](SimpleVectorStore.md)
#### Defined in
[storage/vectorStore/SimpleVectorStore.ts:189](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/SimpleVectorStore.ts#L189)
___
### 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:159](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/SimpleVectorStore.ts#L159)
+47 -41
View File
@@ -36,7 +36,7 @@ TextNode is the default node type for text. Most common node type in LlamaIndex.
#### Defined in
[Node.ts:157](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L157)
[Node.ts:152](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L152)
## Properties
@@ -50,7 +50,7 @@ TextNode is the default node type for text. Most common node type in LlamaIndex.
#### Defined in
[Node.ts:46](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L46)
[Node.ts:39](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L39)
___
@@ -60,7 +60,7 @@ ___
#### Defined in
[Node.ts:152](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L152)
[Node.ts:147](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L147)
___
@@ -74,7 +74,7 @@ ___
#### Defined in
[Node.ts:50](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L50)
[Node.ts:43](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L43)
___
@@ -88,7 +88,7 @@ ___
#### Defined in
[Node.ts:51](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L51)
[Node.ts:44](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L44)
___
@@ -102,7 +102,7 @@ ___
#### Defined in
[Node.ts:53](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L53)
[Node.ts:46](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L46)
___
@@ -110,18 +110,13 @@ ___
**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:45](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L45)
[Node.ts:38](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L38)
___
@@ -135,7 +130,7 @@ ___
#### Defined in
[Node.ts:49](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L49)
[Node.ts:42](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L42)
___
@@ -145,7 +140,7 @@ ___
#### Defined in
[Node.ts:155](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L155)
[Node.ts:150](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L150)
___
@@ -159,7 +154,7 @@ ___
#### Defined in
[Node.ts:52](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L52)
[Node.ts:45](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L45)
___
@@ -169,7 +164,7 @@ ___
#### Defined in
[Node.ts:151](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L151)
[Node.ts:146](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L146)
___
@@ -179,7 +174,7 @@ ___
#### Defined in
[Node.ts:150](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L150)
[Node.ts:145](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L145)
## Accessors
@@ -197,7 +192,7 @@ BaseNode.childNodes
#### Defined in
[Node.ts:107](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L107)
[Node.ts:104](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L104)
___
@@ -215,7 +210,25 @@ BaseNode.nextNode
#### Defined in
[Node.ts:87](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L87)
[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)
___
@@ -233,7 +246,7 @@ BaseNode.parentNode
#### Defined in
[Node.ts:97](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L97)
[Node.ts:94](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L94)
___
@@ -251,7 +264,7 @@ BaseNode.prevNode
#### Defined in
[Node.ts:75](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L75)
[Node.ts:72](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L72)
___
@@ -269,7 +282,7 @@ BaseNode.sourceNode
#### Defined in
[Node.ts:65](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L65)
[Node.ts:62](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L62)
## Methods
@@ -287,28 +300,21 @@ BaseNode.sourceNode
#### Defined in
[Node.ts:129](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L129)
[Node.ts:124](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L124)
___
### generateHash
**generateHash**(): `string`
Generate a hash of the text node.
The ID is not part of the hash as it can change independent of content.
**generateHash**(): `void`
#### Returns
`string`
#### Overrides
[BaseNode](BaseNode.md).[generateHash](BaseNode.md#generatehash)
`void`
#### Defined in
[Node.ts:173](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L173)
[Node.ts:157](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L157)
___
@@ -332,7 +338,7 @@ ___
#### Defined in
[Node.ts:187](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L187)
[Node.ts:165](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L165)
___
@@ -350,7 +356,7 @@ ___
#### Defined in
[Node.ts:121](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L121)
[Node.ts:116](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L116)
___
@@ -374,7 +380,7 @@ ___
#### Defined in
[Node.ts:192](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L192)
[Node.ts:170](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L170)
___
@@ -393,7 +399,7 @@ ___
#### Defined in
[Node.ts:219](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L219)
[Node.ts:195](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L195)
___
@@ -407,7 +413,7 @@ ___
#### Defined in
[Node.ts:223](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L223)
[Node.ts:199](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L199)
___
@@ -425,7 +431,7 @@ ___
#### Defined in
[Node.ts:183](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L183)
[Node.ts:161](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L161)
___
@@ -449,7 +455,7 @@ ___
#### Defined in
[Node.ts:213](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L213)
[Node.ts:191](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L191)
___
@@ -469,4 +475,4 @@ Used with built in JSON.stringify
#### Defined in
[Node.ts:141](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L141)
[Node.ts:136](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L136)
+16 -92
View File
@@ -32,7 +32,7 @@ The VectorStoreIndex, an index that stores the nodes only according to their vec
#### Defined in
[indices/vectorStore/VectorStoreIndex.ts:31](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/vectorStore/VectorStoreIndex.ts#L31)
[indices/vectorStore/VectorStoreIndex.ts:36](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/vectorStore/VectorStoreIndex.ts#L36)
## Properties
@@ -46,7 +46,7 @@ The VectorStoreIndex, an index that stores the nodes only according to their vec
#### Defined in
[indices/BaseIndex.ts:125](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L125)
[indices/BaseIndex.ts:122](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L122)
___
@@ -60,7 +60,7 @@ ___
#### Defined in
[indices/BaseIndex.ts:127](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L127)
[indices/BaseIndex.ts:124](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L124)
___
@@ -74,7 +74,7 @@ ___
#### Defined in
[indices/BaseIndex.ts:128](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L128)
[indices/BaseIndex.ts:125](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L125)
___
@@ -88,7 +88,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:120](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L120)
___
@@ -102,7 +102,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:121](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L121)
___
@@ -116,7 +116,7 @@ ___
#### Defined in
[indices/vectorStore/VectorStoreIndex.ts:29](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/vectorStore/VectorStoreIndex.ts#L29)
[indices/vectorStore/VectorStoreIndex.ts:34](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/vectorStore/VectorStoreIndex.ts#L34)
## Methods
@@ -145,7 +145,7 @@ and response synthezier if they are not provided.
#### Defined in
[indices/vectorStore/VectorStoreIndex.ts:216](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/vectorStore/VectorStoreIndex.ts#L216)
[indices/vectorStore/VectorStoreIndex.ts:215](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/vectorStore/VectorStoreIndex.ts#L215)
___
@@ -171,88 +171,13 @@ Create a new retriever from the index.
#### Defined in
[indices/vectorStore/VectorStoreIndex.ts:212](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/vectorStore/VectorStoreIndex.ts#L212)
___
### 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:252](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/vectorStore/VectorStoreIndex.ts#L252)
___
### 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:227](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/vectorStore/VectorStoreIndex.ts#L227)
[indices/vectorStore/VectorStoreIndex.ts:211](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/vectorStore/VectorStoreIndex.ts#L211)
___
### buildIndexFromNodes
`Static` **buildIndexFromNodes**(`nodes`, `serviceContext`, `vectorStore`, `docStore`, `indexDict?`): `Promise`<[`IndexDict`](IndexDict.md)\>
`Static` **buildIndexFromNodes**(`nodes`, `serviceContext`, `vectorStore`, `docStore`): `Promise`<[`IndexDict`](IndexDict.md)\>
Get embeddings for nodes and place them into the index.
@@ -264,7 +189,6 @@ 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
@@ -272,7 +196,7 @@ Get embeddings for nodes and place them into the index.
#### Defined in
[indices/vectorStore/VectorStoreIndex.ts:143](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/vectorStore/VectorStoreIndex.ts#L143)
[indices/vectorStore/VectorStoreIndex.ts:151](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/vectorStore/VectorStoreIndex.ts#L151)
___
@@ -297,13 +221,13 @@ High level API: split documents, get embeddings, and build index.
#### Defined in
[indices/vectorStore/VectorStoreIndex.ts:187](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/vectorStore/VectorStoreIndex.ts#L187)
[indices/vectorStore/VectorStoreIndex.ts:186](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/vectorStore/VectorStoreIndex.ts#L186)
___
### getNodeEmbeddingResults
`Static` **getNodeEmbeddingResults**(`nodes`, `serviceContext`, `logProgress?`): `Promise`<[`BaseNode`](BaseNode.md)[]\>
`Static` **getNodeEmbeddingResults**(`nodes`, `serviceContext`, `logProgress?`): `Promise`<[`NodeWithEmbedding`](../interfaces/NodeWithEmbedding.md)[]\>
Get the embeddings for nodes.
@@ -317,11 +241,11 @@ Get the embeddings for nodes.
#### Returns
`Promise`<[`BaseNode`](BaseNode.md)[]\>
`Promise`<[`NodeWithEmbedding`](../interfaces/NodeWithEmbedding.md)[]\>
#### Defined in
[indices/vectorStore/VectorStoreIndex.ts:114](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/vectorStore/VectorStoreIndex.ts#L114)
[indices/vectorStore/VectorStoreIndex.ts:123](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/vectorStore/VectorStoreIndex.ts#L123)
___
@@ -344,4 +268,4 @@ This is needed to handle persistence.
#### Defined in
[indices/vectorStore/VectorStoreIndex.ts:42](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/vectorStore/VectorStoreIndex.ts#L42)
[indices/vectorStore/VectorStoreIndex.ts:47](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/vectorStore/VectorStoreIndex.ts#L47)
+3 -13
View File
@@ -14,7 +14,7 @@ custom_edit_url: null
#### Defined in
[llm/LLM.ts:246](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L246)
[llm/LLM.ts:224](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L224)
___
@@ -24,7 +24,7 @@ ___
#### Defined in
[llm/LLM.ts:247](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L247)
[llm/LLM.ts:225](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L225)
___
@@ -34,14 +34,4 @@ ___
#### Defined in
[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)
[llm/LLM.ts:226](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L226)
@@ -14,7 +14,7 @@ custom_edit_url: null
#### Defined in
[indices/list/ListIndex.ts:30](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L30)
[indices/list/ListIndex.ts:26](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L26)
___
@@ -24,4 +24,4 @@ ___
#### Defined in
[indices/list/ListIndex.ts:32](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L32)
[indices/list/ListIndex.ts:28](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/list/ListIndex.ts#L28)
+4 -4
View File
@@ -14,7 +14,7 @@ custom_edit_url: null
#### Defined in
[Node.ts:20](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L20)
[Node.ts:19](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L19)
___
@@ -24,7 +24,7 @@ ___
#### Defined in
[Node.ts:21](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L21)
[Node.ts:20](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L20)
___
@@ -34,7 +34,7 @@ ___
#### Defined in
[Node.ts:22](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L22)
[Node.ts:21](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L21)
___
@@ -44,4 +44,4 @@ ___
#### Defined in
[Node.ts:23](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L23)
[Node.ts:22](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L22)
+5 -5
View File
@@ -14,7 +14,7 @@ custom_edit_url: null
#### Defined in
[Node.ts:9](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L9)
[Node.ts:8](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L8)
___
@@ -24,7 +24,7 @@ ___
#### Defined in
[Node.ts:7](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L7)
[Node.ts:6](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L6)
___
@@ -34,7 +34,7 @@ ___
#### Defined in
[Node.ts:8](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L8)
[Node.ts:7](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L7)
___
@@ -44,7 +44,7 @@ ___
#### Defined in
[Node.ts:6](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L6)
[Node.ts:5](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L5)
___
@@ -54,4 +54,4 @@ ___
#### Defined in
[Node.ts:5](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L5)
[Node.ts:4](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L4)
+4 -4
View File
@@ -14,7 +14,7 @@ custom_edit_url: null
#### Defined in
[Node.ts:16](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L16)
[Node.ts:15](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L15)
___
@@ -24,7 +24,7 @@ ___
#### Defined in
[Node.ts:14](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L14)
[Node.ts:13](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L13)
___
@@ -34,7 +34,7 @@ ___
#### Defined in
[Node.ts:15](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L15)
[Node.ts:14](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L14)
___
@@ -44,4 +44,4 @@ ___
#### Defined in
[Node.ts:13](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L13)
[Node.ts:12](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L12)
@@ -14,7 +14,7 @@ custom_edit_url: null
#### Defined in
[storage/vectorStore/types.ts:11](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L11)
[storage/vectorStore/types.ts:12](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L12)
___
@@ -24,7 +24,7 @@ ___
#### Defined in
[storage/vectorStore/types.ts:13](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L13)
[storage/vectorStore/types.ts:14](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L14)
___
@@ -34,7 +34,7 @@ ___
#### Defined in
[storage/vectorStore/types.ts:17](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L17)
[storage/vectorStore/types.ts:18](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L18)
___
@@ -44,7 +44,7 @@ ___
#### Defined in
[storage/vectorStore/types.ts:16](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L16)
[storage/vectorStore/types.ts:17](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L17)
___
@@ -54,7 +54,7 @@ ___
#### Defined in
[storage/vectorStore/types.ts:19](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L19)
[storage/vectorStore/types.ts:20](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L20)
___
@@ -64,7 +64,7 @@ ___
#### Defined in
[storage/vectorStore/types.ts:12](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L12)
[storage/vectorStore/types.ts:13](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L13)
___
@@ -74,4 +74,4 @@ ___
#### Defined in
[storage/vectorStore/types.ts:15](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L15)
[storage/vectorStore/types.ts:16](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L16)
@@ -26,7 +26,7 @@ custom_edit_url: null
#### Defined in
[indices/BaseIndex.ts:112](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L112)
[indices/BaseIndex.ts:109](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L109)
___
@@ -36,7 +36,7 @@ ___
#### Defined in
[indices/BaseIndex.ts:114](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L114)
[indices/BaseIndex.ts:111](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L111)
___
@@ -46,7 +46,7 @@ ___
#### Defined in
[indices/BaseIndex.ts:115](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L115)
[indices/BaseIndex.ts:112](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L112)
___
@@ -56,7 +56,7 @@ ___
#### Defined in
[indices/BaseIndex.ts:110](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L110)
[indices/BaseIndex.ts:107](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L107)
___
@@ -66,7 +66,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:108](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L108)
___
@@ -76,4 +76,4 @@ ___
#### Defined in
[indices/BaseIndex.ts:113](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L113)
[indices/BaseIndex.ts:110](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L110)
@@ -14,7 +14,7 @@ custom_edit_url: null
#### Defined in
[storage/vectorStore/types.ts:23](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L23)
[storage/vectorStore/types.ts:24](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L24)
___
@@ -24,7 +24,7 @@ ___
#### Defined in
[storage/vectorStore/types.ts:24](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L24)
[storage/vectorStore/types.ts:25](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L25)
___
@@ -34,4 +34,4 @@ ___
#### Defined in
[storage/vectorStore/types.ts:25](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L25)
[storage/vectorStore/types.ts:26](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L26)
@@ -14,4 +14,4 @@ custom_edit_url: null
#### Defined in
[storage/vectorStore/types.ts:29](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L29)
[storage/vectorStore/types.ts:30](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L30)
@@ -14,7 +14,7 @@ custom_edit_url: null
#### Defined in
[storage/vectorStore/types.ts:41](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L41)
[storage/vectorStore/types.ts:42](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L42)
___
@@ -24,7 +24,7 @@ ___
#### Defined in
[storage/vectorStore/types.ts:39](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L39)
[storage/vectorStore/types.ts:40](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L40)
___
@@ -34,4 +34,4 @@ ___
#### Defined in
[storage/vectorStore/types.ts:40](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L40)
[storage/vectorStore/types.ts:41](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L41)
@@ -0,0 +1,29 @@
---
id: "NodeWithEmbedding"
title: "Interface: NodeWithEmbedding"
sidebar_label: "NodeWithEmbedding"
sidebar_position: 0
custom_edit_url: null
---
A node with an embedding
## Properties
### embedding
**embedding**: `number`[]
#### Defined in
[Node.ts:277](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L277)
___
### node
**node**: [`BaseNode`](../classes/BaseNode.md)
#### Defined in
[Node.ts:276](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L276)
@@ -16,7 +16,7 @@ A node with a similarity score
#### Defined in
[Node.ts:296](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L296)
[Node.ts:268](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L268)
___
@@ -26,4 +26,4 @@ ___
#### Defined in
[Node.ts:297](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L297)
[Node.ts:269](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L269)
@@ -14,7 +14,7 @@ custom_edit_url: null
#### Defined in
[Node.ts:30](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L30)
[Node.ts:29](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L29)
___
@@ -24,7 +24,7 @@ ___
#### Defined in
[Node.ts:29](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L29)
[Node.ts:28](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L28)
___
@@ -34,7 +34,7 @@ ___
#### Defined in
[Node.ts:27](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L27)
[Node.ts:26](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L26)
___
@@ -44,4 +44,4 @@ ___
#### Defined in
[Node.ts:28](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L28)
[Node.ts:27](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L27)
@@ -24,7 +24,7 @@ custom_edit_url: null
#### Defined in
[indices/BaseIndex.ts:112](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L112)
[indices/BaseIndex.ts:109](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L109)
___
@@ -38,7 +38,7 @@ ___
#### Defined in
[indices/BaseIndex.ts:114](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L114)
[indices/BaseIndex.ts:111](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L111)
___
@@ -52,7 +52,7 @@ ___
#### Defined in
[indices/BaseIndex.ts:115](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L115)
[indices/BaseIndex.ts:112](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L112)
___
@@ -66,7 +66,7 @@ ___
#### Defined in
[indices/BaseIndex.ts:110](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L110)
[indices/BaseIndex.ts:107](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L107)
___
@@ -80,7 +80,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:108](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L108)
___
@@ -94,4 +94,4 @@ ___
#### Defined in
[indices/BaseIndex.ts:183](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L183)
[indices/BaseIndex.ts:162](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L162)
@@ -14,7 +14,7 @@ custom_edit_url: null
#### Defined in
[indices/BaseIndex.ts:177](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L177)
[indices/BaseIndex.ts:156](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L156)
___
@@ -24,7 +24,7 @@ ___
#### Defined in
[indices/BaseIndex.ts:176](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L176)
[indices/BaseIndex.ts:155](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L155)
___
@@ -34,7 +34,7 @@ ___
#### Defined in
[indices/BaseIndex.ts:175](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L175)
[indices/BaseIndex.ts:154](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L154)
___
@@ -44,7 +44,7 @@ ___
#### Defined in
[indices/BaseIndex.ts:178](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L178)
[indices/BaseIndex.ts:157](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L157)
___
@@ -54,4 +54,4 @@ ___
#### Defined in
[indices/BaseIndex.ts:179](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L179)
[indices/BaseIndex.ts:158](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L158)
+8 -12
View File
@@ -6,10 +6,6 @@ sidebar_position: 0
custom_edit_url: null
---
## Implemented by
- [`SimpleVectorStore`](../classes/SimpleVectorStore.md)
## Properties
### isEmbeddingQuery
@@ -18,7 +14,7 @@ custom_edit_url: null
#### Defined in
[storage/vectorStore/types.ts:62](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L62)
[storage/vectorStore/types.ts:63](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L63)
___
@@ -28,7 +24,7 @@ ___
#### Defined in
[storage/vectorStore/types.ts:61](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L61)
[storage/vectorStore/types.ts:62](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L62)
## Methods
@@ -40,7 +36,7 @@ ___
| Name | Type |
| :------ | :------ |
| `embeddingResults` | [`BaseNode`](../classes/BaseNode.md)[] |
| `embeddingResults` | [`NodeWithEmbedding`](NodeWithEmbedding.md)[] |
#### Returns
@@ -48,7 +44,7 @@ ___
#### Defined in
[storage/vectorStore/types.ts:64](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L64)
[storage/vectorStore/types.ts:65](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L65)
___
@@ -62,7 +58,7 @@ ___
#### Defined in
[storage/vectorStore/types.ts:63](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L63)
[storage/vectorStore/types.ts:64](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L64)
___
@@ -83,7 +79,7 @@ ___
#### Defined in
[storage/vectorStore/types.ts:65](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L65)
[storage/vectorStore/types.ts:66](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L66)
___
@@ -104,7 +100,7 @@ ___
#### Defined in
[storage/vectorStore/types.ts:67](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L67)
[storage/vectorStore/types.ts:68](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L68)
___
@@ -125,4 +121,4 @@ ___
#### Defined in
[storage/vectorStore/types.ts:66](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L66)
[storage/vectorStore/types.ts:67](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L67)
@@ -14,7 +14,7 @@ custom_edit_url: null
#### Defined in
[storage/vectorStore/types.ts:46](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L46)
[storage/vectorStore/types.ts:47](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L47)
___
@@ -24,4 +24,4 @@ ___
#### Defined in
[storage/vectorStore/types.ts:45](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L45)
[storage/vectorStore/types.ts:46](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L46)
@@ -14,7 +14,7 @@ custom_edit_url: null
#### Defined in
[storage/vectorStore/types.ts:55](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L55)
[storage/vectorStore/types.ts:56](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L56)
___
@@ -24,7 +24,7 @@ ___
#### Defined in
[storage/vectorStore/types.ts:52](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L52)
[storage/vectorStore/types.ts:53](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L53)
___
@@ -34,7 +34,7 @@ ___
#### Defined in
[storage/vectorStore/types.ts:56](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L56)
[storage/vectorStore/types.ts:57](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L57)
___
@@ -44,7 +44,7 @@ ___
#### Defined in
[storage/vectorStore/types.ts:57](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L57)
[storage/vectorStore/types.ts:58](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L58)
___
@@ -54,7 +54,7 @@ ___
#### Defined in
[storage/vectorStore/types.ts:54](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L54)
[storage/vectorStore/types.ts:55](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L55)
___
@@ -64,7 +64,7 @@ ___
#### Defined in
[storage/vectorStore/types.ts:50](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L50)
[storage/vectorStore/types.ts:51](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L51)
___
@@ -74,7 +74,7 @@ ___
#### Defined in
[storage/vectorStore/types.ts:53](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L53)
[storage/vectorStore/types.ts:54](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L54)
___
@@ -84,4 +84,4 @@ ___
#### Defined in
[storage/vectorStore/types.ts:51](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L51)
[storage/vectorStore/types.ts:52](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L52)
@@ -14,7 +14,7 @@ custom_edit_url: null
#### Defined in
[storage/vectorStore/types.ts:7](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L7)
[storage/vectorStore/types.ts:8](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L8)
___
@@ -24,7 +24,7 @@ ___
#### Defined in
[storage/vectorStore/types.ts:5](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L5)
[storage/vectorStore/types.ts:6](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L6)
___
@@ -34,4 +34,4 @@ ___
#### Defined in
[storage/vectorStore/types.ts:6](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L6)
[storage/vectorStore/types.ts:7](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L7)
@@ -14,7 +14,7 @@ custom_edit_url: null
#### Defined in
[storage/vectorStore/types.ts:34](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L34)
[storage/vectorStore/types.ts:35](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L35)
___
@@ -24,7 +24,7 @@ ___
#### Defined in
[storage/vectorStore/types.ts:33](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L33)
[storage/vectorStore/types.ts:34](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L34)
___
@@ -34,4 +34,4 @@ ___
#### Defined in
[storage/vectorStore/types.ts:35](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L35)
[storage/vectorStore/types.ts:36](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L36)
+7 -18
View File
@@ -48,11 +48,8 @@ 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)
@@ -80,6 +77,7 @@ custom_edit_url: null
- [MetadataFilters](interfaces/MetadataFilters.md)
- [MetadataInfo](interfaces/MetadataInfo.md)
- [NodeParser](interfaces/NodeParser.md)
- [NodeWithEmbedding](interfaces/NodeWithEmbedding.md)
- [NodeWithScore](interfaces/NodeWithScore.md)
- [QueryEngineTool](interfaces/QueryEngineTool.md)
- [RelatedNodeInfo](interfaces/RelatedNodeInfo.md)
@@ -159,7 +157,7 @@ ___
#### Defined in
[Node.ts:33](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L33)
[Node.ts:32](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L32)
___
@@ -221,21 +219,12 @@ 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-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-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-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
@@ -869,7 +858,7 @@ ___
#### Defined in
[indices/BaseIndex.ts:73](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L73)
[indices/BaseIndex.ts:70](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L70)
___
@@ -889,7 +878,7 @@ ___
#### Defined in
[Node.ts:271](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L271)
[Node.ts:243](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L243)
___
-10
View File
@@ -1,15 +1,5 @@
# simple
## 0.0.16
### Patch Changes
- Updated dependencies [824c13c]
- Updated dependencies [18b8915]
- Updated dependencies [ade9d8f]
- Updated dependencies [824c13c]
- llamaindex@0.0.18
## 0.0.15
### Patch Changes
+9 -10
View File
@@ -1,23 +1,22 @@
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 * as readline from "node:readline/promises";
// @ts-ignore
import { stdin as input, stdout as output } from "node:process";
import {
ContextChatEngine,
Document,
serviceContextFromDefaults,
VectorStoreIndex,
ContextChatEngine,
serviceContextFromDefaults,
} 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 });
+4 -6
View File
@@ -1,9 +1,7 @@
import { stdin as input, stdout as output } from "node:process";
// readline/promises is still experimental so not in @types/node yet
import { OpenAI, LlamaDeuce, ChatMessage, DeuceChatStrategy } from "llamaindex";
// @ts-ignore
import readline from "node:readline/promises";
import { ChatMessage, LlamaDeuce, OpenAI } from "llamaindex";
import * as readline from "node:readline/promises";
import { stdin as input, stdout as output } from "node:process";
(async () => {
const gpt4 = new OpenAI({ model: "gpt-4", temperature: 0.9 });
@@ -29,7 +27,7 @@ import { ChatMessage, LlamaDeuce, OpenAI } from "llamaindex";
history.map(({ content, role }) => ({
content,
role: next === l2 ? role : role === "user" ? "assistant" : "user",
})),
}))
);
history.push({
content: r.message.content,
+6 -3
View File
@@ -13,13 +13,16 @@ async function main() {
chunkSize: 40,
}),
});
const document = new Document({ text: essay, id_: "essay" });
const index = await ListIndex.fromDocuments([document], { serviceContext });
const document = new Document({ text: 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());
}
+1 -1
View File
@@ -1,5 +1,5 @@
{
"version": "0.0.16",
"version": "0.0.15",
"private": true,
"name": "simple",
"dependencies": {
+1
View File
@@ -1,3 +1,4 @@
import fs from "fs/promises";
import { PDFReader, VectorStoreIndex } from "llamaindex";
async function main() {
+5 -4
View File
@@ -1,10 +1,11 @@
import fs from "node:fs/promises";
import fs from "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 essay = await fs.readFile(
"node_modules/llamaindex/examples/abramov.txt",
"utf-8"
);
const textSplitter = new SentenceSplitter();
+4 -4
View File
@@ -1,13 +1,13 @@
import {
Document,
storageContextFromDefaults,
VectorStoreIndex,
storageContextFromDefaults,
} from "llamaindex";
import essay from "./essay";
async function main() {
// Create Document object with essay
const document = new Document({ text: essay, id_: "essay" });
const document = new Document({ text: 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());
}
+3 -3
View File
@@ -1,9 +1,9 @@
import { Document, SubQuestionQueryEngine, VectorStoreIndex } from "llamaindex";
import { Document, VectorStoreIndex, SubQuestionQueryEngine } from "llamaindex";
import essay from "./essay";
(async () => {
const document = new Document({ text: essay, id_: essay });
const document = new Document({ text: 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());
+7 -7
View File
@@ -1,15 +1,15 @@
import fs from "node:fs/promises";
import fs from "fs/promises";
import { Document, VectorStoreIndex } from "llamaindex";
async function main() {
// Load essay from abramov.txt in Node
const path = "node_modules/llamaindex/examples/abramov.txt";
const essay = await fs.readFile(path, "utf-8");
const essay = await fs.readFile(
"node_modules/llamaindex/examples/abramov.txt",
"utf-8"
);
// Create Document object with essay
const document = new Document({ text: essay, id_: path });
const document = new Document({ text: essay });
// 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
+8 -8
View File
@@ -1,20 +1,20 @@
import fs from "node:fs/promises";
import fs from "fs/promises";
import {
Anthropic,
Document,
serviceContextFromDefaults,
VectorStoreIndex,
serviceContextFromDefaults,
} from "llamaindex";
async function main() {
// Load essay from abramov.txt in Node
const path = "node_modules/llamaindex/examples/abramov.txt";
const essay = await fs.readFile(path, "utf-8");
const essay = await fs.readFile(
"node_modules/llamaindex/examples/abramov.txt",
"utf-8"
);
// Create Document object with essay
const document = new Document({ text: essay, id_: path });
const document = new Document({ text: essay });
// 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
+9 -17
View File
@@ -1,31 +1,23 @@
import {
Document,
OpenAI,
RetrieverQueryEngine,
serviceContextFromDefaults,
VectorStoreIndex,
} from "llamaindex";
import { Document, VectorStoreIndex, RetrieverQueryEngine, OpenAI, serviceContextFromDefaults } from "llamaindex";
import essay from "./essay";
// Customize retrieval and query args
async function main() {
const document = new Document({ text: essay, id_: "essay" });
const document = new Document({ text: essay });
const serviceContext = serviceContextFromDefaults({
llm: new OpenAI({ model: "gpt-3.5-turbo", temperature: 0.0 }),
});
const index = await VectorStoreIndex.fromDocuments([document], {
serviceContext,
});
const serviceContext = serviceContextFromDefaults(
{ llm: new OpenAI({ model: "gpt-3.5-turbo", temperature: 0.0 }) }
);
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);
}
+9 -8
View File
@@ -1,19 +1,20 @@
import fs from "node:fs/promises";
import fs from "fs/promises";
import {
Document,
OpenAI,
serviceContextFromDefaults,
Document,
VectorStoreIndex,
serviceContextFromDefaults,
} from "llamaindex";
async function main() {
// Load essay from abramov.txt in Node
const path = "node_modules/llamaindex/examples/abramov.txt";
const essay = await fs.readFile(path, "utf-8");
const essay = await fs.readFile(
"node_modules/llamaindex/examples/abramov.txt",
"utf-8"
);
// Create Document object with essay
const document = new Document({ text: essay, id_: path });
const document = new Document({ text: essay });
// Split text and create embeddings. Store them in a VectorStoreIndex
const serviceContext = serviceContextFromDefaults({
@@ -26,7 +27,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
-1
View File
@@ -1 +0,0 @@
package-lock.json
+9 -10
View File
@@ -1,23 +1,22 @@
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 * as readline from "node:readline/promises";
// @ts-ignore
import { stdin as input, stdout as output } from "node:process";
import {
ContextChatEngine,
Document,
serviceContextFromDefaults,
VectorStoreIndex,
ContextChatEngine,
serviceContextFromDefaults,
} 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 });
+3 -6
View File
@@ -1,9 +1,6 @@
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 });
@@ -29,7 +26,7 @@ import { ChatMessage, LlamaDeuce, OpenAI } from "llamaindex";
history.map(({ content, role }) => ({
content,
role: next === l2 ? role : role === "user" ? "assistant" : "user",
})),
}))
);
history.push({
content: r.message.content,
+6 -3
View File
@@ -13,13 +13,16 @@ async function main() {
chunkSize: 40,
}),
});
const document = new Document({ text: essay, id_: "essay" });
const index = await ListIndex.fromDocuments([document], { serviceContext });
const document = new Document({ text: 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());
}
+2 -2
View File
@@ -1,7 +1,7 @@
import { DeuceChatStrategy, LlamaDeuce } from "llamaindex";
import { LlamaDeuce } from "llamaindex";
(async () => {
const deuce = new LlamaDeuce({ chatStrategy: DeuceChatStrategy.META });
const deuce = new LlamaDeuce();
const result = await deuce.chat([{ content: "Hello, world!", role: "user" }]);
console.log(result);
})();
+367
View File
@@ -0,0 +1,367 @@
{
"name": "simple",
"version": "0.0.3",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "simple",
"version": "0.0.3",
"dependencies": {
"llamaindex": "latest"
},
"devDependencies": {
"@types/node": "^18"
}
},
"node_modules/@anthropic-ai/sdk": {
"version": "0.5.10",
"resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-0.5.10.tgz",
"integrity": "sha512-P8xrIuTUO/6wDzcjQRUROXp4WSqtngbXaE4GpEu0PhEmnq/1Q8vbF1s0o7W07EV3j8zzRoyJxAKovUJtNXH7ew==",
"dependencies": {
"@types/node": "^18.11.18",
"@types/node-fetch": "^2.6.4",
"abort-controller": "^3.0.0",
"agentkeepalive": "^4.2.1",
"digest-fetch": "^1.3.0",
"form-data-encoder": "1.7.2",
"formdata-node": "^4.3.2",
"node-fetch": "^2.6.7"
}
},
"node_modules/@types/node": {
"version": "18.17.3",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.17.3.tgz",
"integrity": "sha512-2x8HWtFk0S99zqVQABU9wTpr8wPoaDHZUcAkoTKH+nL7kPv3WUI9cRi/Kk5Mz4xdqXSqTkKP7IWNoQQYCnDsTA=="
},
"node_modules/@types/node-fetch": {
"version": "2.6.4",
"resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.4.tgz",
"integrity": "sha512-1ZX9fcN4Rvkvgv4E6PAY5WXUFWFcRWxZa3EW83UjycOB9ljJCedb2CupIP4RZMEwF/M3eTcCihbBRgwtGbg5Rg==",
"dependencies": {
"@types/node": "*",
"form-data": "^3.0.0"
}
},
"node_modules/abort-controller": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz",
"integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==",
"dependencies": {
"event-target-shim": "^5.0.0"
},
"engines": {
"node": ">=6.5"
}
},
"node_modules/agentkeepalive": {
"version": "4.5.0",
"resolved": "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-4.5.0.tgz",
"integrity": "sha512-5GG/5IbQQpC9FpkRGsSvZI5QYeSCzlJHdpBQntCsuTOxhKD8lqKhrleg2Yi7yvMIf82Ycmmqln9U8V9qwEiJew==",
"dependencies": {
"humanize-ms": "^1.2.1"
},
"engines": {
"node": ">= 8.0.0"
}
},
"node_modules/asynckit": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
},
"node_modules/base-64": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/base-64/-/base-64-0.1.0.tgz",
"integrity": "sha512-Y5gU45svrR5tI2Vt/X9GPd3L0HNIKzGu202EjxrXMpuc2V2CiKgemAbUUsqYmZJvPtCXoUKjNZwBJzsNScUbXA=="
},
"node_modules/charenc": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz",
"integrity": "sha512-yrLQ/yVUFXkzg7EDQsPieE/53+0RlaWTs+wBrvW36cyilJ2SaDWfl4Yj7MtLTXleV9uEKefbAGUPv2/iWSooRA==",
"engines": {
"node": "*"
}
},
"node_modules/combined-stream": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
"dependencies": {
"delayed-stream": "~1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/crypt": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz",
"integrity": "sha512-mCxBlsHFYh9C+HVpiEacem8FEBnMXgU9gy4zmNC+SXAZNB/1idgp/aulFJ4FgCi7GPEVbfyng092GqL2k2rmow==",
"engines": {
"node": "*"
}
},
"node_modules/debug": {
"version": "3.2.7",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz",
"integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==",
"dependencies": {
"ms": "^2.1.1"
}
},
"node_modules/delayed-stream": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/digest-fetch": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/digest-fetch/-/digest-fetch-1.3.0.tgz",
"integrity": "sha512-CGJuv6iKNM7QyZlM2T3sPAdZWd/p9zQiRNS9G+9COUCwzWFTs0Xp8NF5iePx7wtvhDykReiRRrSeNb4oMmB8lA==",
"dependencies": {
"base-64": "^0.1.0",
"md5": "^2.3.0"
}
},
"node_modules/event-target-shim": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz",
"integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==",
"engines": {
"node": ">=6"
}
},
"node_modules/form-data": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz",
"integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==",
"dependencies": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"mime-types": "^2.1.12"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/form-data-encoder": {
"version": "1.7.2",
"resolved": "https://registry.npmjs.org/form-data-encoder/-/form-data-encoder-1.7.2.tgz",
"integrity": "sha512-qfqtYan3rxrnCk1VYaA4H+Ms9xdpPqvLZa6xmMgFvhO32x7/3J/ExcTd6qpxM0vH2GdMI+poehyBZvqfMTto8A=="
},
"node_modules/formdata-node": {
"version": "4.4.1",
"resolved": "https://registry.npmjs.org/formdata-node/-/formdata-node-4.4.1.tgz",
"integrity": "sha512-0iirZp3uVDjVGt9p49aTaqjk84TrglENEDuqfdlZQ1roC9CWlPk6Avf8EEnZNcAqPonwkG35x4n3ww/1THYAeQ==",
"dependencies": {
"node-domexception": "1.0.0",
"web-streams-polyfill": "4.0.0-beta.3"
},
"engines": {
"node": ">= 12.20"
}
},
"node_modules/humanize-ms": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/humanize-ms/-/humanize-ms-1.2.1.tgz",
"integrity": "sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==",
"dependencies": {
"ms": "^2.0.0"
}
},
"node_modules/is-buffer": {
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz",
"integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w=="
},
"node_modules/llamaindex": {
"version": "0.0.17",
"resolved": "https://registry.npmjs.org/llamaindex/-/llamaindex-0.0.17.tgz",
"integrity": "sha512-2XrKEBUaEfATYmMcW4AkX0B4EiVpp6Gcg3aeWZ+gJZVYc5iMsApReH1gy5T/+XstJWz6lNYOP/DJnVRfkVj0Lg==",
"dependencies": {
"@anthropic-ai/sdk": "^0.5.9",
"lodash": "^4.17.21",
"openai": "4.0.0-beta.8",
"pdf-parse": "^1.1.1",
"replicate": "^0.14.1",
"tiktoken-node": "^0.0.6",
"uuid": "^9.0.0",
"wink-nlp": "^1.14.3"
},
"engines": {
"node": ">=18.0.0"
}
},
"node_modules/lodash": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
},
"node_modules/md5": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/md5/-/md5-2.3.0.tgz",
"integrity": "sha512-T1GITYmFaKuO91vxyoQMFETst+O71VUPEU3ze5GNzDm0OWdP8v1ziTaAEPUr/3kLsY3Sftgz242A1SetQiDL7g==",
"dependencies": {
"charenc": "0.0.2",
"crypt": "0.0.2",
"is-buffer": "~1.1.6"
}
},
"node_modules/mime-db": {
"version": "1.52.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime-types": {
"version": "2.1.35",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
"dependencies": {
"mime-db": "1.52.0"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
},
"node_modules/node-domexception": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz",
"integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/jimmywarting"
},
{
"type": "github",
"url": "https://paypal.me/jimmywarting"
}
],
"engines": {
"node": ">=10.5.0"
}
},
"node_modules/node-ensure": {
"version": "0.0.0",
"resolved": "https://registry.npmjs.org/node-ensure/-/node-ensure-0.0.0.tgz",
"integrity": "sha512-DRI60hzo2oKN1ma0ckc6nQWlHU69RH6xN0sjQTjMpChPfTYvKZdcQFfdYK2RWbJcKyUizSIy/l8OTGxMAM1QDw=="
},
"node_modules/node-fetch": {
"version": "2.6.12",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.12.tgz",
"integrity": "sha512-C/fGU2E8ToujUivIO0H+tpQ6HWo4eEmchoPIoXtxCrVghxdKq+QOHqEZW7tuP3KlV3bC8FRMO5nMCC7Zm1VP6g==",
"dependencies": {
"whatwg-url": "^5.0.0"
},
"engines": {
"node": "4.x || >=6.0.0"
},
"peerDependencies": {
"encoding": "^0.1.0"
},
"peerDependenciesMeta": {
"encoding": {
"optional": true
}
}
},
"node_modules/openai": {
"version": "4.0.0-beta.8",
"resolved": "https://registry.npmjs.org/openai/-/openai-4.0.0-beta.8.tgz",
"integrity": "sha512-bXBxUK2B288GlLckjnpT+UgyyddP+f4JIT5/df95C6eeqQhf5UkuN41Z3uf/6unPvR8Tthm4jJje1fA0OgsDEw==",
"dependencies": {
"@types/node": "^18.11.18",
"@types/node-fetch": "^2.6.4",
"abort-controller": "^3.0.0",
"agentkeepalive": "^4.2.1",
"digest-fetch": "^1.3.0",
"form-data-encoder": "1.7.2",
"formdata-node": "^4.3.2",
"node-fetch": "^2.6.7"
}
},
"node_modules/pdf-parse": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/pdf-parse/-/pdf-parse-1.1.1.tgz",
"integrity": "sha512-v6ZJ/efsBpGrGGknjtq9J/oC8tZWq0KWL5vQrk2GlzLEQPUDB1ex+13Rmidl1neNN358Jn9EHZw5y07FFtaC7A==",
"dependencies": {
"debug": "^3.1.0",
"node-ensure": "^0.0.0"
},
"engines": {
"node": ">=6.8.1"
}
},
"node_modules/replicate": {
"version": "0.14.1",
"resolved": "https://registry.npmjs.org/replicate/-/replicate-0.14.1.tgz",
"integrity": "sha512-3NpuNRbvXoEjY+n/ra24VfQyIRCdLub9GCrU51fFTrMaa6OjRvMC9jGDJSpGRXOLvID75mFgN577HEhA3XEFtg==",
"engines": {
"git": ">=2.11.0",
"node": ">=16.6.0",
"npm": ">=7.19.0",
"yarn": ">=1.7.0"
}
},
"node_modules/tiktoken-node": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/tiktoken-node/-/tiktoken-node-0.0.6.tgz",
"integrity": "sha512-MiprfzPhoKhCflzl0Jyds0VKibAgUGHfJLvBCAXPpum6Lru6ZoKQGsl8lJP0B94LPpby2B2WveOB2tZVfEZQOQ==",
"engines": {
"node": ">= 14"
}
},
"node_modules/tr46": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw=="
},
"node_modules/uuid": {
"version": "9.0.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz",
"integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==",
"bin": {
"uuid": "dist/bin/uuid"
}
},
"node_modules/web-streams-polyfill": {
"version": "4.0.0-beta.3",
"resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-4.0.0-beta.3.tgz",
"integrity": "sha512-QW95TCTaHmsYfHDybGMwO5IJIM93I/6vTRk+daHTWFPhwh+C8Cg7j7XyKrwrj8Ib6vYXe0ocYNrmzY4xAAN6ug==",
"engines": {
"node": ">= 14"
}
},
"node_modules/webidl-conversions": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ=="
},
"node_modules/whatwg-url": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
"integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
"dependencies": {
"tr46": "~0.0.3",
"webidl-conversions": "^3.0.0"
}
},
"node_modules/wink-nlp": {
"version": "1.14.3",
"resolved": "https://registry.npmjs.org/wink-nlp/-/wink-nlp-1.14.3.tgz",
"integrity": "sha512-lvY5iCs3T8I34F8WKS70+2P0U9dWLn3vdPf/Z+m2VK14N7OmqnPzmHfh3moHdusajoQ37Em39z0IZB9K4x/96A=="
}
}
}
+1
View File
@@ -1,3 +1,4 @@
import fs from "fs/promises";
import { PDFReader, VectorStoreIndex } from "llamaindex";
async function main() {
-16
View File
@@ -1,16 +0,0 @@
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();
+4 -4
View File
@@ -1,13 +1,13 @@
import {
Document,
storageContextFromDefaults,
VectorStoreIndex,
storageContextFromDefaults,
} from "llamaindex";
import essay from "./essay";
async function main() {
// Create Document object with essay
const document = new Document({ text: essay, id_: "essay" });
const document = new Document({ text: 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());
}
+3 -3
View File
@@ -1,9 +1,9 @@
import { Document, SubQuestionQueryEngine, VectorStoreIndex } from "llamaindex";
import { Document, VectorStoreIndex, SubQuestionQueryEngine } from "llamaindex";
import essay from "./essay";
(async () => {
const document = new Document({ text: essay, id_: essay });
const document = new Document({ text: 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());
+7 -7
View File
@@ -1,15 +1,15 @@
import fs from "node:fs/promises";
import fs from "fs/promises";
import { Document, VectorStoreIndex } from "llamaindex";
async function main() {
// Load essay from abramov.txt in Node
const path = "node_modules/llamaindex/examples/abramov.txt";
const essay = await fs.readFile(path, "utf-8");
const essay = await fs.readFile(
"node_modules/llamaindex/examples/abramov.txt",
"utf-8"
);
// Create Document object with essay
const document = new Document({ text: essay, id_: path });
const document = new Document({ text: essay });
// 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
+8 -8
View File
@@ -1,20 +1,20 @@
import fs from "node:fs/promises";
import fs from "fs/promises";
import {
Anthropic,
Document,
serviceContextFromDefaults,
VectorStoreIndex,
serviceContextFromDefaults,
} from "llamaindex";
async function main() {
// Load essay from abramov.txt in Node
const path = "node_modules/llamaindex/examples/abramov.txt";
const essay = await fs.readFile(path, "utf-8");
const essay = await fs.readFile(
"node_modules/llamaindex/examples/abramov.txt",
"utf-8"
);
// Create Document object with essay
const document = new Document({ text: essay, id_: path });
const document = new Document({ text: essay });
// 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
+9 -17
View File
@@ -1,31 +1,23 @@
import {
Document,
OpenAI,
RetrieverQueryEngine,
serviceContextFromDefaults,
VectorStoreIndex,
} from "llamaindex";
import { Document, VectorStoreIndex, RetrieverQueryEngine, OpenAI, serviceContextFromDefaults } from "llamaindex";
import essay from "./essay";
// Customize retrieval and query args
async function main() {
const document = new Document({ text: essay, id_: "essay" });
const document = new Document({ text: essay });
const serviceContext = serviceContextFromDefaults({
llm: new OpenAI({ model: "gpt-3.5-turbo", temperature: 0.0 }),
});
const index = await VectorStoreIndex.fromDocuments([document], {
serviceContext,
});
const serviceContext = serviceContextFromDefaults(
{ llm: new OpenAI({ model: "gpt-3.5-turbo", temperature: 0.0 }) }
);
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);
}
+9 -8
View File
@@ -1,19 +1,20 @@
import fs from "node:fs/promises";
import fs from "fs/promises";
import {
Document,
OpenAI,
serviceContextFromDefaults,
Document,
VectorStoreIndex,
serviceContextFromDefaults,
} from "llamaindex";
async function main() {
// Load essay from abramov.txt in Node
const path = "node_modules/llamaindex/examples/abramov.txt";
const essay = await fs.readFile(path, "utf-8");
const essay = await fs.readFile(
"node_modules/llamaindex/examples/abramov.txt",
"utf-8"
);
// Create Document object with essay
const document = new Document({ text: essay, id_: path });
const document = new Document({ text: essay });
// Split text and create embeddings. Store them in a VectorStoreIndex
const serviceContext = serviceContextFromDefaults({
@@ -26,7 +27,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
+2 -2
View File
@@ -17,8 +17,8 @@
"eslint-config-custom": "workspace:*",
"husky": "^8.0.3",
"jest": "^29.6.2",
"prettier": "^3.0.2",
"prettier-plugin-organize-imports": "^3.2.3",
"prettier": "^2.8.8",
"prettier-plugin-tailwindcss": "^0.3.0",
"ts-jest": "^29.1.1",
"turbo": "^1.10.12"
},
-9
View File
@@ -1,14 +1,5 @@
# llamaindex
## 0.0.18
### Patch Changes
- 824c13c: Breaking: allow documents to be reimported with hash checking.
- 18b8915: Update storage exports (thanks @TomPenguin)
- ade9d8f: Bug fix: use session in OpenAI Embeddings (thanks @swk777)
- 824c13c: Breaking: removed nodeId and docId. Just use id\_
## 0.0.17
### Patch Changes
+7 -7
View File
@@ -1,23 +1,23 @@
{
"name": "llamaindex",
"version": "0.0.18",
"version": "0.0.17",
"dependencies": {
"@anthropic-ai/sdk": "^0.6.0",
"@anthropic-ai/sdk": "^0.5.9",
"lodash": "^4.17.21",
"openai": "^4.0.0",
"openai": "4.0.0-beta.8",
"pdf-parse": "^1.1.1",
"replicate": "^0.16.1",
"replicate": "^0.14.1",
"tiktoken-node": "^0.0.6",
"uuid": "^9.0.0",
"wink-nlp": "^1.14.3"
},
"devDependencies": {
"@types/lodash": "^4.14.197",
"@types/node": "^18.17.5",
"@types/lodash": "^4.14.196",
"@types/node": "^18.17.1",
"@types/pdf-parse": "^1.1.1",
"@types/uuid": "^9.0.2",
"node-stdlib-browser": "^1.2.0",
"tsup": "^7.2.0"
"tsup": "^7.1.0"
},
"engines": {
"node": ">=18.0.0"
+5 -7
View File
@@ -259,13 +259,11 @@ export class OpenAIEmbedding extends BaseEmbedding {
});
} else {
this.apiKey = init?.apiKey ?? undefined;
this.session =
init?.session ??
getOpenAISession({
apiKey: this.apiKey,
maxRetries: this.maxRetries,
timeout: this.timeout,
});
this.session = getOpenAISession({
apiKey: this.apiKey,
maxRetries: this.maxRetries,
timeout: this.timeout,
});
}
}
+20 -40
View File
@@ -1,4 +1,3 @@
import crypto from "crypto"; // TODO Node dependency
import { v4 as uuidv4 } from "uuid";
export enum NodeRelationship {
@@ -36,12 +35,6 @@ 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[];
@@ -62,6 +55,10 @@ 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];
@@ -77,7 +74,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"
);
}
@@ -109,15 +106,13 @@ 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");
@@ -128,7 +123,7 @@ export abstract class BaseNode {
asRelatedNodeInfo(): RelatedNodeInfo {
return {
nodeId: this.id_,
nodeId: this.nodeId,
metadata: this.metadata,
hash: this.hash,
};
@@ -157,27 +152,10 @@ 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() {
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");
throw new Error("Not implemented");
}
getType(): ObjectType {
@@ -212,8 +190,6 @@ export class TextNode extends BaseNode {
setContent(value: string) {
this.text = value;
this.hash = this.generateHash();
}
getNodeInfo() {
@@ -239,10 +215,6 @@ 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 {
@@ -257,15 +229,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) {
@@ -296,3 +268,11 @@ export interface NodeWithScore {
node: BaseNode;
score: number;
}
/**
* A node with an embedding
*/
export interface NodeWithEmbedding {
node: BaseNode;
embedding: number[];
}
@@ -1,8 +1,9 @@
import { ChatCompletionChunk } from "openai/resources/chat";
import { Stream } from "openai/streaming";
import { globalsHelper } from "../../GlobalsHelper";
import { StreamCallbackResponse, Event } from "../CallbackManager";
import { APIResponse } from "openai/core";
import { Stream } from "openai/streaming";
import { MessageType } from "../../llm/LLM";
import { Event, StreamCallbackResponse } from "../CallbackManager";
/**
* Handles the OpenAI streaming interface and pipes it to the callback function
@@ -16,7 +17,7 @@ export async function handleOpenAIStream({
onLLMStream,
parentEvent,
}: {
response: Stream<ChatCompletionChunk>;
response: APIResponse<Stream<ChatCompletionChunk>>;
onLLMStream: (data: StreamCallbackResponse) => void;
parentEvent?: Event;
}): Promise<{ message: string; role: MessageType }> {
+6 -27
View File
@@ -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 { BaseDocumentStore } from "../storage/docStore/types";
import { BaseIndexStore } from "../storage/indexStore/types";
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";
/**
* The underlying structure of each index.
@@ -43,6 +43,7 @@ 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 {
@@ -64,10 +65,6 @@ export class IndexDict extends IndexStruct {
type: this.type,
};
}
delete(nodeId: string) {
delete this.nodesDict[nodeId];
}
}
export function jsonToIndexStruct(json: any): IndexStruct {
@@ -151,24 +148,6 @@ 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 {
+26 -57
View File
@@ -1,30 +1,26 @@
import _ from "lodash";
import { BaseNode, Document } from "../../Node";
import { BaseIndex, BaseIndexInit, IndexList } from "../BaseIndex";
import { BaseQueryEngine, RetrieverQueryEngine } from "../../QueryEngine";
import {
CompactAndRefine,
ResponseSynthesizer,
} from "../../ResponseSynthesizer";
StorageContext,
storageContextFromDefaults,
} from "../../storage/StorageContext";
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 {
StorageContext,
storageContextFromDefaults,
} from "../../storage/StorageContext";
import {
BaseIndex,
BaseIndexInit,
IndexList,
IndexStructType,
} from "../BaseIndex";
import {
ListIndexLLMRetriever,
ListIndexRetriever,
} from "./ListIndexRetriever";
ResponseSynthesizer,
CompactAndRefine,
} from "../../ResponseSynthesizer";
import { IndexStructType } from "../BaseIndex";
export enum ListRetrieverMode {
DEFAULT = "default",
@@ -61,7 +57,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"
);
}
@@ -71,7 +67,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;
@@ -80,25 +76,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);
@@ -118,7 +114,7 @@ export class ListIndex extends BaseIndex<IndexList> {
args: {
storageContext?: StorageContext;
serviceContext?: ServiceContext;
} = {},
} = {}
): Promise<ListIndex> {
let { storageContext, serviceContext } = args;
storageContext = storageContext ?? (await storageContextFromDefaults({}));
@@ -173,10 +169,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();
@@ -188,43 +184,16 @@ export class ListIndex extends BaseIndex<IndexList> {
return indexStruct;
}
async insertNodes(nodes: BaseNode[]): Promise<void> {
protected _insert(nodes: BaseNode[]): void {
for (const node of nodes) {
this.indexStruct.addNode(node);
}
}
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) {
protected _deleteNode(nodeId: string): void {
this.indexStruct.nodes = this.indexStruct.nodes.filter(
(existingNodeId: string) => !nodeIds.includes(existingNodeId),
(existingNodeId: string) => existingNodeId !== nodeId
);
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>> {
@@ -1,12 +1,15 @@
import { BaseNode, Document, MetadataMode } from "../../Node";
import {
Document,
BaseNode,
MetadataMode,
NodeWithEmbedding,
} from "../../Node";
import { BaseQueryEngine, RetrieverQueryEngine } from "../../QueryEngine";
import { ResponseSynthesizer } from "../../ResponseSynthesizer";
import { BaseRetriever } from "../../Retriever";
import { VectorIndexRetriever } from "./VectorIndexRetriever";
import {
ServiceContext,
serviceContextFromDefaults,
} from "../../ServiceContext";
import { BaseDocumentStore } from "../../storage/docStore/types";
import {
StorageContext,
storageContextFromDefaults,
@@ -15,11 +18,13 @@ import { VectorStore } from "../../storage/vectorStore/types";
import {
BaseIndex,
IndexDict,
IndexStructType,
VectorIndexConstructorProps,
VectorIndexOptions,
IndexStructType
} from "../BaseIndex";
import { VectorIndexRetriever } from "./VectorIndexRetriever";
import { BaseRetriever } from "../../Retriever";
import { ResponseSynthesizer } from "../../ResponseSynthesizer";
import { BaseDocumentStore } from "../../storage/docStore/types";
/**
* The VectorStoreIndex, an index that stores the nodes only according to their vector embedings.
@@ -50,11 +55,11 @@ export class VectorStoreIndex extends BaseIndex<IndexDict> {
// Setup IndexStruct from storage
let indexStructs = (await indexStore.getIndexStructs()) as IndexDict[];
let indexStruct: IndexDict | undefined;
let indexStruct: IndexDict | null;
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"
);
}
@@ -64,44 +69,53 @@ 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 = undefined;
indexStruct = null;
}
// 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 && !options.nodes) {
throw new Error(
"Cannot initialize VectorStoreIndex without nodes or 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
);
await indexStore.addIndexStruct(indexStruct);
}
const nodes = options.nodes ?? [];
indexStruct = await VectorStoreIndex.buildIndexFromNodes(
nodes,
serviceContext,
vectorStore,
docStore,
indexStruct,
);
await indexStore.addIndexStruct(indexStruct);
return new VectorStoreIndex({
// Using the singleton pattern to ensure that only one instance of VectorStoreIndex is created.
if (VectorStoreIndex.instance) {
throw new Error('VectorStoreIndex has already been initialized');
}
VectorStoreIndex.instance = new VectorStoreIndex({
storageContext,
serviceContext,
docStore,
vectorStore,
indexStruct,
});
return VectorStoreIndex.instance;
}
/**
@@ -114,20 +128,22 @@ export class VectorStoreIndex extends BaseIndex<IndexDict> {
static async getNodeEmbeddingResults(
nodes: BaseNode[],
serviceContext: ServiceContext,
logProgress = false,
logProgress = false
) {
const nodesWithEmbeddings: BaseNode[] = [];
const nodesWithEmbeddings: NodeWithEmbedding[] = [];
for (let i = 0; i < nodes.length; ++i) {
const node = nodes[i];
if (logProgress) {
const node = nodes[i];
if (typeof node.getContent !== 'function') {
throw new Error('Expected node object of type BaseNode with getContent function');
}
if (logProgress) {
console.log(`getting embedding for node ${i}/${nodes.length}`);
}
const embedding = await serviceContext.embedModel.getTextEmbedding(
node.getContent(MetadataMode.EMBED),
);
node.embedding = embedding;
nodesWithEmbeddings.push(node);
}
const embedding = await serviceContext.embedModel.getTextEmbedding(
node.getContent(MetadataMode.EMBED)
);
nodesWithEmbeddings.push({ node, embedding });
}
return nodesWithEmbeddings;
@@ -144,33 +160,24 @@ export class VectorStoreIndex extends BaseIndex<IndexDict> {
nodes: BaseNode[],
serviceContext: ServiceContext,
vectorStore: VectorStore,
docStore: BaseDocumentStore,
indexDict?: IndexDict,
docStore: BaseDocumentStore
): 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(
newNodes,
serviceContext,
nodes,
serviceContext
);
await vectorStore.add(embeddingResults);
vectorStore.add(embeddingResults);
if (!vectorStore.storesText) {
await docStore.addDocuments(embeddingResults, true);
await docStore.addDocuments(
embeddingResults.map((result) => result.node),
true
);
}
for (const node of embeddingResults) {
const indexDict = new IndexDict();
for (const { node } of embeddingResults) {
indexDict.addNode(node);
}
@@ -189,7 +196,7 @@ export class VectorStoreIndex extends BaseIndex<IndexDict> {
args: {
storageContext?: StorageContext;
serviceContext?: ServiceContext;
} = {},
} = {}
): Promise<VectorStoreIndex> {
let { storageContext, serviceContext } = args;
storageContext = storageContext ?? (await storageContextFromDefaults({}));
@@ -218,57 +225,6 @@ 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);
}
}
}
}
+16 -16
View File
@@ -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);
}
@@ -1,9 +1,9 @@
import _, * as lodash from "lodash";
import { BaseNode, ObjectType } from "../../Node";
import { DEFAULT_NAMESPACE } from "../constants";
import { BaseKVStore } from "../kvStore/types";
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 { DEFAULT_NAMESPACE } from "../constants";
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)) || {
nodeIds: [],
docIds: [],
extraInfo: {},
};
refDocInfo.nodeIds.push(doc.id_);
refDocInfo.docIds.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.nodeIds) {
for (let docId of refDocInfo.docIds) {
await this.deleteDocument(docId, false, false);
}
+10 -10
View File
@@ -1,14 +1,14 @@
import { BaseNode } from "../../Node";
import {
DEFAULT_DOC_STORE_PERSIST_FILENAME,
DEFAULT_PERSIST_DIR,
} from "../constants";
import { GenericFileSystem } from "../FileSystem";
import {
DEFAULT_PERSIST_DIR,
DEFAULT_DOC_STORE_PERSIST_FILENAME,
} from "../constants";
const defaultPersistPath = `${DEFAULT_PERSIST_DIR}/${DEFAULT_DOC_STORE_PERSIST_FILENAME}`;
export interface RefDocInfo {
nodeIds: string[];
docIds: 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): Promise<void>;
abstract addDocuments(docs: BaseNode[], allowUpdate: boolean): void;
abstract getDocument(
docId: string,
raiseError: boolean,
raiseError: boolean
): Promise<BaseNode | undefined>;
abstract deleteDocument(docId: string, raiseError: boolean): Promise<void>;
abstract deleteDocument(docId: string, raiseError: boolean): 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))
);
}
@@ -1,19 +1,19 @@
import _ from "lodash";
import * as path from "path";
import {
getTopKEmbeddings,
getTopKEmbeddingsLearner,
getTopKMMREmbeddings,
} from "../../Embedding";
import { BaseNode } from "../../Node";
import { DEFAULT_FS, DEFAULT_PERSIST_DIR } from "../constants";
import { exists, GenericFileSystem } from "../FileSystem";
import _ from "lodash";
import { GenericFileSystem, exists } from "../FileSystem";
import {
VectorStore,
VectorStoreQuery,
VectorStoreQueryMode,
VectorStoreQueryResult,
} from "./types";
import {
getTopKEmbeddings,
getTopKEmbeddingsLearner,
getTopKMMREmbeddings,
} from "../../Embedding";
import { DEFAULT_PERSIST_DIR, DEFAULT_FS } from "../constants";
import { NodeWithEmbedding } from "../../Node";
const LEARNER_MODES = new Set<VectorStoreQueryMode>([
VectorStoreQueryMode.SVM,
@@ -41,7 +41,7 @@ export class SimpleVectorStore implements VectorStore {
static async fromPersistDir(
persistDir: string = DEFAULT_PERSIST_DIR,
fs: GenericFileSystem = DEFAULT_FS,
fs: GenericFileSystem = DEFAULT_FS
): Promise<SimpleVectorStore> {
let persistPath = `${persistDir}/vector_store.json`;
return await SimpleVectorStore.fromPersistPath(persistPath, fs);
@@ -55,28 +55,29 @@ export class SimpleVectorStore implements VectorStore {
return this.data.embeddingDict[textId];
}
async add(embeddingResults: BaseNode[]): Promise<string[]> {
for (let node of embeddingResults) {
this.data.embeddingDict[node.id_] = node.getEmbedding();
async add(embeddingResults: NodeWithEmbedding[]): Promise<string[]> {
for (let result of embeddingResults) {
this.data.embeddingDict[result.node.id_] = result.embedding;
if (!node.sourceNode) {
if (!result.node.sourceNode) {
console.error("Missing source node from TextNode.");
continue;
}
this.data.textIdToRefDocId[node.id_] = node.sourceNode?.nodeId;
this.data.textIdToRefDocId[result.node.id_] =
result.node.sourceNode?.nodeId;
}
if (this.persistPath) {
await this.persist(this.persistPath, this.fs);
}
return embeddingResults.map((result) => result.id_);
return embeddingResults.map((result) => result.node.id_);
}
async delete(refDocId: string): Promise<void> {
let textIdsToDelete = Object.keys(this.data.textIdToRefDocId).filter(
(textId) => this.data.textIdToRefDocId[textId] === refDocId,
(textId) => this.data.textIdToRefDocId[textId] === refDocId
);
for (let textId of textIdsToDelete) {
delete this.data.embeddingDict[textId];
@@ -88,7 +89,7 @@ export class SimpleVectorStore implements VectorStore {
async query(query: VectorStoreQuery): Promise<VectorStoreQueryResult> {
if (!_.isNil(query.filters)) {
throw new Error(
"Metadata filters not implemented for SimpleVectorStore yet.",
"Metadata filters not implemented for SimpleVectorStore yet."
);
}
@@ -114,7 +115,7 @@ export class SimpleVectorStore implements VectorStore {
queryEmbedding,
embeddings,
query.similarityTopK,
nodeIds,
nodeIds
);
} else if (query.mode === MMR_MODE) {
let mmrThreshold = query.mmrThreshold;
@@ -124,14 +125,14 @@ export class SimpleVectorStore implements VectorStore {
null,
query.similarityTopK,
nodeIds,
mmrThreshold,
mmrThreshold
);
} else if (query.mode === VectorStoreQueryMode.DEFAULT) {
[topSimilarities, topIds] = getTopKEmbeddings(
queryEmbedding,
embeddings,
query.similarityTopK,
nodeIds,
nodeIds
);
} else {
throw new Error(`Invalid query mode: ${query.mode}`);
@@ -145,7 +146,7 @@ export class SimpleVectorStore implements VectorStore {
async persist(
persistPath: string = `${DEFAULT_PERSIST_DIR}/vector_store.json`,
fs?: GenericFileSystem,
fs?: GenericFileSystem
): Promise<void> {
fs = fs || this.fs;
let dirPath = path.dirname(persistPath);
@@ -158,7 +159,7 @@ export class SimpleVectorStore implements VectorStore {
static async fromPersistPath(
persistPath: string,
fs?: GenericFileSystem,
fs?: GenericFileSystem
): Promise<SimpleVectorStore> {
fs = fs || DEFAULT_FS;
@@ -173,7 +174,7 @@ export class SimpleVectorStore implements VectorStore {
dataDict = JSON.parse(fileData.toString());
} catch (e) {
console.error(
`No valid data found at path: ${persistPath} starting new store.`,
`No valid data found at path: ${persistPath} starting new store.`
);
}
@@ -1,5 +1,6 @@
import { BaseNode } from "../../Node";
import { GenericFileSystem } from "../FileSystem";
import { NodeWithEmbedding } from "../../Node";
export interface VectorStoreQueryResult {
nodes?: BaseNode[];
@@ -61,7 +62,7 @@ export interface VectorStore {
storesText: boolean;
isEmbeddingQuery?: boolean;
client(): any;
add(embeddingResults: BaseNode[]): Promise<string[]>;
add(embeddingResults: NodeWithEmbedding[]): Promise<string[]>;
delete(refDocId: string, deleteKwargs?: any): Promise<void>;
query(query: VectorStoreQuery, kwargs?: any): Promise<VectorStoreQueryResult>;
persist(persistPath: string, fs?: GenericFileSystem): Promise<void>;
+425 -746
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -1,3 +1,3 @@
module.exports = {
plugins: ["prettier-plugin-organize-imports"],
plugins: [require("prettier-plugin-tailwindcss")],
};