mirror of
https://github.com/run-llama/LlamaIndexTS.git
synced 2026-07-19 18:43:34 -04:00
Compare commits
29 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e9e01c3aaa | |||
| 18b8915f22 | |||
| 9bbfc2414e | |||
| 9487aa1ed5 | |||
| fd74c52fe8 | |||
| 0d2bf51a2e | |||
| 551c0edadf | |||
| f80b06293b | |||
| b3fec86413 | |||
| ab886a34d7 | |||
| 1ec9da120e | |||
| 817178272d | |||
| 3316c6b41c | |||
| 9214b0669d | |||
| b3d659b9af | |||
| 05b0fca610 | |||
| 64b909f436 | |||
| a2e6299aaa | |||
| 1fbfcab55e | |||
| 7db567ea74 | |||
| 6354c16776 | |||
| eb4c3dd3c7 | |||
| 8a4330132c | |||
| f2d4f828d4 | |||
| fe8030a9ad | |||
| ec12633ae0 | |||
| 5e24733e41 | |||
| a13911435f | |||
| 857bb4596a |
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"llamaindex": patch
|
||||
---
|
||||
|
||||
Update storage exports (thanks @TomPenguin)
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
"llamaindex": patch
|
||||
---
|
||||
|
||||
Added Anthropic Claude support
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
"llamaindex": patch
|
||||
---
|
||||
|
||||
Add Top P
|
||||
+4
-2
@@ -12,7 +12,7 @@ apps/simple is where the demo code lives
|
||||
|
||||
### Turborepo docs
|
||||
|
||||
You can checkout how Turborepo works using the built in [README-turborepo.md](README-turborepo.md)
|
||||
You can checkout how Turborepo works using the default [README-turborepo.md](/README-turborepo.md)
|
||||
|
||||
## Getting Started
|
||||
|
||||
@@ -41,12 +41,14 @@ To run them, run
|
||||
pnpm run test
|
||||
```
|
||||
|
||||
To write new test cases write them in packages/core/src/tests
|
||||
To write new test cases write them in [packages/core/src/tests](/packages/core/src/tests)
|
||||
|
||||
We use Jest https://jestjs.io/ to write our test cases. Jest comes with a bunch of built in assertions using the expect function: https://jestjs.io/docs/expect
|
||||
|
||||
### Demo applications
|
||||
|
||||
There is an existing ["simple"](/apps/simple/README.md) demos folder with mainly NodeJS scripts. Feel free to add additional demos to that folder. If you would like to try out your changes in the core package with a new demo, you need to run the build command in the README.
|
||||
|
||||
You can create new demo applications in the apps folder. Just run pnpm init in the folder after you create it to create its own package.json
|
||||
|
||||
### Installing packages
|
||||
|
||||
@@ -64,29 +64,35 @@ Then you can run it using
|
||||
pnpm dlx ts-node example.ts
|
||||
```
|
||||
|
||||
## Core concepts for getting started:
|
||||
|
||||
- [Document](packages/core/src/Node.ts): A document represents a text file, PDF file or other contiguous piece of data.
|
||||
|
||||
- [Node](packages/core/src/Node.ts): The basic data building block. Most commonly, these are parts of the document split into manageable pieces that are small enough to be fed into an embedding model and LLM.
|
||||
|
||||
- [Embedding](packages/core/src/Embedding.ts): Embeddings are sets of floating point numbers which represent the data in a Node. By comparing the similarity of embeddings, we can derive an understanding of the similarity of two pieces of data. One use case is to compare the embedding of a question with the embeddings of our Nodes to see which Nodes may contain the data needed to answer that quesiton.
|
||||
|
||||
- [Indices](packages/core/src/indices/): Indices store the Nodes and the embeddings of those nodes. QueryEngines retrieve Nodes from these Indices using embedding similarity.
|
||||
|
||||
- [QueryEngine](packages/core/src/QueryEngine.ts): Query engines are what generate the query you put in and give you back the result. Query engines generally combine a pre-built prompt with selected Nodes from your Index to give the LLM the context it needs to answer your query.
|
||||
|
||||
- [ChatEngine](packages/core/src/ChatEngine.ts): A ChatEngine helps you build a chatbot that will interact with your Indices.
|
||||
|
||||
- [SimplePrompt](packages/core/src/Prompt.ts): A simple standardized function call definition that takes in inputs and formats them in a template literal. SimplePrompts can be specialized using currying and combined using other SimplePrompt functions.
|
||||
|
||||
## Playground
|
||||
|
||||
Check out our NextJS playground at https://llama-playground.vercel.app/. The source is available at https://github.com/run-llama/ts-playground
|
||||
|
||||
## Core concepts for getting started:
|
||||
|
||||
- [Document](/packages/core/src/Node.ts): A document represents a text file, PDF file or other contiguous piece of data.
|
||||
|
||||
- [Node](/packages/core/src/Node.ts): The basic data building block. Most commonly, these are parts of the document split into manageable pieces that are small enough to be fed into an embedding model and LLM.
|
||||
|
||||
- [Embedding](/packages/core/src/Embedding.ts): Embeddings are sets of floating point numbers which represent the data in a Node. By comparing the similarity of embeddings, we can derive an understanding of the similarity of two pieces of data. One use case is to compare the embedding of a question with the embeddings of our Nodes to see which Nodes may contain the data needed to answer that quesiton.
|
||||
|
||||
- [Indices](/packages/core/src/indices/): Indices store the Nodes and the embeddings of those nodes. QueryEngines retrieve Nodes from these Indices using embedding similarity.
|
||||
|
||||
- [QueryEngine](/packages/core/src/QueryEngine.ts): Query engines are what generate the query you put in and give you back the result. Query engines generally combine a pre-built prompt with selected Nodes from your Index to give the LLM the context it needs to answer your query.
|
||||
|
||||
- [ChatEngine](/packages/core/src/ChatEngine.ts): A ChatEngine helps you build a chatbot that will interact with your Indices.
|
||||
|
||||
- [SimplePrompt](/packages/core/src/Prompt.ts): A simple standardized function call definition that takes in inputs and formats them in a template literal. SimplePrompts can be specialized using currying and combined using other SimplePrompt functions.
|
||||
|
||||
## Supported LLMs:
|
||||
|
||||
- OpenAI GPT-3.5-turbo and GPT-4
|
||||
- Anthropic Claude Instant and Claude 2
|
||||
- Llama2 Chat LLMs (70B, 13B, and 7B parameters)
|
||||
|
||||
## Contributing:
|
||||
|
||||
We are in the very early days of LlamaIndex.TS. If you’re interested in hacking on it with us check out our [contributing guide](CONTRIBUTING.md)
|
||||
We are in the very early days of LlamaIndex.TS. If you’re interested in hacking on it with us check out our [contributing guide](/CONTRIBUTING.md)
|
||||
|
||||
## Bugs? Questions?
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ Anthropic LLM implementation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:343](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L343)
|
||||
[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:336](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L336)
|
||||
[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:341](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L341)
|
||||
[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:337](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L337)
|
||||
[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:333](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L333)
|
||||
[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:331](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L331)
|
||||
[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:339](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L339)
|
||||
[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:332](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L332)
|
||||
[llm/LLM.ts:375](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L375)
|
||||
|
||||
___
|
||||
|
||||
@@ -106,7 +106,17 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:338](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L338)
|
||||
[llm/LLM.ts:382](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L382)
|
||||
|
||||
___
|
||||
|
||||
### topP
|
||||
|
||||
• **topP**: `number`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:376](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L376)
|
||||
|
||||
## Methods
|
||||
|
||||
@@ -133,7 +143,7 @@ Get a chat response from the LLM
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:377](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L377)
|
||||
[llm/LLM.ts:422](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L422)
|
||||
|
||||
___
|
||||
|
||||
@@ -160,7 +170,7 @@ Get a prompt completion from the LLM
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:394](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L394)
|
||||
[llm/LLM.ts:440](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L440)
|
||||
|
||||
___
|
||||
|
||||
@@ -180,4 +190,4 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:362](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L362)
|
||||
[llm/LLM.ts:407](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L407)
|
||||
|
||||
@@ -36,7 +36,7 @@ custom_edit_url: null
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Embedding.ts:206](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Embedding.ts#L206)
|
||||
[Embedding.ts:213](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Embedding.ts#L213)
|
||||
|
||||
___
|
||||
|
||||
@@ -56,7 +56,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Embedding.ts:205](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Embedding.ts#L205)
|
||||
[Embedding.ts:212](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Embedding.ts#L212)
|
||||
|
||||
___
|
||||
|
||||
@@ -78,4 +78,4 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Embedding.ts:197](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Embedding.ts#L197)
|
||||
[Embedding.ts:204](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Embedding.ts#L204)
|
||||
|
||||
@@ -43,7 +43,7 @@ they can be retrieved for our queries.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[indices/BaseIndex.ts:122](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L122)
|
||||
[indices/BaseIndex.ts: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:117](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L117)
|
||||
[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:119](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L119)
|
||||
[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:120](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L120)
|
||||
[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:115](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L115)
|
||||
[indices/BaseIndex.ts:120](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L120)
|
||||
|
||||
___
|
||||
|
||||
@@ -93,17 +93,17 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[indices/BaseIndex.ts:116](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L116)
|
||||
[indices/BaseIndex.ts:121](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L121)
|
||||
|
||||
___
|
||||
|
||||
### vectorStore
|
||||
|
||||
• `Optional` **vectorStore**: `VectorStore`
|
||||
• `Optional` **vectorStore**: [`VectorStore`](../interfaces/VectorStore.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[indices/BaseIndex.ts:118](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L118)
|
||||
[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:142](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L142)
|
||||
[indices/BaseIndex.ts:147](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L147)
|
||||
|
||||
___
|
||||
|
||||
@@ -150,4 +150,4 @@ Create a new retriever from the index.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[indices/BaseIndex.ts:135](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L135)
|
||||
[indices/BaseIndex.ts:140](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L140)
|
||||
|
||||
@@ -285,3 +285,19 @@ ___
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:56](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### toJSON
|
||||
|
||||
▸ **toJSON**(): `Record`<`string`, `any`\>
|
||||
|
||||
Used with built in JSON.stringify
|
||||
|
||||
#### Returns
|
||||
|
||||
`Record`<`string`, `any`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:136](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L136)
|
||||
|
||||
@@ -32,7 +32,7 @@ A document is just a special text node with a docId.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:216](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L216)
|
||||
[Node.ts:229](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L229)
|
||||
|
||||
## Properties
|
||||
|
||||
@@ -60,7 +60,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:139](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L139)
|
||||
[Node.ts:147](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L147)
|
||||
|
||||
___
|
||||
|
||||
@@ -144,7 +144,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:142](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L142)
|
||||
[Node.ts:150](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L150)
|
||||
|
||||
___
|
||||
|
||||
@@ -172,7 +172,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:138](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L138)
|
||||
[Node.ts:146](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L146)
|
||||
|
||||
___
|
||||
|
||||
@@ -186,7 +186,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:137](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L137)
|
||||
[Node.ts:145](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L145)
|
||||
|
||||
## Accessors
|
||||
|
||||
@@ -218,7 +218,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:225](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L225)
|
||||
[Node.ts:238](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L238)
|
||||
|
||||
___
|
||||
|
||||
@@ -344,7 +344,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:149](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L149)
|
||||
[Node.ts:157](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L157)
|
||||
|
||||
___
|
||||
|
||||
@@ -368,7 +368,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:157](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L157)
|
||||
[Node.ts:165](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L165)
|
||||
|
||||
___
|
||||
|
||||
@@ -410,7 +410,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:162](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L162)
|
||||
[Node.ts:170](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L170)
|
||||
|
||||
___
|
||||
|
||||
@@ -433,7 +433,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:187](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L187)
|
||||
[Node.ts:195](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L195)
|
||||
|
||||
___
|
||||
|
||||
@@ -451,7 +451,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:191](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L191)
|
||||
[Node.ts:199](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L199)
|
||||
|
||||
___
|
||||
|
||||
@@ -469,7 +469,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:221](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L221)
|
||||
[Node.ts:234](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L234)
|
||||
|
||||
___
|
||||
|
||||
@@ -493,4 +493,24 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:183](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L183)
|
||||
[Node.ts:191](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L191)
|
||||
|
||||
___
|
||||
|
||||
### toJSON
|
||||
|
||||
▸ **toJSON**(): `Record`<`string`, `any`\>
|
||||
|
||||
Used with built in JSON.stringify
|
||||
|
||||
#### Returns
|
||||
|
||||
`Record`<`string`, `any`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
[TextNode](TextNode.md).[toJSON](TextNode.md#tojson)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:136](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L136)
|
||||
|
||||
@@ -57,7 +57,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[indices/BaseIndex.ts:85](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L85)
|
||||
[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:86](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L86)
|
||||
[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:88](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L88)
|
||||
[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:92](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L92)
|
||||
[indices/BaseIndex.ts:97](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L97)
|
||||
|
||||
@@ -24,15 +24,15 @@ TextNode is the default node type for text. Most common node type in LlamaIndex.
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `init?` | `Partial`<[`TextNode`](TextNode.md)\> |
|
||||
| `init?` | `Partial`<[`IndexNode`](IndexNode.md)\> |
|
||||
|
||||
#### Inherited from
|
||||
#### Overrides
|
||||
|
||||
[TextNode](TextNode.md).[constructor](TextNode.md#constructor)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:144](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L144)
|
||||
[Node.ts:215](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L215)
|
||||
|
||||
## Properties
|
||||
|
||||
@@ -60,7 +60,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:139](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L139)
|
||||
[Node.ts:147](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L147)
|
||||
|
||||
___
|
||||
|
||||
@@ -126,7 +126,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:205](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L205)
|
||||
[Node.ts:213](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L213)
|
||||
|
||||
___
|
||||
|
||||
@@ -154,7 +154,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:142](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L142)
|
||||
[Node.ts:150](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L150)
|
||||
|
||||
___
|
||||
|
||||
@@ -182,7 +182,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:138](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L138)
|
||||
[Node.ts:146](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L146)
|
||||
|
||||
___
|
||||
|
||||
@@ -196,7 +196,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:137](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L137)
|
||||
[Node.ts:145](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L145)
|
||||
|
||||
## Accessors
|
||||
|
||||
@@ -340,7 +340,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:149](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L149)
|
||||
[Node.ts:157](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L157)
|
||||
|
||||
___
|
||||
|
||||
@@ -364,7 +364,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:157](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L157)
|
||||
[Node.ts:165](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L165)
|
||||
|
||||
___
|
||||
|
||||
@@ -406,7 +406,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:162](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L162)
|
||||
[Node.ts:170](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L170)
|
||||
|
||||
___
|
||||
|
||||
@@ -429,7 +429,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:187](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L187)
|
||||
[Node.ts:195](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L195)
|
||||
|
||||
___
|
||||
|
||||
@@ -447,7 +447,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:191](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L191)
|
||||
[Node.ts:199](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L199)
|
||||
|
||||
___
|
||||
|
||||
@@ -465,7 +465,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:207](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L207)
|
||||
[Node.ts:220](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L220)
|
||||
|
||||
___
|
||||
|
||||
@@ -489,4 +489,24 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:183](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L183)
|
||||
[Node.ts:191](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L191)
|
||||
|
||||
___
|
||||
|
||||
### toJSON
|
||||
|
||||
▸ **toJSON**(): `Record`<`string`, `any`\>
|
||||
|
||||
Used with built in JSON.stringify
|
||||
|
||||
#### Returns
|
||||
|
||||
`Record`<`string`, `any`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
[TextNode](TextNode.md).[toJSON](TextNode.md#tojson)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:136](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L136)
|
||||
|
||||
@@ -46,7 +46,7 @@ A ListIndex keeps nodes in a sequential list structure
|
||||
|
||||
#### Defined in
|
||||
|
||||
[indices/BaseIndex.ts:117](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L117)
|
||||
[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:119](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L119)
|
||||
[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:120](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L120)
|
||||
[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:115](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L115)
|
||||
[indices/BaseIndex.ts:120](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L120)
|
||||
|
||||
___
|
||||
|
||||
@@ -102,13 +102,13 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[indices/BaseIndex.ts:116](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L116)
|
||||
[indices/BaseIndex.ts:121](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L121)
|
||||
|
||||
___
|
||||
|
||||
### vectorStore
|
||||
|
||||
• `Optional` **vectorStore**: `VectorStore`
|
||||
• `Optional` **vectorStore**: [`VectorStore`](../interfaces/VectorStore.md)
|
||||
|
||||
#### Inherited from
|
||||
|
||||
@@ -116,7 +116,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[indices/BaseIndex.ts:118](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L118)
|
||||
[indices/BaseIndex.ts:123](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L123)
|
||||
|
||||
## Methods
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ Llama2 LLM implementation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:204](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L204)
|
||||
[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:199](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L199)
|
||||
[llm/LLM.ts:236](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L236)
|
||||
|
||||
___
|
||||
|
||||
@@ -46,7 +46,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:201](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L201)
|
||||
[llm/LLM.ts:239](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L239)
|
||||
|
||||
___
|
||||
|
||||
@@ -56,7 +56,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:198](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L198)
|
||||
[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:202](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L202)
|
||||
[llm/LLM.ts:240](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L240)
|
||||
|
||||
___
|
||||
|
||||
@@ -76,7 +76,17 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:200](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L200)
|
||||
[llm/LLM.ts:237](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L237)
|
||||
|
||||
___
|
||||
|
||||
### topP
|
||||
|
||||
• **topP**: `number`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:238](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L238)
|
||||
|
||||
## Methods
|
||||
|
||||
@@ -103,7 +113,7 @@ Get a chat response from the LLM
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:294](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L294)
|
||||
[llm/LLM.ts:333](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L333)
|
||||
|
||||
___
|
||||
|
||||
@@ -130,7 +140,7 @@ Get a prompt completion from the LLM
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:317](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L317)
|
||||
[llm/LLM.ts:360](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L360)
|
||||
|
||||
___
|
||||
|
||||
@@ -150,7 +160,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:235](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L235)
|
||||
[llm/LLM.ts:274](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L274)
|
||||
|
||||
___
|
||||
|
||||
@@ -170,7 +180,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:212](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L212)
|
||||
[llm/LLM.ts:251](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L251)
|
||||
|
||||
___
|
||||
|
||||
@@ -190,7 +200,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:224](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L224)
|
||||
[llm/LLM.ts:263](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L263)
|
||||
|
||||
___
|
||||
|
||||
@@ -211,4 +221,4 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:248](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L248)
|
||||
[llm/LLM.ts:287](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L287)
|
||||
|
||||
@@ -22,11 +22,11 @@ OpenAI LLM implementation
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `init?` | `Partial`<[`OpenAI`](OpenAI.md)\> |
|
||||
| `init?` | `Partial`<[`OpenAI`](OpenAI.md)\> & { `azure?`: `AzureOpenAIConfig` } |
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:86](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L86)
|
||||
[llm/LLM.ts:94](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L94)
|
||||
|
||||
## Properties
|
||||
|
||||
@@ -36,7 +36,7 @@ OpenAI LLM implementation
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:79](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L79)
|
||||
[llm/LLM.ts:87](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L87)
|
||||
|
||||
___
|
||||
|
||||
@@ -46,7 +46,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:84](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L84)
|
||||
[llm/LLM.ts:92](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L92)
|
||||
|
||||
___
|
||||
|
||||
@@ -56,7 +56,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:80](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L80)
|
||||
[llm/LLM.ts:88](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L88)
|
||||
|
||||
___
|
||||
|
||||
@@ -66,7 +66,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:76](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L76)
|
||||
[llm/LLM.ts:84](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L84)
|
||||
|
||||
___
|
||||
|
||||
@@ -76,7 +76,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:74](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L74)
|
||||
[llm/LLM.ts:81](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L81)
|
||||
|
||||
___
|
||||
|
||||
@@ -86,7 +86,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:82](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L82)
|
||||
[llm/LLM.ts:90](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L90)
|
||||
|
||||
___
|
||||
|
||||
@@ -96,7 +96,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:75](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L75)
|
||||
[llm/LLM.ts:82](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L82)
|
||||
|
||||
___
|
||||
|
||||
@@ -106,7 +106,17 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:81](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L81)
|
||||
[llm/LLM.ts:89](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L89)
|
||||
|
||||
___
|
||||
|
||||
### topP
|
||||
|
||||
• **topP**: `number`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:83](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L83)
|
||||
|
||||
## Methods
|
||||
|
||||
@@ -133,7 +143,7 @@ Get a chat response from the LLM
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:122](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L122)
|
||||
[llm/LLM.ts:157](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L157)
|
||||
|
||||
___
|
||||
|
||||
@@ -160,7 +170,7 @@ Get a prompt completion from the LLM
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:160](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L160)
|
||||
[llm/LLM.ts:197](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L197)
|
||||
|
||||
___
|
||||
|
||||
@@ -180,4 +190,4 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:105](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L105)
|
||||
[llm/LLM.ts:140](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L140)
|
||||
|
||||
@@ -22,7 +22,7 @@ custom_edit_url: null
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `init?` | `Partial`<[`OpenAIEmbedding`](OpenAIEmbedding.md)\> |
|
||||
| `init?` | `Partial`<[`OpenAIEmbedding`](OpenAIEmbedding.md)\> & { `azure?`: `AzureOpenAIConfig` } |
|
||||
|
||||
#### Overrides
|
||||
|
||||
@@ -30,7 +30,7 @@ custom_edit_url: null
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Embedding.ts:222](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Embedding.ts#L222)
|
||||
[Embedding.ts:229](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Embedding.ts#L229)
|
||||
|
||||
## Properties
|
||||
|
||||
@@ -40,7 +40,7 @@ custom_edit_url: null
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Embedding.ts:217](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Embedding.ts#L217)
|
||||
[Embedding.ts:224](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Embedding.ts#L224)
|
||||
|
||||
___
|
||||
|
||||
@@ -50,7 +50,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Embedding.ts:218](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Embedding.ts#L218)
|
||||
[Embedding.ts:225](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Embedding.ts#L225)
|
||||
|
||||
___
|
||||
|
||||
@@ -60,7 +60,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Embedding.ts:214](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Embedding.ts#L214)
|
||||
[Embedding.ts:221](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Embedding.ts#L221)
|
||||
|
||||
___
|
||||
|
||||
@@ -70,7 +70,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Embedding.ts:220](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Embedding.ts#L220)
|
||||
[Embedding.ts:227](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Embedding.ts#L227)
|
||||
|
||||
___
|
||||
|
||||
@@ -80,7 +80,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Embedding.ts:219](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Embedding.ts#L219)
|
||||
[Embedding.ts:226](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Embedding.ts#L226)
|
||||
|
||||
## Methods
|
||||
|
||||
@@ -100,7 +100,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Embedding.ts:237](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Embedding.ts#L237)
|
||||
[Embedding.ts:270](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Embedding.ts#L270)
|
||||
|
||||
___
|
||||
|
||||
@@ -124,7 +124,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Embedding.ts:253](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Embedding.ts#L253)
|
||||
[Embedding.ts:286](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Embedding.ts#L286)
|
||||
|
||||
___
|
||||
|
||||
@@ -148,7 +148,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Embedding.ts:249](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Embedding.ts#L249)
|
||||
[Embedding.ts:282](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Embedding.ts#L282)
|
||||
|
||||
___
|
||||
|
||||
@@ -174,4 +174,4 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Embedding.ts:197](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Embedding.ts#L197)
|
||||
[Embedding.ts:204](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Embedding.ts#L204)
|
||||
|
||||
@@ -36,7 +36,7 @@ TextNode is the default node type for text. Most common node type in LlamaIndex.
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:144](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L144)
|
||||
[Node.ts:152](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L152)
|
||||
|
||||
## Properties
|
||||
|
||||
@@ -60,7 +60,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:139](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L139)
|
||||
[Node.ts:147](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L147)
|
||||
|
||||
___
|
||||
|
||||
@@ -140,7 +140,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:142](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L142)
|
||||
[Node.ts:150](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L150)
|
||||
|
||||
___
|
||||
|
||||
@@ -164,7 +164,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:138](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L138)
|
||||
[Node.ts:146](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L146)
|
||||
|
||||
___
|
||||
|
||||
@@ -174,7 +174,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:137](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L137)
|
||||
[Node.ts:145](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L145)
|
||||
|
||||
## Accessors
|
||||
|
||||
@@ -314,7 +314,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:149](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L149)
|
||||
[Node.ts:157](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L157)
|
||||
|
||||
___
|
||||
|
||||
@@ -338,7 +338,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:157](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L157)
|
||||
[Node.ts:165](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L165)
|
||||
|
||||
___
|
||||
|
||||
@@ -380,7 +380,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:162](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L162)
|
||||
[Node.ts:170](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L170)
|
||||
|
||||
___
|
||||
|
||||
@@ -399,7 +399,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:187](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L187)
|
||||
[Node.ts:195](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L195)
|
||||
|
||||
___
|
||||
|
||||
@@ -413,7 +413,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:191](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L191)
|
||||
[Node.ts:199](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L199)
|
||||
|
||||
___
|
||||
|
||||
@@ -431,7 +431,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:153](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L153)
|
||||
[Node.ts:161](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L161)
|
||||
|
||||
___
|
||||
|
||||
@@ -455,4 +455,24 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:183](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L183)
|
||||
[Node.ts:191](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L191)
|
||||
|
||||
___
|
||||
|
||||
### toJSON
|
||||
|
||||
▸ **toJSON**(): `Record`<`string`, `any`\>
|
||||
|
||||
Used with built in JSON.stringify
|
||||
|
||||
#### Returns
|
||||
|
||||
`Record`<`string`, `any`\>
|
||||
|
||||
#### Inherited from
|
||||
|
||||
[BaseNode](BaseNode.md).[toJSON](BaseNode.md#tojson)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:136](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L136)
|
||||
|
||||
@@ -46,7 +46,7 @@ The VectorStoreIndex, an index that stores the nodes only according to their vec
|
||||
|
||||
#### Defined in
|
||||
|
||||
[indices/BaseIndex.ts:117](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L117)
|
||||
[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:119](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L119)
|
||||
[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:120](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L120)
|
||||
[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:115](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L115)
|
||||
[indices/BaseIndex.ts:120](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L120)
|
||||
|
||||
___
|
||||
|
||||
@@ -102,13 +102,13 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[indices/BaseIndex.ts:116](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L116)
|
||||
[indices/BaseIndex.ts:121](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L121)
|
||||
|
||||
___
|
||||
|
||||
### vectorStore
|
||||
|
||||
• **vectorStore**: `VectorStore`
|
||||
• **vectorStore**: [`VectorStore`](../interfaces/VectorStore.md)
|
||||
|
||||
#### Overrides
|
||||
|
||||
@@ -187,7 +187,7 @@ Get embeddings for nodes and place them into the index.
|
||||
| :------ | :------ |
|
||||
| `nodes` | [`BaseNode`](BaseNode.md)[] |
|
||||
| `serviceContext` | [`ServiceContext`](../interfaces/ServiceContext.md) |
|
||||
| `vectorStore` | `VectorStore` |
|
||||
| `vectorStore` | [`VectorStore`](../interfaces/VectorStore.md) |
|
||||
| `docStore` | `BaseDocumentStore` |
|
||||
|
||||
#### Returns
|
||||
|
||||
@@ -14,7 +14,7 @@ custom_edit_url: null
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:187](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L187)
|
||||
[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:188](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L188)
|
||||
[llm/LLM.ts:225](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L225)
|
||||
|
||||
___
|
||||
|
||||
@@ -34,4 +34,4 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:189](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L189)
|
||||
[llm/LLM.ts:226](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L226)
|
||||
|
||||
@@ -17,7 +17,7 @@ Default is cosine similarity. Dot product and negative Euclidean distance are al
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Embedding.ts:10](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Embedding.ts#L10)
|
||||
[Embedding.ts:17](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Embedding.ts#L17)
|
||||
|
||||
___
|
||||
|
||||
@@ -27,7 +27,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Embedding.ts:11](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Embedding.ts#L11)
|
||||
[Embedding.ts:18](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Embedding.ts#L18)
|
||||
|
||||
___
|
||||
|
||||
@@ -37,4 +37,4 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Embedding.ts:12](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Embedding.ts#L12)
|
||||
[Embedding.ts:19](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Embedding.ts#L19)
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
---
|
||||
id: "VectorStoreQueryMode"
|
||||
title: "Enumeration: VectorStoreQueryMode"
|
||||
sidebar_label: "VectorStoreQueryMode"
|
||||
sidebar_position: 0
|
||||
custom_edit_url: null
|
||||
---
|
||||
|
||||
## Enumeration Members
|
||||
|
||||
### DEFAULT
|
||||
|
||||
• **DEFAULT** = ``"default"``
|
||||
|
||||
#### Defined in
|
||||
|
||||
[storage/vectorStore/types.ts:12](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L12)
|
||||
|
||||
___
|
||||
|
||||
### HYBRID
|
||||
|
||||
• **HYBRID** = ``"hybrid"``
|
||||
|
||||
#### Defined in
|
||||
|
||||
[storage/vectorStore/types.ts:14](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L14)
|
||||
|
||||
___
|
||||
|
||||
### LINEAR\_REGRESSION
|
||||
|
||||
• **LINEAR\_REGRESSION** = ``"linear_regression"``
|
||||
|
||||
#### Defined in
|
||||
|
||||
[storage/vectorStore/types.ts:18](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L18)
|
||||
|
||||
___
|
||||
|
||||
### LOGISTIC\_REGRESSION
|
||||
|
||||
• **LOGISTIC\_REGRESSION** = ``"logistic_regression"``
|
||||
|
||||
#### Defined in
|
||||
|
||||
[storage/vectorStore/types.ts:17](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L17)
|
||||
|
||||
___
|
||||
|
||||
### MMR
|
||||
|
||||
• **MMR** = ``"mmr"``
|
||||
|
||||
#### Defined in
|
||||
|
||||
[storage/vectorStore/types.ts:20](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L20)
|
||||
|
||||
___
|
||||
|
||||
### SPARSE
|
||||
|
||||
• **SPARSE** = ``"sparse"``
|
||||
|
||||
#### Defined in
|
||||
|
||||
[storage/vectorStore/types.ts:13](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L13)
|
||||
|
||||
___
|
||||
|
||||
### SVM
|
||||
|
||||
• **SVM** = ``"svm"``
|
||||
|
||||
#### Defined in
|
||||
|
||||
[storage/vectorStore/types.ts:16](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L16)
|
||||
+27
-10
@@ -8,8 +8,12 @@ custom_edit_url: null
|
||||
|
||||
# LlamaIndex.TS
|
||||
|
||||
LlamaIndex is a data framework for your LLM application.
|
||||
|
||||
Use your own data with large language models (LLMs, OpenAI ChatGPT and others) in Typescript and Javascript.
|
||||
|
||||
Documentation: https://ts.llamaindex.ai/
|
||||
|
||||
## What is LlamaIndex.TS?
|
||||
|
||||
LlamaIndex.TS aims to be a lightweight, easy to use set of libraries to help you integrate large language models into your applications with your own data.
|
||||
@@ -22,8 +26,11 @@ In a new folder:
|
||||
|
||||
```bash
|
||||
export OPENAI_API_KEY="sk-......" # Replace with your key from https://platform.openai.com/account/api-keys
|
||||
npx tsc –-init # if needed
|
||||
pnpm init
|
||||
pnpm install typescript
|
||||
pnpm exec tsc –-init # if needed
|
||||
pnpm install llamaindex
|
||||
pnpm install @types/node
|
||||
```
|
||||
|
||||
Create the file example.ts
|
||||
@@ -62,28 +69,38 @@ main();
|
||||
Then you can run it using
|
||||
|
||||
```bash
|
||||
npx ts-node example.ts
|
||||
pnpm dlx ts-node example.ts
|
||||
```
|
||||
|
||||
## Playground
|
||||
|
||||
Check out our NextJS playground at https://llama-playground.vercel.app/. The source is available at https://github.com/run-llama/ts-playground
|
||||
|
||||
## Core concepts for getting started:
|
||||
|
||||
- [Document](packages/core/src/Node.ts): A document represents a text file, PDF file or other contiguous piece of data.
|
||||
- [Document](/packages/core/src/Node.ts): A document represents a text file, PDF file or other contiguous piece of data.
|
||||
|
||||
- [Node](packages/core/src/Node.ts): The basic data building block. Most commonly, these are parts of the document split into manageable pieces that are small enough to be fed into an embedding model and LLM.
|
||||
- [Node](/packages/core/src/Node.ts): The basic data building block. Most commonly, these are parts of the document split into manageable pieces that are small enough to be fed into an embedding model and LLM.
|
||||
|
||||
- [Embedding](packages/core/src/Embedding.ts): Embeddings are sets of floating point numbers which represent the data in a Node. By comparing the similarity of embeddings, we can derive an understanding of the similarity of two pieces of data. One use case is to compare the embedding of a question with the embeddings of our Nodes to see which Nodes may contain the data needed to answer that quesiton.
|
||||
- [Embedding](/packages/core/src/Embedding.ts): Embeddings are sets of floating point numbers which represent the data in a Node. By comparing the similarity of embeddings, we can derive an understanding of the similarity of two pieces of data. One use case is to compare the embedding of a question with the embeddings of our Nodes to see which Nodes may contain the data needed to answer that quesiton.
|
||||
|
||||
- [Indices](packages/core/src/indices/): Indices store the Nodes and the embeddings of those nodes. QueryEngines retrieve Nodes from these Indices using embedding similarity.
|
||||
- [Indices](/packages/core/src/indices/): Indices store the Nodes and the embeddings of those nodes. QueryEngines retrieve Nodes from these Indices using embedding similarity.
|
||||
|
||||
- [QueryEngine](packages/core/src/QueryEngine.ts): Query engines are what generate the query you put in and give you back the result. Query engines generally combine a pre-built prompt with selected Nodes from your Index to give the LLM the context it needs to answer your query.
|
||||
- [QueryEngine](/packages/core/src/QueryEngine.ts): Query engines are what generate the query you put in and give you back the result. Query engines generally combine a pre-built prompt with selected Nodes from your Index to give the LLM the context it needs to answer your query.
|
||||
|
||||
- [ChatEngine](packages/core/src/ChatEngine.ts): A ChatEngine helps you build a chatbot that will interact with your Indices.
|
||||
- [ChatEngine](/packages/core/src/ChatEngine.ts): A ChatEngine helps you build a chatbot that will interact with your Indices.
|
||||
|
||||
- [SimplePrompt](packages/core/src/Prompt.ts): A simple standardized function call definition that takes in inputs and formats them in a template literal. SimplePrompts can be specialized using currying and combined using other SimplePrompt functions.
|
||||
- [SimplePrompt](/packages/core/src/Prompt.ts): A simple standardized function call definition that takes in inputs and formats them in a template literal. SimplePrompts can be specialized using currying and combined using other SimplePrompt functions.
|
||||
|
||||
## Supported LLMs:
|
||||
|
||||
- OpenAI GPT-3.5-turbo and GPT-4
|
||||
- Anthropic Claude Instant and Claude 2
|
||||
- Llama2 Chat LLMs (70B, 13B, and 7B parameters)
|
||||
|
||||
## Contributing:
|
||||
|
||||
We are in the very early days of LlamaIndex.TS. If you’re interested in hacking on it with us check out our [contributing guide](CONTRIBUTING.md)
|
||||
We are in the very early days of LlamaIndex.TS. If you’re interested in hacking on it with us check out our [contributing guide](/CONTRIBUTING.md)
|
||||
|
||||
## Bugs? Questions?
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ custom_edit_url: null
|
||||
|
||||
#### Defined in
|
||||
|
||||
[indices/BaseIndex.ts:104](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L104)
|
||||
[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:106](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L106)
|
||||
[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:107](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L107)
|
||||
[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:102](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L102)
|
||||
[indices/BaseIndex.ts:107](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L107)
|
||||
|
||||
___
|
||||
|
||||
@@ -66,14 +66,14 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[indices/BaseIndex.ts:103](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L103)
|
||||
[indices/BaseIndex.ts:108](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L108)
|
||||
|
||||
___
|
||||
|
||||
### vectorStore
|
||||
|
||||
• `Optional` **vectorStore**: `VectorStore`
|
||||
• `Optional` **vectorStore**: [`VectorStore`](VectorStore.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[indices/BaseIndex.ts:105](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L105)
|
||||
[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
|
||||
|
||||
[llm/LLM.ts:21](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L21)
|
||||
[llm/LLM.ts:28](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L28)
|
||||
|
||||
___
|
||||
|
||||
@@ -24,4 +24,4 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:22](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L22)
|
||||
[llm/LLM.ts:29](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L29)
|
||||
|
||||
@@ -14,7 +14,7 @@ custom_edit_url: null
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:28](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L28)
|
||||
[llm/LLM.ts:35](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L35)
|
||||
|
||||
___
|
||||
|
||||
@@ -24,7 +24,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:26](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L26)
|
||||
[llm/LLM.ts:33](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L33)
|
||||
|
||||
___
|
||||
|
||||
@@ -34,4 +34,4 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:27](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L27)
|
||||
[llm/LLM.ts:34](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L34)
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
---
|
||||
id: "ExactMatchFilter"
|
||||
title: "Interface: ExactMatchFilter"
|
||||
sidebar_label: "ExactMatchFilter"
|
||||
sidebar_position: 0
|
||||
custom_edit_url: null
|
||||
---
|
||||
|
||||
## Properties
|
||||
|
||||
### filterType
|
||||
|
||||
• **filterType**: ``"ExactMatch"``
|
||||
|
||||
#### Defined in
|
||||
|
||||
[storage/vectorStore/types.ts:24](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L24)
|
||||
|
||||
___
|
||||
|
||||
### key
|
||||
|
||||
• **key**: `string`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[storage/vectorStore/types.ts:25](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L25)
|
||||
|
||||
___
|
||||
|
||||
### value
|
||||
|
||||
• **value**: `string` \| `number`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[storage/vectorStore/types.ts:26](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L26)
|
||||
@@ -35,7 +35,7 @@ Get a chat response from the LLM
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:42](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L42)
|
||||
[llm/LLM.ts:49](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L49)
|
||||
|
||||
___
|
||||
|
||||
@@ -58,4 +58,4 @@ Get a prompt completion from the LLM
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:48](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L48)
|
||||
[llm/LLM.ts:55](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L55)
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
---
|
||||
id: "MetadataFilters"
|
||||
title: "Interface: MetadataFilters"
|
||||
sidebar_label: "MetadataFilters"
|
||||
sidebar_position: 0
|
||||
custom_edit_url: null
|
||||
---
|
||||
|
||||
## Properties
|
||||
|
||||
### filters
|
||||
|
||||
• **filters**: [`ExactMatchFilter`](ExactMatchFilter.md)[]
|
||||
|
||||
#### Defined in
|
||||
|
||||
[storage/vectorStore/types.ts:30](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L30)
|
||||
@@ -0,0 +1,37 @@
|
||||
---
|
||||
id: "MetadataInfo"
|
||||
title: "Interface: MetadataInfo"
|
||||
sidebar_label: "MetadataInfo"
|
||||
sidebar_position: 0
|
||||
custom_edit_url: null
|
||||
---
|
||||
|
||||
## Properties
|
||||
|
||||
### description
|
||||
|
||||
• **description**: `string`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[storage/vectorStore/types.ts:42](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L42)
|
||||
|
||||
___
|
||||
|
||||
### name
|
||||
|
||||
• **name**: `string`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[storage/vectorStore/types.ts:40](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L40)
|
||||
|
||||
___
|
||||
|
||||
### type
|
||||
|
||||
• **type**: `string`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[storage/vectorStore/types.ts:41](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L41)
|
||||
@@ -16,7 +16,7 @@ A node with an embedding
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:247](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L247)
|
||||
[Node.ts:277](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L277)
|
||||
|
||||
___
|
||||
|
||||
@@ -26,4 +26,4 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:246](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L246)
|
||||
[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:238](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L238)
|
||||
[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:239](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L239)
|
||||
[Node.ts:269](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L269)
|
||||
|
||||
@@ -30,7 +30,7 @@ ___
|
||||
|
||||
### vectorStore
|
||||
|
||||
• **vectorStore**: `VectorStore`
|
||||
• **vectorStore**: [`VectorStore`](VectorStore.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ custom_edit_url: null
|
||||
|
||||
#### Defined in
|
||||
|
||||
[indices/BaseIndex.ts:104](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L104)
|
||||
[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:106](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L106)
|
||||
[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:107](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L107)
|
||||
[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:102](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L102)
|
||||
[indices/BaseIndex.ts:107](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L107)
|
||||
|
||||
___
|
||||
|
||||
@@ -80,13 +80,13 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[indices/BaseIndex.ts:103](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L103)
|
||||
[indices/BaseIndex.ts:108](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L108)
|
||||
|
||||
___
|
||||
|
||||
### vectorStore
|
||||
|
||||
• **vectorStore**: `VectorStore`
|
||||
• **vectorStore**: [`VectorStore`](VectorStore.md)
|
||||
|
||||
#### Overrides
|
||||
|
||||
@@ -94,4 +94,4 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[indices/BaseIndex.ts:157](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L157)
|
||||
[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:151](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L151)
|
||||
[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:150](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L150)
|
||||
[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:149](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L149)
|
||||
[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:152](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L152)
|
||||
[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:153](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L153)
|
||||
[indices/BaseIndex.ts:158](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/indices/BaseIndex.ts#L158)
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
---
|
||||
id: "VectorStore"
|
||||
title: "Interface: VectorStore"
|
||||
sidebar_label: "VectorStore"
|
||||
sidebar_position: 0
|
||||
custom_edit_url: null
|
||||
---
|
||||
|
||||
## Properties
|
||||
|
||||
### isEmbeddingQuery
|
||||
|
||||
• `Optional` **isEmbeddingQuery**: `boolean`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[storage/vectorStore/types.ts:63](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L63)
|
||||
|
||||
___
|
||||
|
||||
### storesText
|
||||
|
||||
• **storesText**: `boolean`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[storage/vectorStore/types.ts:62](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L62)
|
||||
|
||||
## Methods
|
||||
|
||||
### add
|
||||
|
||||
▸ **add**(`embeddingResults`): `Promise`<`string`[]\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `embeddingResults` | [`NodeWithEmbedding`](NodeWithEmbedding.md)[] |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`string`[]\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[storage/vectorStore/types.ts:65](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L65)
|
||||
|
||||
___
|
||||
|
||||
### client
|
||||
|
||||
▸ **client**(): `any`
|
||||
|
||||
#### Returns
|
||||
|
||||
`any`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[storage/vectorStore/types.ts:64](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L64)
|
||||
|
||||
___
|
||||
|
||||
### delete
|
||||
|
||||
▸ **delete**(`refDocId`, `deleteKwargs?`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `refDocId` | `string` |
|
||||
| `deleteKwargs?` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[storage/vectorStore/types.ts:66](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L66)
|
||||
|
||||
___
|
||||
|
||||
### persist
|
||||
|
||||
▸ **persist**(`persistPath`, `fs?`): `Promise`<`void`\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `persistPath` | `string` |
|
||||
| `fs?` | [`GenericFileSystem`](GenericFileSystem.md) |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<`void`\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[storage/vectorStore/types.ts:68](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L68)
|
||||
|
||||
___
|
||||
|
||||
### query
|
||||
|
||||
▸ **query**(`query`, `kwargs?`): `Promise`<[`VectorStoreQueryResult`](VectorStoreQueryResult.md)\>
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `query` | [`VectorStoreQuery`](VectorStoreQuery.md) |
|
||||
| `kwargs?` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<[`VectorStoreQueryResult`](VectorStoreQueryResult.md)\>
|
||||
|
||||
#### Defined in
|
||||
|
||||
[storage/vectorStore/types.ts:67](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L67)
|
||||
@@ -0,0 +1,27 @@
|
||||
---
|
||||
id: "VectorStoreInfo"
|
||||
title: "Interface: VectorStoreInfo"
|
||||
sidebar_label: "VectorStoreInfo"
|
||||
sidebar_position: 0
|
||||
custom_edit_url: null
|
||||
---
|
||||
|
||||
## Properties
|
||||
|
||||
### contentInfo
|
||||
|
||||
• **contentInfo**: `string`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[storage/vectorStore/types.ts:47](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L47)
|
||||
|
||||
___
|
||||
|
||||
### metadataInfo
|
||||
|
||||
• **metadataInfo**: [`MetadataInfo`](MetadataInfo.md)[]
|
||||
|
||||
#### Defined in
|
||||
|
||||
[storage/vectorStore/types.ts:46](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L46)
|
||||
@@ -0,0 +1,87 @@
|
||||
---
|
||||
id: "VectorStoreQuery"
|
||||
title: "Interface: VectorStoreQuery"
|
||||
sidebar_label: "VectorStoreQuery"
|
||||
sidebar_position: 0
|
||||
custom_edit_url: null
|
||||
---
|
||||
|
||||
## Properties
|
||||
|
||||
### alpha
|
||||
|
||||
• `Optional` **alpha**: `number`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[storage/vectorStore/types.ts:56](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L56)
|
||||
|
||||
___
|
||||
|
||||
### docIds
|
||||
|
||||
• `Optional` **docIds**: `string`[]
|
||||
|
||||
#### Defined in
|
||||
|
||||
[storage/vectorStore/types.ts:53](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L53)
|
||||
|
||||
___
|
||||
|
||||
### filters
|
||||
|
||||
• `Optional` **filters**: [`MetadataFilters`](MetadataFilters.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[storage/vectorStore/types.ts:57](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L57)
|
||||
|
||||
___
|
||||
|
||||
### mmrThreshold
|
||||
|
||||
• `Optional` **mmrThreshold**: `number`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[storage/vectorStore/types.ts:58](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L58)
|
||||
|
||||
___
|
||||
|
||||
### mode
|
||||
|
||||
• **mode**: [`VectorStoreQueryMode`](../enums/VectorStoreQueryMode.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[storage/vectorStore/types.ts:55](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L55)
|
||||
|
||||
___
|
||||
|
||||
### queryEmbedding
|
||||
|
||||
• `Optional` **queryEmbedding**: `number`[]
|
||||
|
||||
#### Defined in
|
||||
|
||||
[storage/vectorStore/types.ts:51](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L51)
|
||||
|
||||
___
|
||||
|
||||
### queryStr
|
||||
|
||||
• `Optional` **queryStr**: `string`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[storage/vectorStore/types.ts:54](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L54)
|
||||
|
||||
___
|
||||
|
||||
### similarityTopK
|
||||
|
||||
• **similarityTopK**: `number`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[storage/vectorStore/types.ts:52](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L52)
|
||||
@@ -0,0 +1,37 @@
|
||||
---
|
||||
id: "VectorStoreQueryResult"
|
||||
title: "Interface: VectorStoreQueryResult"
|
||||
sidebar_label: "VectorStoreQueryResult"
|
||||
sidebar_position: 0
|
||||
custom_edit_url: null
|
||||
---
|
||||
|
||||
## Properties
|
||||
|
||||
### ids
|
||||
|
||||
• **ids**: `string`[]
|
||||
|
||||
#### Defined in
|
||||
|
||||
[storage/vectorStore/types.ts:8](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L8)
|
||||
|
||||
___
|
||||
|
||||
### nodes
|
||||
|
||||
• `Optional` **nodes**: [`BaseNode`](../classes/BaseNode.md)[]
|
||||
|
||||
#### Defined in
|
||||
|
||||
[storage/vectorStore/types.ts:6](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L6)
|
||||
|
||||
___
|
||||
|
||||
### similarities
|
||||
|
||||
• **similarities**: `number`[]
|
||||
|
||||
#### Defined in
|
||||
|
||||
[storage/vectorStore/types.ts:7](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L7)
|
||||
@@ -0,0 +1,37 @@
|
||||
---
|
||||
id: "VectorStoreQuerySpec"
|
||||
title: "Interface: VectorStoreQuerySpec"
|
||||
sidebar_label: "VectorStoreQuerySpec"
|
||||
sidebar_position: 0
|
||||
custom_edit_url: null
|
||||
---
|
||||
|
||||
## Properties
|
||||
|
||||
### filters
|
||||
|
||||
• **filters**: [`ExactMatchFilter`](ExactMatchFilter.md)[]
|
||||
|
||||
#### Defined in
|
||||
|
||||
[storage/vectorStore/types.ts:35](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L35)
|
||||
|
||||
___
|
||||
|
||||
### query
|
||||
|
||||
• **query**: `string`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[storage/vectorStore/types.ts:34](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L34)
|
||||
|
||||
___
|
||||
|
||||
### topK
|
||||
|
||||
• `Optional` **topK**: `number`
|
||||
|
||||
#### Defined in
|
||||
|
||||
[storage/vectorStore/types.ts:36](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/storage/vectorStore/types.ts#L36)
|
||||
@@ -15,6 +15,7 @@ custom_edit_url: null
|
||||
- [NodeRelationship](enums/NodeRelationship.md)
|
||||
- [ObjectType](enums/ObjectType.md)
|
||||
- [SimilarityType](enums/SimilarityType.md)
|
||||
- [VectorStoreQueryMode](enums/VectorStoreQueryMode.md)
|
||||
|
||||
## Classes
|
||||
|
||||
@@ -70,8 +71,11 @@ custom_edit_url: null
|
||||
- [ChatMessage](interfaces/ChatMessage.md)
|
||||
- [ChatResponse](interfaces/ChatResponse.md)
|
||||
- [Event](interfaces/Event.md)
|
||||
- [ExactMatchFilter](interfaces/ExactMatchFilter.md)
|
||||
- [GenericFileSystem](interfaces/GenericFileSystem.md)
|
||||
- [LLM](interfaces/LLM.md)
|
||||
- [MetadataFilters](interfaces/MetadataFilters.md)
|
||||
- [MetadataInfo](interfaces/MetadataInfo.md)
|
||||
- [NodeParser](interfaces/NodeParser.md)
|
||||
- [NodeWithEmbedding](interfaces/NodeWithEmbedding.md)
|
||||
- [NodeWithScore](interfaces/NodeWithScore.md)
|
||||
@@ -88,6 +92,11 @@ custom_edit_url: null
|
||||
- [ToolMetadata](interfaces/ToolMetadata.md)
|
||||
- [VectorIndexConstructorProps](interfaces/VectorIndexConstructorProps.md)
|
||||
- [VectorIndexOptions](interfaces/VectorIndexOptions.md)
|
||||
- [VectorStore](interfaces/VectorStore.md)
|
||||
- [VectorStoreInfo](interfaces/VectorStoreInfo.md)
|
||||
- [VectorStoreQuery](interfaces/VectorStoreQuery.md)
|
||||
- [VectorStoreQueryResult](interfaces/VectorStoreQueryResult.md)
|
||||
- [VectorStoreQuerySpec](interfaces/VectorStoreQuerySpec.md)
|
||||
- [WalkableFileSystem](interfaces/WalkableFileSystem.md)
|
||||
|
||||
## Type Aliases
|
||||
@@ -108,7 +117,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:32](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L32)
|
||||
[llm/LLM.ts:39](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L39)
|
||||
|
||||
___
|
||||
|
||||
@@ -138,7 +147,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:13](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L13)
|
||||
[llm/LLM.ts:20](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L20)
|
||||
|
||||
___
|
||||
|
||||
@@ -219,7 +228,7 @@ NOTE 2: we default to empty string to make it easy to calculate prompt sizes
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:168](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L168)
|
||||
[llm/LLM.ts:205](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L205)
|
||||
|
||||
___
|
||||
|
||||
@@ -244,7 +253,7 @@ We currently support GPT-3.5 and GPT-4 models
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:64](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L64)
|
||||
[llm/LLM.ts:71](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L71)
|
||||
|
||||
___
|
||||
|
||||
@@ -300,7 +309,7 @@ ___
|
||||
|
||||
### DEFAULT\_DOC\_STORE\_PERSIST\_FILENAME
|
||||
|
||||
• `Const` **DEFAULT\_DOC\_STORE\_PERSIST\_FILENAME**: ``"docstore.json"``
|
||||
• `Const` **DEFAULT\_DOC\_STORE\_PERSIST\_FILENAME**: ``"doc_store.json"``
|
||||
|
||||
#### Defined in
|
||||
|
||||
@@ -423,7 +432,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:51](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L51)
|
||||
[llm/LLM.ts:58](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L58)
|
||||
|
||||
___
|
||||
|
||||
@@ -442,7 +451,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[llm/LLM.ts:56](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L56)
|
||||
[llm/LLM.ts:63](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/llm/LLM.ts#L63)
|
||||
|
||||
___
|
||||
|
||||
@@ -779,7 +788,7 @@ Get the top K embeddings from a list of embeddings ordered by similarity to the
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Embedding.ts:77](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Embedding.ts#L77)
|
||||
[Embedding.ts:84](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Embedding.ts#L84)
|
||||
|
||||
___
|
||||
|
||||
@@ -795,7 +804,7 @@ ___
|
||||
| `embeddings` | `number`[][] | `undefined` |
|
||||
| `similarityTopK?` | `number` | `undefined` |
|
||||
| `embeddingsIds?` | `any`[] | `undefined` |
|
||||
| `queryMode` | `VectorStoreQueryMode` | `VectorStoreQueryMode.SVM` |
|
||||
| `queryMode` | [`VectorStoreQueryMode`](enums/VectorStoreQueryMode.md) | `VectorStoreQueryMode.SVM` |
|
||||
|
||||
#### Returns
|
||||
|
||||
@@ -803,7 +812,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Embedding.ts:119](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Embedding.ts#L119)
|
||||
[Embedding.ts:126](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Embedding.ts#L126)
|
||||
|
||||
___
|
||||
|
||||
@@ -829,7 +838,7 @@ ___
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Embedding.ts:131](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Embedding.ts#L131)
|
||||
[Embedding.ts:138](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Embedding.ts#L138)
|
||||
|
||||
___
|
||||
|
||||
@@ -853,6 +862,26 @@ ___
|
||||
|
||||
___
|
||||
|
||||
### jsonToNode
|
||||
|
||||
▸ **jsonToNode**(`json`): [`TextNode`](classes/TextNode.md)
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Name | Type |
|
||||
| :------ | :------ |
|
||||
| `json` | `any` |
|
||||
|
||||
#### Returns
|
||||
|
||||
[`TextNode`](classes/TextNode.md)
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Node.ts:243](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Node.ts#L243)
|
||||
|
||||
___
|
||||
|
||||
### messagesToHistoryStr
|
||||
|
||||
▸ **messagesToHistoryStr**(`messages`): `string`
|
||||
@@ -944,7 +973,7 @@ similartiy score with higher numbers meaning the two embeddings are more similar
|
||||
|
||||
#### Defined in
|
||||
|
||||
[Embedding.ts:22](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Embedding.ts#L22)
|
||||
[Embedding.ts:29](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/Embedding.ts#L29)
|
||||
|
||||
___
|
||||
|
||||
|
||||
Generated
-12839
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,32 @@
|
||||
# simple
|
||||
|
||||
## 0.0.15
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [f80b062]
|
||||
- Updated dependencies [b3fec86]
|
||||
- Updated dependencies [b3fec86]
|
||||
- llamaindex@0.0.17
|
||||
|
||||
## 0.0.14
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [ec12633]
|
||||
- Updated dependencies [9214b06]
|
||||
- Updated dependencies [3316c6b]
|
||||
- Updated dependencies [3316c6b]
|
||||
- llamaindex@0.0.16
|
||||
|
||||
## 0.0.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [b501eb5]
|
||||
- Updated dependencies [f9d1a6e]
|
||||
- llamaindex@0.0.15
|
||||
|
||||
## 0.0.12
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import { OpenAI, LlamaDeuce, ChatMessage, DeuceChatStrategy } from "llamaindex";
|
||||
// @ts-ignore
|
||||
import * as readline from "node:readline/promises";
|
||||
import { stdin as input, stdout as output } from "node:process";
|
||||
|
||||
(async () => {
|
||||
const gpt4 = new OpenAI({ model: "gpt-4", temperature: 0.9 });
|
||||
const l2 = new LlamaDeuce({
|
||||
model: "Llama-2-70b-chat-4bit",
|
||||
temperature: 0.9,
|
||||
});
|
||||
|
||||
const rl = readline.createInterface({ input, output });
|
||||
const start = await rl.question("Start: ");
|
||||
const history: ChatMessage[] = [
|
||||
{
|
||||
content:
|
||||
"Prefer shorter answers. Keep your response to 100 words or less.",
|
||||
role: "system",
|
||||
},
|
||||
{ content: start, role: "user" },
|
||||
];
|
||||
|
||||
while (true) {
|
||||
const next = history.length % 2 === 1 ? gpt4 : l2;
|
||||
const r = await next.chat(
|
||||
history.map(({ content, role }) => ({
|
||||
content,
|
||||
role: next === l2 ? role : role === "user" ? "assistant" : "user",
|
||||
}))
|
||||
);
|
||||
history.push({
|
||||
content: r.message.content,
|
||||
role: next === l2 ? "assistant" : "user",
|
||||
});
|
||||
await rl.question((next === l2 ? "Llama: " : "GPT: ") + r.message.content);
|
||||
}
|
||||
})();
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "0.0.12",
|
||||
"version": "0.0.15",
|
||||
"private": true,
|
||||
"name": "simple",
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
import fs from "fs/promises";
|
||||
import {
|
||||
Document,
|
||||
VectorStoreIndex,
|
||||
storageContextFromDefaults,
|
||||
} from "llamaindex";
|
||||
|
||||
async function main() {
|
||||
// Load essay from abramov.txt in Node
|
||||
const essay = await fs.readFile(
|
||||
"node_modules/llamaindex/examples/abramov.txt",
|
||||
"utf-8"
|
||||
);
|
||||
|
||||
// Create Document object with essay
|
||||
const document = new Document({ text: essay });
|
||||
|
||||
// Split text and create embeddings. Store them in a VectorStoreIndex with persistence
|
||||
const storageContext = await storageContextFromDefaults({
|
||||
persistDir: "./storage",
|
||||
});
|
||||
const index = await VectorStoreIndex.fromDocuments([document], {
|
||||
storageContext,
|
||||
});
|
||||
|
||||
// Query the index
|
||||
const queryEngine = index.asQueryEngine();
|
||||
const response = await queryEngine.query(
|
||||
"What did the author do in college?"
|
||||
);
|
||||
|
||||
// Output response
|
||||
console.log(response.toString());
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
@@ -1,15 +1,22 @@
|
||||
import { Document, VectorStoreIndex, storageContextFromDefaults } from "llamaindex";
|
||||
import {
|
||||
Document,
|
||||
VectorStoreIndex,
|
||||
storageContextFromDefaults,
|
||||
} from "llamaindex";
|
||||
import essay from "./essay";
|
||||
|
||||
|
||||
async function main() {
|
||||
// Create Document object with 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
|
||||
const storageContext = await storageContextFromDefaults({ persistDir: "./storage" });
|
||||
const index = await VectorStoreIndex.fromDocuments([document], { storageContext });
|
||||
const storageContext = await storageContextFromDefaults({
|
||||
persistDir: "./storage",
|
||||
});
|
||||
const index = await VectorStoreIndex.fromDocuments([document], {
|
||||
storageContext,
|
||||
});
|
||||
|
||||
// Query the index
|
||||
const queryEngine = index.asQueryEngine();
|
||||
@@ -21,9 +28,14 @@ async function main() {
|
||||
console.log(response.toString());
|
||||
|
||||
// load the index
|
||||
const loadedIndex = await VectorStoreIndex.init({ storageContext });
|
||||
const laodedQueryEngine = loadedIndex.asQueryEngine();
|
||||
const loadedResponse = await laodedQueryEngine.query(
|
||||
const secondStorageContext = await storageContextFromDefaults({
|
||||
persistDir: "./storage",
|
||||
});
|
||||
const loadedIndex = await VectorStoreIndex.init({
|
||||
storageContext: secondStorageContext,
|
||||
});
|
||||
const loadedQueryEngine = loadedIndex.asQueryEngine();
|
||||
const loadedResponse = await loadedQueryEngine.query(
|
||||
"What did the author do growing up?"
|
||||
);
|
||||
console.log(loadedResponse.toString());
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
import { OpenAI, LlamaDeuce, ChatMessage, DeuceChatStrategy } 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 });
|
||||
const l2 = new LlamaDeuce({
|
||||
model: "Llama-2-70b-chat-4bit",
|
||||
temperature: 0.9,
|
||||
});
|
||||
|
||||
const rl = readline.createInterface({ input, output });
|
||||
const start = await rl.question("Start: ");
|
||||
const history: ChatMessage[] = [
|
||||
{
|
||||
content:
|
||||
"Prefer shorter answers. Keep your response to 100 words or less.",
|
||||
role: "system",
|
||||
},
|
||||
{ content: start, role: "user" },
|
||||
];
|
||||
|
||||
while (true) {
|
||||
const next = history.length % 2 === 1 ? gpt4 : l2;
|
||||
const r = await next.chat(
|
||||
history.map(({ content, role }) => ({
|
||||
content,
|
||||
role: next === l2 ? role : role === "user" ? "assistant" : "user",
|
||||
}))
|
||||
);
|
||||
history.push({
|
||||
content: r.message.content,
|
||||
role: next === l2 ? "assistant" : "user",
|
||||
});
|
||||
await rl.question((next === l2 ? "Llama: " : "GPT: ") + r.message.content);
|
||||
}
|
||||
})();
|
||||
Generated
+22
-81
@@ -8,16 +8,16 @@
|
||||
"name": "simple",
|
||||
"version": "0.0.3",
|
||||
"dependencies": {
|
||||
"llamaindex": "^0.0.0-20230730023617"
|
||||
"llamaindex": "latest"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^18"
|
||||
}
|
||||
},
|
||||
"node_modules/@anthropic-ai/sdk": {
|
||||
"version": "0.5.8",
|
||||
"resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-0.5.8.tgz",
|
||||
"integrity": "sha512-iHenjcE2Q/az6VZiP1DueOSvKNRmxsly6Rx2yjJBoy7OBYVFGVjEdgs2mPQHtTX0ibKAR7tPq6F6MQbKDPWcKg==",
|
||||
"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",
|
||||
@@ -30,9 +30,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "18.17.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.17.0.tgz",
|
||||
"integrity": "sha512-GXZxEtOxYGFchyUzxvKI14iff9KZ2DI+A6a37o6EQevtg6uO9t+aUZKcaC1Te5Ng1OnLM7K9NVVj+FbecD9cJg=="
|
||||
"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",
|
||||
@@ -55,39 +55,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/agentkeepalive": {
|
||||
"version": "4.3.0",
|
||||
"resolved": "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-4.3.0.tgz",
|
||||
"integrity": "sha512-7Epl1Blf4Sy37j4v9f9FjICCh4+KAQOyXgHEwlyBiAQLbhKdq/i2QQU3amQalS/wPhdPzDXPL5DMR5bkn+YeWg==",
|
||||
"version": "4.5.0",
|
||||
"resolved": "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-4.5.0.tgz",
|
||||
"integrity": "sha512-5GG/5IbQQpC9FpkRGsSvZI5QYeSCzlJHdpBQntCsuTOxhKD8lqKhrleg2Yi7yvMIf82Ycmmqln9U8V9qwEiJew==",
|
||||
"dependencies": {
|
||||
"debug": "^4.1.0",
|
||||
"depd": "^2.0.0",
|
||||
"humanize-ms": "^1.2.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 8.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/agentkeepalive/node_modules/debug": {
|
||||
"version": "4.3.4",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
|
||||
"integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==",
|
||||
"dependencies": {
|
||||
"ms": "2.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"supports-color": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/agentkeepalive/node_modules/ms": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
|
||||
},
|
||||
"node_modules/asynckit": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
|
||||
@@ -98,25 +75,6 @@
|
||||
"resolved": "https://registry.npmjs.org/base-64/-/base-64-0.1.0.tgz",
|
||||
"integrity": "sha512-Y5gU45svrR5tI2Vt/X9GPd3L0HNIKzGu202EjxrXMpuc2V2CiKgemAbUUsqYmZJvPtCXoUKjNZwBJzsNScUbXA=="
|
||||
},
|
||||
"node_modules/base64-js": {
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
|
||||
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/feross"
|
||||
},
|
||||
{
|
||||
"type": "patreon",
|
||||
"url": "https://www.patreon.com/feross"
|
||||
},
|
||||
{
|
||||
"type": "consulting",
|
||||
"url": "https://feross.org/support"
|
||||
}
|
||||
]
|
||||
},
|
||||
"node_modules/charenc": {
|
||||
"version": "0.0.2",
|
||||
"resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz",
|
||||
@@ -160,14 +118,6 @@
|
||||
"node": ">=0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/depd": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
|
||||
"integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/digest-fetch": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/digest-fetch/-/digest-fetch-1.3.0.tgz",
|
||||
@@ -228,25 +178,16 @@
|
||||
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz",
|
||||
"integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w=="
|
||||
},
|
||||
"node_modules/js-tiktoken": {
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/js-tiktoken/-/js-tiktoken-1.0.7.tgz",
|
||||
"integrity": "sha512-biba8u/clw7iesNEWLOLwrNGoBP2lA+hTaBLs/D45pJdUPFXyxD6nhcDVtADChghv4GgyAiMKYMiRx7x6h7Biw==",
|
||||
"dependencies": {
|
||||
"base64-js": "^1.5.1"
|
||||
}
|
||||
},
|
||||
"node_modules/llamaindex": {
|
||||
"version": "0.0.0-20230730023617",
|
||||
"resolved": "https://registry.npmjs.org/llamaindex/-/llamaindex-0.0.0-20230730023617.tgz",
|
||||
"integrity": "sha512-scBB8s0iboM6LS9zsStxom3UaWd4gBYoC2pbPnX7gZRzgRI3ErFn1cke2tJWG3pqKGg8RYSUus4jltemGHMs/A==",
|
||||
"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.8",
|
||||
"js-tiktoken": "^1.0.7",
|
||||
"@anthropic-ai/sdk": "^0.5.9",
|
||||
"lodash": "^4.17.21",
|
||||
"openai": "4.0.0-beta.6",
|
||||
"openai": "4.0.0-beta.8",
|
||||
"pdf-parse": "^1.1.1",
|
||||
"replicate": "^0.12.3",
|
||||
"replicate": "^0.14.1",
|
||||
"tiktoken-node": "^0.0.6",
|
||||
"uuid": "^9.0.0",
|
||||
"wink-nlp": "^1.14.3"
|
||||
@@ -337,9 +278,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/openai": {
|
||||
"version": "4.0.0-beta.6",
|
||||
"resolved": "https://registry.npmjs.org/openai/-/openai-4.0.0-beta.6.tgz",
|
||||
"integrity": "sha512-sZscRgs6nhBgIt0qcK8XB2PGga6V0Qy9rQn/vKesox/laQDs9tMaOi6rsDhHq15aXQJPROfEB0K9SZoCuyWbSw==",
|
||||
"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",
|
||||
@@ -364,9 +305,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/replicate": {
|
||||
"version": "0.12.3",
|
||||
"resolved": "https://registry.npmjs.org/replicate/-/replicate-0.12.3.tgz",
|
||||
"integrity": "sha512-HVWKPoVhWVTONlWk+lUXmq9Vy2J8MxBJMtDBQq3dA5uq71ZzKTh0xvJfvzW4+VLBjhBeL7tkdua6hZJmKfzAPQ==",
|
||||
"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",
|
||||
|
||||
@@ -1,15 +1,22 @@
|
||||
import { Document, VectorStoreIndex, storageContextFromDefaults } from "llamaindex";
|
||||
import {
|
||||
Document,
|
||||
VectorStoreIndex,
|
||||
storageContextFromDefaults,
|
||||
} from "llamaindex";
|
||||
import essay from "./essay";
|
||||
|
||||
|
||||
async function main() {
|
||||
// Create Document object with 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
|
||||
const storageContext = await storageContextFromDefaults({ persistDir: "./storage" });
|
||||
const index = await VectorStoreIndex.fromDocuments([document], { storageContext });
|
||||
const storageContext = await storageContextFromDefaults({
|
||||
persistDir: "./storage",
|
||||
});
|
||||
const index = await VectorStoreIndex.fromDocuments([document], {
|
||||
storageContext,
|
||||
});
|
||||
|
||||
// Query the index
|
||||
const queryEngine = index.asQueryEngine();
|
||||
@@ -21,9 +28,14 @@ async function main() {
|
||||
console.log(response.toString());
|
||||
|
||||
// load the index
|
||||
const loadedIndex = await VectorStoreIndex.init({ storageContext });
|
||||
const laodedQueryEngine = loadedIndex.asQueryEngine();
|
||||
const loadedResponse = await laodedQueryEngine.query(
|
||||
const secondStorageContext = await storageContextFromDefaults({
|
||||
persistDir: "./storage",
|
||||
});
|
||||
const loadedIndex = await VectorStoreIndex.init({
|
||||
storageContext: secondStorageContext,
|
||||
});
|
||||
const loadedQueryEngine = loadedIndex.asQueryEngine();
|
||||
const loadedResponse = await loadedQueryEngine.query(
|
||||
"What did the author do growing up?"
|
||||
);
|
||||
console.log(loadedResponse.toString());
|
||||
|
||||
+6
-1
@@ -16,7 +16,7 @@
|
||||
"eslint": "^7.32.0",
|
||||
"eslint-config-custom": "workspace:*",
|
||||
"husky": "^8.0.3",
|
||||
"jest": "^29.6.1",
|
||||
"jest": "^29.6.2",
|
||||
"prettier": "^2.8.8",
|
||||
"prettier-plugin-tailwindcss": "^0.3.0",
|
||||
"ts-jest": "^29.1.1",
|
||||
@@ -25,5 +25,10 @@
|
||||
"packageManager": "pnpm@7.15.0",
|
||||
"dependencies": {
|
||||
"@changesets/cli": "^2.26.2"
|
||||
},
|
||||
"pnpm": {
|
||||
"overrides": {
|
||||
"trim": "1.0.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,30 @@
|
||||
# llamaindex
|
||||
|
||||
## 0.0.17
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- f80b062: Breaking: changed default temp to 0.1 matching new Python change by @logan-markewich
|
||||
- b3fec86: Add support for new Replicate 4 bit Llama2 models
|
||||
- b3fec86: Bug fixes for Llama2 Replicate
|
||||
|
||||
## 0.0.16
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- ec12633: Breaking: make vector store abstraction async (thank you @tyre for the PR)
|
||||
- 9214b06: Fix persistence bug (thanks @HenryHengZJ)
|
||||
- 3e52972: Fix Node initializer bug (thank you @tyre for the PR)
|
||||
- 3316c6b: Add Azure OpenAI support
|
||||
- 3316c6b: OpenAI Node v4-beta.8
|
||||
|
||||
## 0.0.15
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- b501eb5: Added Anthropic Claude support
|
||||
- f9d1a6e: Add Top P
|
||||
|
||||
## 0.0.14
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -12,7 +12,7 @@ apps/simple is where the demo code lives
|
||||
|
||||
### Turborepo docs
|
||||
|
||||
You can checkout how Turborepo works using the built in [README-turborepo.md](README-turborepo.md)
|
||||
You can checkout how Turborepo works using the default [README-turborepo.md](/README-turborepo.md)
|
||||
|
||||
## Getting Started
|
||||
|
||||
@@ -41,12 +41,14 @@ To run them, run
|
||||
pnpm run test
|
||||
```
|
||||
|
||||
To write new test cases write them in packages/core/src/tests
|
||||
To write new test cases write them in [packages/core/src/tests](/packages/core/src/tests)
|
||||
|
||||
We use Jest https://jestjs.io/ to write our test cases. Jest comes with a bunch of built in assertions using the expect function: https://jestjs.io/docs/expect
|
||||
|
||||
### Demo applications
|
||||
|
||||
There is an existing ["simple"](/apps/simple/README.md) demos folder with mainly NodeJS scripts. Feel free to add additional demos to that folder. If you would like to try out your changes in the core package with a new demo, you need to run the build command in the README.
|
||||
|
||||
You can create new demo applications in the apps folder. Just run pnpm init in the folder after you create it to create its own package.json
|
||||
|
||||
### Installing packages
|
||||
|
||||
+27
-10
@@ -1,7 +1,11 @@
|
||||
# LlamaIndex.TS
|
||||
|
||||
LlamaIndex is a data framework for your LLM application.
|
||||
|
||||
Use your own data with large language models (LLMs, OpenAI ChatGPT and others) in Typescript and Javascript.
|
||||
|
||||
Documentation: https://ts.llamaindex.ai/
|
||||
|
||||
## What is LlamaIndex.TS?
|
||||
|
||||
LlamaIndex.TS aims to be a lightweight, easy to use set of libraries to help you integrate large language models into your applications with your own data.
|
||||
@@ -14,8 +18,11 @@ In a new folder:
|
||||
|
||||
```bash
|
||||
export OPENAI_API_KEY="sk-......" # Replace with your key from https://platform.openai.com/account/api-keys
|
||||
npx tsc –-init # if needed
|
||||
pnpm init
|
||||
pnpm install typescript
|
||||
pnpm exec tsc –-init # if needed
|
||||
pnpm install llamaindex
|
||||
pnpm install @types/node
|
||||
```
|
||||
|
||||
Create the file example.ts
|
||||
@@ -54,28 +61,38 @@ main();
|
||||
Then you can run it using
|
||||
|
||||
```bash
|
||||
npx ts-node example.ts
|
||||
pnpm dlx ts-node example.ts
|
||||
```
|
||||
|
||||
## Playground
|
||||
|
||||
Check out our NextJS playground at https://llama-playground.vercel.app/. The source is available at https://github.com/run-llama/ts-playground
|
||||
|
||||
## Core concepts for getting started:
|
||||
|
||||
- [Document](packages/core/src/Node.ts): A document represents a text file, PDF file or other contiguous piece of data.
|
||||
- [Document](/packages/core/src/Node.ts): A document represents a text file, PDF file or other contiguous piece of data.
|
||||
|
||||
- [Node](packages/core/src/Node.ts): The basic data building block. Most commonly, these are parts of the document split into manageable pieces that are small enough to be fed into an embedding model and LLM.
|
||||
- [Node](/packages/core/src/Node.ts): The basic data building block. Most commonly, these are parts of the document split into manageable pieces that are small enough to be fed into an embedding model and LLM.
|
||||
|
||||
- [Embedding](packages/core/src/Embedding.ts): Embeddings are sets of floating point numbers which represent the data in a Node. By comparing the similarity of embeddings, we can derive an understanding of the similarity of two pieces of data. One use case is to compare the embedding of a question with the embeddings of our Nodes to see which Nodes may contain the data needed to answer that quesiton.
|
||||
- [Embedding](/packages/core/src/Embedding.ts): Embeddings are sets of floating point numbers which represent the data in a Node. By comparing the similarity of embeddings, we can derive an understanding of the similarity of two pieces of data. One use case is to compare the embedding of a question with the embeddings of our Nodes to see which Nodes may contain the data needed to answer that quesiton.
|
||||
|
||||
- [Indices](packages/core/src/indices/): Indices store the Nodes and the embeddings of those nodes. QueryEngines retrieve Nodes from these Indices using embedding similarity.
|
||||
- [Indices](/packages/core/src/indices/): Indices store the Nodes and the embeddings of those nodes. QueryEngines retrieve Nodes from these Indices using embedding similarity.
|
||||
|
||||
- [QueryEngine](packages/core/src/QueryEngine.ts): Query engines are what generate the query you put in and give you back the result. Query engines generally combine a pre-built prompt with selected Nodes from your Index to give the LLM the context it needs to answer your query.
|
||||
- [QueryEngine](/packages/core/src/QueryEngine.ts): Query engines are what generate the query you put in and give you back the result. Query engines generally combine a pre-built prompt with selected Nodes from your Index to give the LLM the context it needs to answer your query.
|
||||
|
||||
- [ChatEngine](packages/core/src/ChatEngine.ts): A ChatEngine helps you build a chatbot that will interact with your Indices.
|
||||
- [ChatEngine](/packages/core/src/ChatEngine.ts): A ChatEngine helps you build a chatbot that will interact with your Indices.
|
||||
|
||||
- [SimplePrompt](packages/core/src/Prompt.ts): A simple standardized function call definition that takes in inputs and formats them in a template literal. SimplePrompts can be specialized using currying and combined using other SimplePrompt functions.
|
||||
- [SimplePrompt](/packages/core/src/Prompt.ts): A simple standardized function call definition that takes in inputs and formats them in a template literal. SimplePrompts can be specialized using currying and combined using other SimplePrompt functions.
|
||||
|
||||
## Supported LLMs:
|
||||
|
||||
- OpenAI GPT-3.5-turbo and GPT-4
|
||||
- Anthropic Claude Instant and Claude 2
|
||||
- Llama2 Chat LLMs (70B, 13B, and 7B parameters)
|
||||
|
||||
## Contributing:
|
||||
|
||||
We are in the very early days of LlamaIndex.TS. If you’re interested in hacking on it with us check out our [contributing guide](CONTRIBUTING.md)
|
||||
We are in the very early days of LlamaIndex.TS. If you’re interested in hacking on it with us check out our [contributing guide](/CONTRIBUTING.md)
|
||||
|
||||
## Bugs? Questions?
|
||||
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
{
|
||||
"name": "llamaindex",
|
||||
"version": "0.0.14",
|
||||
"version": "0.0.17",
|
||||
"dependencies": {
|
||||
"@anthropic-ai/sdk": "^0.5.8",
|
||||
"js-tiktoken": "^1.0.7",
|
||||
"@anthropic-ai/sdk": "^0.5.9",
|
||||
"lodash": "^4.17.21",
|
||||
"openai": "4.0.0-beta.6",
|
||||
"openai": "4.0.0-beta.8",
|
||||
"pdf-parse": "^1.1.1",
|
||||
"replicate": "^0.12.3",
|
||||
"replicate": "^0.14.1",
|
||||
"tiktoken-node": "^0.0.6",
|
||||
"uuid": "^9.0.0",
|
||||
"wink-nlp": "^1.14.3"
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
import { DEFAULT_SIMILARITY_TOP_K } from "./constants";
|
||||
import {
|
||||
AzureOpenAIConfig,
|
||||
getAzureConfigFromEnv,
|
||||
getAzureModel,
|
||||
getAzureBaseUrl,
|
||||
shouldUseAzure,
|
||||
} from "./llm/azure";
|
||||
import { OpenAISession, getOpenAISession } from "./llm/openai";
|
||||
import { VectorStoreQueryMode } from "./storage/vectorStore/types";
|
||||
|
||||
@@ -219,19 +226,45 @@ export class OpenAIEmbedding extends BaseEmbedding {
|
||||
timeout?: number;
|
||||
session: OpenAISession;
|
||||
|
||||
constructor(init?: Partial<OpenAIEmbedding>) {
|
||||
constructor(init?: Partial<OpenAIEmbedding> & { azure?: AzureOpenAIConfig }) {
|
||||
super();
|
||||
|
||||
this.model = OpenAIEmbeddingModelType.TEXT_EMBED_ADA_002;
|
||||
|
||||
this.apiKey = init?.apiKey ?? undefined;
|
||||
this.maxRetries = init?.maxRetries ?? 10;
|
||||
this.timeout = init?.timeout ?? undefined;
|
||||
this.session = getOpenAISession({
|
||||
apiKey: this.apiKey,
|
||||
maxRetries: this.maxRetries,
|
||||
timeout: this.timeout,
|
||||
});
|
||||
|
||||
if (init?.azure || shouldUseAzure()) {
|
||||
const azureConfig = getAzureConfigFromEnv({
|
||||
...init?.azure,
|
||||
model: getAzureModel(this.model),
|
||||
});
|
||||
|
||||
if (!azureConfig.apiKey) {
|
||||
throw new Error(
|
||||
"Azure API key is required for OpenAI Azure models. Please set the AZURE_OPENAI_KEY environment variable."
|
||||
);
|
||||
}
|
||||
|
||||
this.apiKey = azureConfig.apiKey;
|
||||
this.session =
|
||||
init?.session ??
|
||||
getOpenAISession({
|
||||
azure: true,
|
||||
apiKey: this.apiKey,
|
||||
baseURL: getAzureBaseUrl(azureConfig),
|
||||
maxRetries: this.maxRetries,
|
||||
timeout: this.timeout,
|
||||
defaultQuery: { "api-version": azureConfig.apiVersion },
|
||||
});
|
||||
} else {
|
||||
this.apiKey = init?.apiKey ?? undefined;
|
||||
this.session = getOpenAISession({
|
||||
apiKey: this.apiKey,
|
||||
maxRetries: this.maxRetries,
|
||||
timeout: this.timeout,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private async getOpenAIEmbedding(input: string) {
|
||||
|
||||
@@ -128,6 +128,14 @@ export abstract class BaseNode {
|
||||
hash: this.hash,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Used with built in JSON.stringify
|
||||
* @returns
|
||||
*/
|
||||
toJSON(): Record<string, any> {
|
||||
return { ...this, type: this.getType() };
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,13 +145,15 @@ export class TextNode extends BaseNode {
|
||||
text: string = "";
|
||||
startCharIdx?: number;
|
||||
endCharIdx?: number;
|
||||
sourceNode?: BaseNode;
|
||||
// textTemplate: NOTE write your own formatter if needed
|
||||
// metadataTemplate: NOTE write your own formatter if needed
|
||||
metadataSeparator: string = "\n";
|
||||
|
||||
constructor(init?: Partial<TextNode>) {
|
||||
constructor(init?: Partial<TextNode>, sourceNode?: BaseNode) {
|
||||
super(init);
|
||||
Object.assign(this, init);
|
||||
this.sourceNode = sourceNode;
|
||||
}
|
||||
|
||||
generateHash() {
|
||||
@@ -204,6 +214,11 @@ export class TextNode extends BaseNode {
|
||||
export class IndexNode extends TextNode {
|
||||
indexId: string = "";
|
||||
|
||||
constructor(init?: Partial<IndexNode>) {
|
||||
super(init);
|
||||
Object.assign(this, init);
|
||||
}
|
||||
|
||||
getType(): ObjectType {
|
||||
return ObjectType.INDEX;
|
||||
}
|
||||
@@ -227,6 +242,23 @@ export class Document extends TextNode {
|
||||
}
|
||||
}
|
||||
|
||||
export function jsonToNode(json: any) {
|
||||
if (!json.type) {
|
||||
throw new Error("Node type not found");
|
||||
}
|
||||
|
||||
switch (json.type) {
|
||||
case ObjectType.TEXT:
|
||||
return new TextNode(json);
|
||||
case ObjectType.INDEX:
|
||||
return new IndexNode(json);
|
||||
case ObjectType.DOCUMENT:
|
||||
return new Document(json);
|
||||
default:
|
||||
throw new Error(`Invalid node type: ${json.type}`);
|
||||
}
|
||||
}
|
||||
|
||||
// export class ImageDocument extends Document {
|
||||
// image?: string;
|
||||
// }
|
||||
|
||||
@@ -24,6 +24,4 @@ export * from "./readers/base";
|
||||
export * from "./readers/PDFReader";
|
||||
export * from "./readers/SimpleDirectoryReader";
|
||||
|
||||
export * from "./storage/constants";
|
||||
export * from "./storage/FileSystem";
|
||||
export * from "./storage/StorageContext";
|
||||
export * from "./storage";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Document, BaseNode } from "../Node";
|
||||
import { Document, BaseNode, jsonToNode } from "../Node";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import { BaseRetriever } from "../Retriever";
|
||||
import { ServiceContext } from "../ServiceContext";
|
||||
@@ -74,7 +74,12 @@ export function jsonToIndexStruct(json: any): IndexStruct {
|
||||
return indexList;
|
||||
} else if (json.type === IndexStructType.SIMPLE_DICT) {
|
||||
const indexDict = new IndexDict(json.indexId, json.summary);
|
||||
indexDict.nodesDict = json.nodesDict;
|
||||
indexDict.nodesDict = Object.entries(json.nodesDict).reduce<
|
||||
Record<string, BaseNode>
|
||||
>((acc, [key, value]) => {
|
||||
acc[key] = jsonToNode(value);
|
||||
return acc;
|
||||
}, {});
|
||||
return indexDict;
|
||||
} else {
|
||||
throw new Error(`Unknown index struct type: ${json.type}`);
|
||||
|
||||
@@ -41,7 +41,7 @@ export class VectorIndexRetriever implements BaseRetriever {
|
||||
mode: VectorStoreQueryMode.DEFAULT,
|
||||
similarityTopK: this.similarityTopK,
|
||||
};
|
||||
const result = this.index.vectorStore.query(q);
|
||||
const result = await this.index.vectorStore.query(q);
|
||||
|
||||
let nodesWithScores: NodeWithScore[] = [];
|
||||
for (let i = 0; i < result.ids.length; i++) {
|
||||
|
||||
+154
-58
@@ -9,6 +9,13 @@ import {
|
||||
AnthropicSession,
|
||||
getAnthropicSession,
|
||||
} from "./anthropic";
|
||||
import {
|
||||
AzureOpenAIConfig,
|
||||
getAzureConfigFromEnv,
|
||||
getAzureModel,
|
||||
getAzureBaseUrl,
|
||||
shouldUseAzure,
|
||||
} from "./azure";
|
||||
|
||||
export type MessageType =
|
||||
| "user"
|
||||
@@ -84,23 +91,49 @@ export class OpenAI implements LLM {
|
||||
|
||||
callbackManager?: CallbackManager;
|
||||
|
||||
constructor(init?: Partial<OpenAI>) {
|
||||
constructor(init?: Partial<OpenAI> & { azure?: AzureOpenAIConfig }) {
|
||||
this.model = init?.model ?? "gpt-3.5-turbo";
|
||||
this.temperature = init?.temperature ?? 0;
|
||||
this.temperature = init?.temperature ?? 0.1;
|
||||
this.topP = init?.topP ?? 1;
|
||||
this.maxTokens = init?.maxTokens ?? undefined;
|
||||
|
||||
this.apiKey = init?.apiKey ?? undefined;
|
||||
this.maxRetries = init?.maxRetries ?? 10;
|
||||
this.timeout = init?.timeout ?? undefined; // Default is 60 seconds
|
||||
this.session =
|
||||
init?.session ??
|
||||
getOpenAISession({
|
||||
apiKey: this.apiKey,
|
||||
maxRetries: this.maxRetries,
|
||||
timeout: this.timeout,
|
||||
|
||||
if (init?.azure || shouldUseAzure()) {
|
||||
const azureConfig = getAzureConfigFromEnv({
|
||||
...init?.azure,
|
||||
model: getAzureModel(this.model),
|
||||
});
|
||||
|
||||
if (!azureConfig.apiKey) {
|
||||
throw new Error(
|
||||
"Azure API key is required for OpenAI Azure models. Please set the AZURE_OPENAI_KEY environment variable."
|
||||
);
|
||||
}
|
||||
|
||||
this.apiKey = azureConfig.apiKey;
|
||||
this.session =
|
||||
init?.session ??
|
||||
getOpenAISession({
|
||||
azure: true,
|
||||
apiKey: this.apiKey,
|
||||
baseURL: getAzureBaseUrl(azureConfig),
|
||||
maxRetries: this.maxRetries,
|
||||
timeout: this.timeout,
|
||||
defaultQuery: { "api-version": azureConfig.apiVersion },
|
||||
});
|
||||
} else {
|
||||
this.apiKey = init?.apiKey ?? undefined;
|
||||
this.session =
|
||||
init?.session ??
|
||||
getOpenAISession({
|
||||
apiKey: this.apiKey,
|
||||
maxRetries: this.maxRetries,
|
||||
timeout: this.timeout,
|
||||
});
|
||||
}
|
||||
|
||||
this.callbackManager = init?.callbackManager;
|
||||
}
|
||||
|
||||
@@ -151,9 +184,10 @@ export class OpenAI implements LLM {
|
||||
return { message: { content: message, role } };
|
||||
} else {
|
||||
// Non-streaming
|
||||
const response = await this.session.openai.chat.completions.create(
|
||||
baseRequestParams
|
||||
);
|
||||
const response = await this.session.openai.chat.completions.create({
|
||||
...baseRequestParams,
|
||||
stream: false,
|
||||
});
|
||||
|
||||
const content = response.choices[0].message?.content ?? "";
|
||||
return { message: { content, role: response.choices[0].message.role } };
|
||||
@@ -169,20 +203,42 @@ export class OpenAI implements LLM {
|
||||
}
|
||||
|
||||
export const ALL_AVAILABLE_LLAMADEUCE_MODELS = {
|
||||
"Llama-2-70b-chat": {
|
||||
"Llama-2-70b-chat-old": {
|
||||
contextWindow: 4096,
|
||||
replicateApi:
|
||||
"replicate/llama70b-v2-chat:e951f18578850b652510200860fc4ea62b3b16fac280f83ff32282f87bbd2e48",
|
||||
//^ Previous 70b model. This is also actually 4 bit, although not exllama.
|
||||
},
|
||||
"Llama-2-70b-chat-4bit": {
|
||||
contextWindow: 4096,
|
||||
replicateApi:
|
||||
"replicate/llama70b-v2-chat:2c1608e18606fad2812020dc541930f2d0495ce32eee50074220b87300bc16e1",
|
||||
//^ Model is based off of exllama 4bit.
|
||||
},
|
||||
"Llama-2-13b-chat": {
|
||||
contextWindow: 4096,
|
||||
replicateApi:
|
||||
"a16z-infra/llama13b-v2-chat:df7690f1994d94e96ad9d568eac121aecf50684a0b0963b25a41cc40061269e5",
|
||||
},
|
||||
//^ Last known good 13b non-quantized model. In future versions they add the SYS and INST tags themselves
|
||||
"Llama-2-13b-chat-4bit": {
|
||||
contextWindow: 4096,
|
||||
replicateApi:
|
||||
"a16z-infra/llama13b-v2-chat:2a7f981751ec7fdf87b5b91ad4db53683a98082e9ff7bfd12c8cd5ea85980a52",
|
||||
},
|
||||
"Llama-2-7b-chat": {
|
||||
contextWindow: 4096,
|
||||
replicateApi:
|
||||
"a16z-infra/llama7b-v2-chat:4f0a4744c7295c024a1de15e1a63c880d3da035fa1f49bfd344fe076074c8eea",
|
||||
//^ Last (somewhat) known good 7b non-quantized model. In future versions they add the SYS and INST
|
||||
// tags themselves
|
||||
// https://github.com/replicate/cog-llama-template/commit/fa5ce83912cf82fc2b9c01a4e9dc9bff6f2ef137
|
||||
// Problem is that they fix the max_new_tokens issue in the same commit. :-(
|
||||
},
|
||||
"Llama-2-7b-chat-4bit": {
|
||||
contextWindow: 4096,
|
||||
replicateApi:
|
||||
"a16z-infra/llama7b-v2-chat:4f0b260b6a13eb53a6b1891f089d57c08f41003ae79458be5011303d81a394dc",
|
||||
},
|
||||
};
|
||||
|
||||
@@ -192,6 +248,8 @@ export enum DeuceChatStrategy {
|
||||
METAWBOS = "metawbos",
|
||||
//^ This is not exactly right because SentencePiece puts the BOS and EOS token IDs in after tokenization
|
||||
// Unfortunately any string only API won't support these properly.
|
||||
REPLICATE4BIT = "replicate4bit",
|
||||
//^ To satisfy Replicate's 4 bit models' requirements where they also insert some INST tags
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -206,35 +264,46 @@ export class LlamaDeuce implements LLM {
|
||||
replicateSession: ReplicateSession;
|
||||
|
||||
constructor(init?: Partial<LlamaDeuce>) {
|
||||
this.model = init?.model ?? "Llama-2-70b-chat";
|
||||
this.chatStrategy = init?.chatStrategy ?? DeuceChatStrategy.META;
|
||||
this.temperature = init?.temperature ?? 0.01; // minimum temperature is 0.01 for Replicate endpoint
|
||||
this.model = init?.model ?? "Llama-2-70b-chat-4bit";
|
||||
this.chatStrategy =
|
||||
init?.chatStrategy ??
|
||||
(this.model.endsWith("4bit")
|
||||
? DeuceChatStrategy.REPLICATE4BIT // With the newer A16Z/Replicate models they do the system message themselves.
|
||||
: DeuceChatStrategy.METAWBOS); // With BOS and EOS seems to work best, although they all have problems past a certain point
|
||||
this.temperature = init?.temperature ?? 0.1; // minimum temperature is 0.01 for Replicate endpoint
|
||||
this.topP = init?.topP ?? 1;
|
||||
this.maxTokens = init?.maxTokens ?? undefined; // By default this means it's 500 tokens according to Replicate docs
|
||||
this.maxTokens =
|
||||
init?.maxTokens ??
|
||||
ALL_AVAILABLE_LLAMADEUCE_MODELS[this.model].contextWindow; // For Replicate, the default is 500 tokens which is too low.
|
||||
this.replicateSession = init?.replicateSession ?? new ReplicateSession();
|
||||
}
|
||||
|
||||
mapMessagesToPrompt(messages: ChatMessage[]): string {
|
||||
mapMessagesToPrompt(messages: ChatMessage[]) {
|
||||
if (this.chatStrategy === DeuceChatStrategy.A16Z) {
|
||||
return this.mapMessagesToPromptA16Z(messages);
|
||||
} else if (this.chatStrategy === DeuceChatStrategy.META) {
|
||||
return this.mapMessagesToPromptMeta(messages);
|
||||
} else if (this.chatStrategy === DeuceChatStrategy.METAWBOS) {
|
||||
return this.mapMessagesToPromptMeta(messages, true);
|
||||
return this.mapMessagesToPromptMeta(messages, { withBos: true });
|
||||
} else if (this.chatStrategy === DeuceChatStrategy.REPLICATE4BIT) {
|
||||
return this.mapMessagesToPromptMeta(messages, { replicate4Bit: true });
|
||||
} else {
|
||||
return this.mapMessagesToPromptMeta(messages);
|
||||
}
|
||||
}
|
||||
|
||||
mapMessagesToPromptA16Z(messages: ChatMessage[]): string {
|
||||
return (
|
||||
messages.reduce((acc, message) => {
|
||||
return (
|
||||
(acc && `${acc}\n\n`) +
|
||||
`${this.mapMessageTypeA16Z(message.role)}${message.content}`
|
||||
);
|
||||
}, "") + "\n\nAssistant:"
|
||||
); // Here we're differing from A16Z by omitting the space. Generally spaces at the end of prompts decrease performance due to tokenization
|
||||
mapMessagesToPromptA16Z(messages: ChatMessage[]) {
|
||||
return {
|
||||
prompt:
|
||||
messages.reduce((acc, message) => {
|
||||
return (
|
||||
(acc && `${acc}\n\n`) +
|
||||
`${this.mapMessageTypeA16Z(message.role)}${message.content}`
|
||||
);
|
||||
}, "") + "\n\nAssistant:",
|
||||
//^ Here we're differing from A16Z by omitting the space. Generally spaces at the end of prompts decrease performance due to tokenization
|
||||
systemPrompt: undefined,
|
||||
};
|
||||
}
|
||||
|
||||
mapMessageTypeA16Z(messageType: MessageType): string {
|
||||
@@ -250,7 +319,11 @@ export class LlamaDeuce implements LLM {
|
||||
}
|
||||
}
|
||||
|
||||
mapMessagesToPromptMeta(messages: ChatMessage[], withBos = false): string {
|
||||
mapMessagesToPromptMeta(
|
||||
messages: ChatMessage[],
|
||||
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.
|
||||
|
||||
If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information.`;
|
||||
@@ -263,37 +336,50 @@ If a question does not make any sense, or is not factually coherent, explain why
|
||||
const EOS = "</s>";
|
||||
|
||||
if (messages.length === 0) {
|
||||
return "";
|
||||
return { prompt: "", systemPrompt: undefined };
|
||||
}
|
||||
|
||||
messages = [...messages]; // so we can use shift without mutating the original array
|
||||
|
||||
let systemPrompt = undefined;
|
||||
if (messages[0].role === "system") {
|
||||
const systemMessage = messages.shift()!;
|
||||
|
||||
const systemStr = `${B_SYS}${systemMessage.content}${E_SYS}`;
|
||||
if (replicate4Bit) {
|
||||
systemPrompt = systemMessage.content;
|
||||
} else {
|
||||
const systemStr = `${B_SYS}${systemMessage.content}${E_SYS}`;
|
||||
|
||||
if (messages[1].role !== "user") {
|
||||
throw new Error(
|
||||
"LlamaDeuce: if there is a system message, the second message must be a user message."
|
||||
);
|
||||
// TS Bug: https://github.com/microsoft/TypeScript/issues/9998
|
||||
// @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."
|
||||
);
|
||||
}
|
||||
|
||||
const userContent = messages[0].content;
|
||||
|
||||
messages[0].content = `${systemStr}${userContent}`;
|
||||
}
|
||||
|
||||
const userContent = messages[0].content;
|
||||
|
||||
messages[0].content = `${systemStr}${userContent}`;
|
||||
} else {
|
||||
messages[0].content = `${B_SYS}${DEFAULT_SYSTEM_PROMPT}${E_SYS}${messages[0].content}`;
|
||||
if (!replicate4Bit) {
|
||||
messages[0].content = `${B_SYS}${DEFAULT_SYSTEM_PROMPT}${E_SYS}${messages[0].content}`;
|
||||
}
|
||||
}
|
||||
|
||||
return messages.reduce((acc, message, index) => {
|
||||
if (index % 2 === 0) {
|
||||
return (
|
||||
(withBos ? BOS : "") +
|
||||
`${acc}${B_INST} ${message.content.trim()} ${E_INST}`
|
||||
);
|
||||
} else {
|
||||
return `${acc} ${message.content.trim()} ` + (withBos ? EOS : ""); // Yes, the EOS comes after the space. This is not a mistake.
|
||||
}
|
||||
}, "");
|
||||
return {
|
||||
prompt: messages.reduce((acc, message, index) => {
|
||||
if (index % 2 === 0) {
|
||||
return `${acc}${
|
||||
withBos ? BOS : ""
|
||||
}${B_INST} ${message.content.trim()} ${E_INST}`;
|
||||
} else {
|
||||
return `${acc} ${message.content.trim()} ` + (withBos ? EOS : ""); // Yes, the EOS comes after the space. This is not a mistake.
|
||||
}
|
||||
}, ""),
|
||||
systemPrompt,
|
||||
};
|
||||
}
|
||||
|
||||
async chat(
|
||||
@@ -303,21 +389,31 @@ If a question does not make any sense, or is not factually coherent, explain why
|
||||
const api = ALL_AVAILABLE_LLAMADEUCE_MODELS[this.model]
|
||||
.replicateApi as `${string}/${string}:${string}`;
|
||||
|
||||
const prompt = this.mapMessagesToPrompt(messages);
|
||||
const { prompt, systemPrompt } = this.mapMessagesToPrompt(messages);
|
||||
|
||||
const response = await this.replicateSession.replicate.run(api, {
|
||||
const replicateOptions: any = {
|
||||
input: {
|
||||
prompt,
|
||||
system_prompt: "", // We are already sending the system prompt so set system prompt to empty.
|
||||
max_new_tokens: this.maxTokens,
|
||||
system_prompt: systemPrompt,
|
||||
temperature: this.temperature,
|
||||
top_p: this.topP,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
if (this.model.endsWith("4bit")) {
|
||||
replicateOptions.input.max_new_tokens = this.maxTokens;
|
||||
} else {
|
||||
replicateOptions.input.max_length = this.maxTokens;
|
||||
}
|
||||
|
||||
const response = await this.replicateSession.replicate.run(
|
||||
api,
|
||||
replicateOptions
|
||||
);
|
||||
return {
|
||||
message: {
|
||||
content: (response as Array<string>).join(""),
|
||||
// We need to do this because Replicate returns a list of strings (for streaming functionality which is not exposed by the run function)
|
||||
content: (response as Array<string>).join("").trimStart(),
|
||||
//^ We need to do this because Replicate returns a list of strings (for streaming functionality which is not exposed by the run function)
|
||||
role: "assistant",
|
||||
},
|
||||
};
|
||||
@@ -352,7 +448,7 @@ export class Anthropic implements LLM {
|
||||
|
||||
constructor(init?: Partial<Anthropic>) {
|
||||
this.model = init?.model ?? "claude-2";
|
||||
this.temperature = init?.temperature ?? 0;
|
||||
this.temperature = init?.temperature ?? 0.1;
|
||||
this.topP = init?.topP ?? 0.999; // Per Ben Mann
|
||||
this.maxTokens = init?.maxTokens ?? undefined;
|
||||
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
export interface AzureOpenAIConfig {
|
||||
apiKey?: string;
|
||||
endpoint?: string;
|
||||
apiVersion?: string;
|
||||
deploymentName?: string;
|
||||
}
|
||||
|
||||
// NOTE we're not supporting the legacy models as they're not available for new deployments
|
||||
// https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/legacy-models
|
||||
// If you have a need for them, please open an issue on GitHub
|
||||
|
||||
const ALL_AZURE_OPENAI_CHAT_MODELS = {
|
||||
"gpt-35-turbo": { contextWindow: 4096, openAIModel: "gpt-3.5-turbo" },
|
||||
"gpt-35-turbo-16k": {
|
||||
contextWindow: 16384,
|
||||
openAIModel: "gpt-3.5-turbo-16k",
|
||||
},
|
||||
"gpt-4": { contextWindow: 8192, openAIModel: "gpt-4" },
|
||||
"gpt-4-32k": { contextWindow: 32768, openAIModel: "gpt-4-32k" },
|
||||
};
|
||||
|
||||
const ALL_AZURE_OPENAI_EMBEDDING_MODELS = {
|
||||
"text-embedding-ada-002": {
|
||||
dimensions: 1536,
|
||||
openAIModel: "text-embedding-ada-002",
|
||||
maxTokens: 8191,
|
||||
},
|
||||
};
|
||||
|
||||
const ALL_AZURE_API_VERSIONS = [
|
||||
"2022-12-01",
|
||||
"2023-05-15",
|
||||
"2023-06-01-preview",
|
||||
"2023-07-01-preview",
|
||||
];
|
||||
|
||||
const DEFAULT_API_VERSION = "2023-05-15";
|
||||
//^ NOTE: this will change over time, if you want to pin it, use a specific version
|
||||
|
||||
export function getAzureConfigFromEnv(
|
||||
init?: Partial<AzureOpenAIConfig> & { model?: string }
|
||||
): AzureOpenAIConfig {
|
||||
return {
|
||||
apiKey:
|
||||
init?.apiKey ??
|
||||
process.env.AZURE_OPENAI_KEY ?? // From Azure docs
|
||||
process.env.OPENAI_API_KEY ?? // Python compatible
|
||||
process.env.AZURE_OPENAI_API_KEY, // LCJS compatible
|
||||
endpoint:
|
||||
init?.endpoint ??
|
||||
process.env.AZURE_OPENAI_ENDPOINT ?? // From Azure docs
|
||||
process.env.OPENAI_API_BASE ?? // Python compatible
|
||||
process.env.AZURE_OPENAI_API_INSTANCE_NAME, // LCJS compatible
|
||||
apiVersion:
|
||||
init?.apiVersion ??
|
||||
process.env.AZURE_OPENAI_API_VERSION ?? // From Azure docs
|
||||
process.env.OPENAI_API_VERSION ?? // Python compatible
|
||||
process.env.AZURE_OPENAI_API_VERSION ?? // LCJS compatible
|
||||
DEFAULT_API_VERSION,
|
||||
deploymentName:
|
||||
init?.deploymentName ??
|
||||
process.env.AZURE_OPENAI_DEPLOYMENT ?? // From Azure docs
|
||||
process.env.AZURE_OPENAI_API_DEPLOYMENT_NAME ?? // LCJS compatible
|
||||
init?.model, // Fall back to model name, Python compatible
|
||||
};
|
||||
}
|
||||
|
||||
export function getAzureBaseUrl(config: AzureOpenAIConfig): string {
|
||||
return `${config.endpoint}/openai/deployments/${config.deploymentName}`;
|
||||
}
|
||||
|
||||
export function getAzureModel(openAIModel: string) {
|
||||
for (const [key, value] of Object.entries(
|
||||
ALL_AZURE_OPENAI_EMBEDDING_MODELS
|
||||
)) {
|
||||
if (value.openAIModel === openAIModel) {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
||||
for (const [key, value] of Object.entries(ALL_AZURE_OPENAI_CHAT_MODELS)) {
|
||||
if (value.openAIModel === openAIModel) {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error(`Unknown model: ${openAIModel}`);
|
||||
}
|
||||
|
||||
export function shouldUseAzure() {
|
||||
return (
|
||||
process.env.AZURE_OPENAI_ENDPOINT ||
|
||||
process.env.AZURE_OPENAI_API_INSTANCE_NAME ||
|
||||
process.env.OPENAI_API_TYPE === "azure"
|
||||
);
|
||||
}
|
||||
@@ -1,10 +1,16 @@
|
||||
import OpenAI, { ClientOptions } from "openai";
|
||||
import _ from "lodash";
|
||||
|
||||
export class AzureOpenAI extends OpenAI {
|
||||
protected override authHeaders() {
|
||||
return { "api-key": this.apiKey };
|
||||
}
|
||||
}
|
||||
|
||||
export class OpenAISession {
|
||||
openai: OpenAI;
|
||||
|
||||
constructor(options: ClientOptions = {}) {
|
||||
constructor(options: ClientOptions & { azure?: boolean } = {}) {
|
||||
if (!options.apiKey) {
|
||||
if (typeof process !== undefined) {
|
||||
options.apiKey = process.env.OPENAI_API_KEY;
|
||||
@@ -15,7 +21,11 @@ export class OpenAISession {
|
||||
throw new Error("Set OpenAI Key in OPENAI_API_KEY env variable"); // Overriding OpenAI package's error message
|
||||
}
|
||||
|
||||
this.openai = new OpenAI(options);
|
||||
if (options.azure) {
|
||||
this.openai = new AzureOpenAI(options);
|
||||
} else {
|
||||
this.openai = new OpenAI(options);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +41,9 @@ let defaultOpenAISession: { session: OpenAISession; options: ClientOptions }[] =
|
||||
* @param options
|
||||
* @returns
|
||||
*/
|
||||
export function getOpenAISession(options: ClientOptions = {}) {
|
||||
export function getOpenAISession(
|
||||
options: ClientOptions & { azure?: boolean } = {}
|
||||
) {
|
||||
let session = defaultOpenAISession.find((session) => {
|
||||
return _.isEqual(session.options, options);
|
||||
})?.session;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
export const DEFAULT_COLLECTION = "data";
|
||||
export const DEFAULT_PERSIST_DIR = "./storage";
|
||||
export const DEFAULT_INDEX_STORE_PERSIST_FILENAME = "index_store.json";
|
||||
export const DEFAULT_DOC_STORE_PERSIST_FILENAME = "docstore.json";
|
||||
export const DEFAULT_DOC_STORE_PERSIST_FILENAME = "doc_store.json";
|
||||
export const DEFAULT_VECTOR_STORE_PERSIST_FILENAME = "vector_store.json";
|
||||
export const DEFAULT_GRAPH_STORE_PERSIST_FILENAME = "graph_store.json";
|
||||
export const DEFAULT_NAMESPACE = "docstore";
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
export * from "./constants";
|
||||
export * from "./FileSystem";
|
||||
export * from "./StorageContext";
|
||||
export * from "./vectorStore/types";
|
||||
export { SimpleDocumentStore } from "./docStore/SimpleDocumentStore";
|
||||
export { SimpleIndexStore } from "./indexStore/SimpleIndexStore";
|
||||
export { SimpleVectorStore } from "./vectorStore/SimpleVectorStore";
|
||||
@@ -51,11 +51,11 @@ export class SimpleVectorStore implements VectorStore {
|
||||
return null;
|
||||
}
|
||||
|
||||
get(textId: string): number[] {
|
||||
async get(textId: string): Promise<number[]> {
|
||||
return this.data.embeddingDict[textId];
|
||||
}
|
||||
|
||||
add(embeddingResults: NodeWithEmbedding[]): string[] {
|
||||
async add(embeddingResults: NodeWithEmbedding[]): Promise<string[]> {
|
||||
for (let result of embeddingResults) {
|
||||
this.data.embeddingDict[result.node.id_] = result.embedding;
|
||||
|
||||
@@ -69,13 +69,13 @@ export class SimpleVectorStore implements VectorStore {
|
||||
}
|
||||
|
||||
if (this.persistPath) {
|
||||
this.persist(this.persistPath, this.fs);
|
||||
await this.persist(this.persistPath, this.fs);
|
||||
}
|
||||
|
||||
return embeddingResults.map((result) => result.node.id_);
|
||||
}
|
||||
|
||||
delete(refDocId: string): void {
|
||||
async delete(refDocId: string): Promise<void> {
|
||||
let textIdsToDelete = Object.keys(this.data.textIdToRefDocId).filter(
|
||||
(textId) => this.data.textIdToRefDocId[textId] === refDocId
|
||||
);
|
||||
@@ -83,9 +83,10 @@ export class SimpleVectorStore implements VectorStore {
|
||||
delete this.data.embeddingDict[textId];
|
||||
delete this.data.textIdToRefDocId[textId];
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
query(query: VectorStoreQuery): VectorStoreQueryResult {
|
||||
async query(query: VectorStoreQuery): Promise<VectorStoreQueryResult> {
|
||||
if (!_.isNil(query.filters)) {
|
||||
throw new Error(
|
||||
"Metadata filters not implemented for SimpleVectorStore yet."
|
||||
@@ -137,10 +138,10 @@ export class SimpleVectorStore implements VectorStore {
|
||||
throw new Error(`Invalid query mode: ${query.mode}`);
|
||||
}
|
||||
|
||||
return {
|
||||
return Promise.resolve({
|
||||
similarities: topSimilarities,
|
||||
ids: topIds,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
async persist(
|
||||
|
||||
@@ -21,6 +21,7 @@ export enum VectorStoreQueryMode {
|
||||
}
|
||||
|
||||
export interface ExactMatchFilter {
|
||||
filterType: "ExactMatch";
|
||||
key: string;
|
||||
value: string | number;
|
||||
}
|
||||
@@ -61,8 +62,8 @@ export interface VectorStore {
|
||||
storesText: boolean;
|
||||
isEmbeddingQuery?: boolean;
|
||||
client(): any;
|
||||
add(embeddingResults: NodeWithEmbedding[]): string[];
|
||||
delete(refDocId: string, deleteKwargs?: any): void;
|
||||
query(query: VectorStoreQuery, kwargs?: any): VectorStoreQueryResult;
|
||||
persist(persistPath: string, fs?: GenericFileSystem): void;
|
||||
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>;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,20 @@ module.exports = {
|
||||
"OPENAI_API_KEY",
|
||||
"REPLICATE_API_TOKEN",
|
||||
"ANTHROPIC_API_KEY",
|
||||
|
||||
"AZURE_OPENAI_KEY",
|
||||
"AZURE_OPENAI_ENDPOINT",
|
||||
"AZURE_OPENAI_API_VERSION",
|
||||
"AZURE_OPENAI_DEPLOYMENT",
|
||||
|
||||
"OPENAI_API_BASE",
|
||||
"OPENAI_API_VERSION",
|
||||
"OPENAI_API_TYPE",
|
||||
|
||||
"AZURE_OPENAI_API_KEY",
|
||||
"AZURE_OPENAI_API_INSTANCE_NAME",
|
||||
"AZURE_OPENAI_API_DEPLOYMENT_NAME",
|
||||
|
||||
"DEBUG",
|
||||
"no_proxy",
|
||||
"NO_PROXY",
|
||||
|
||||
Generated
+323
-308
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user