Compare commits

...

63 Commits

Author SHA1 Message Date
github-actions[bot] 469e438741 Release 0.4.1 (#949)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-21 17:26:01 +07:00
Marcus Schiesser 56fabbb4f5 fix: Release env changes to tokenizer (#952) 2024-06-21 16:58:02 +07:00
Alex Yang dfd8cc1ba4 chore: fix new-version script (#950) 2024-06-20 16:34:09 -07:00
Fabian Wimmer cba54061a2 fix: every Llama Parse job being called "blob" (#946)
Co-authored-by: Alex Yang <himself65@outlook.com>
2024-06-20 16:32:20 -07:00
Peter Goldstein ed467a9889 feat: add Anthropic Claude 3.5 Sonnet model (#948) 2024-06-20 16:21:58 -07:00
Alex Yang 3c4791007f fix: groq llm (#947) 2024-06-20 16:19:55 -07:00
Alex Yang 8f16a179c3 chore: fix lock 2024-06-20 12:51:34 -07:00
github-actions[bot] ce3a4cac6c Release 0.4.0 (#923)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-20 12:38:05 -07:00
Alex Yang be46044b98 build: fix check-minor-version.mjs 2024-06-20 12:31:13 -07:00
Alex Yang 154c7f8e36 chore: bump version (#945) 2024-06-20 12:25:59 -07:00
Alex Yang 8b6c2b45a6 chore: fix version release (#937) 2024-06-17 16:42:38 -07:00
Parham Saidi b1a4a74270 docs: updated Bedrock Opus region and added a basic README (#935) 2024-06-17 14:34:14 -07:00
Alex Yang d7fb095fbd refactor: rename directory core to llamaindex (#936) 2024-06-17 14:33:53 -07:00
Alex Yang 58791d4bdd fix: tokenizer type (#934) 2024-06-17 10:34:37 -07:00
Parham Saidi d3b635b193 fix: agents to use chat history (#933) 2024-06-17 10:33:57 -07:00
Marcus Schiesser 436bc41f82 refactor: unify response and agent response (#930) 2024-06-17 09:01:08 -07:00
Vishwasa Navada K 834f49275a docs: fixed the broken link on Getting Started Section (#932) 2024-06-17 22:56:10 +07:00
Marcus Schiesser a44e54f9ec feat: truncate embedding tokens (#918)
Co-authored-by: Alex Yang <himself65@outlook.com>
2024-06-15 02:13:39 +08:00
Wassim Chegham a51ed8dd70 feat: add support for managed identity for Azure OpenAI (#922)
Co-authored-by: Alex Yang <himself65@outlook.com>
2024-06-11 16:32:39 -07:00
Fabian Wimmer c8cfc6c06d fix: LlamaParse json mode returns array + basic example (#914)
Co-authored-by: Marcus Schiesser <marcus.schiesser@googlemail.com>
Co-authored-by: Marcus Schiesser <mail@marcusschiesser.de>
2024-06-11 10:56:52 -07:00
github-actions[bot] 83b2f0b0af Release 0.3.17 (#920)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-11 10:52:40 -07:00
Alex Yang 1a6abb38bc build: community package cleanup before release (#897) 2024-06-11 10:47:35 -07:00
Fabian Wimmer 6bc5bddb59 feat: add new options to LlamaParseReader (#915) 2024-06-11 16:31:01 +07:00
Alex Yang e6d6576b2f chore: use unpdf (#849) 2024-06-10 16:45:09 -07:00
Alex Yang bf25ff6104 fix: polyfill for cloudflare worker (#919) 2024-06-10 14:08:47 -07:00
Talha Jubair Siam 32ad0992cf docs : fix correctness and relevancy example (#913) 2024-06-10 20:19:06 +07:00
Marcus Schiesser af650343d9 fix: remove debugger statement (#917) 2024-06-10 20:14:26 +07:00
Thuc Pham f6f4ca44bd feat: add gpt-4o tool call fail example (#916)
Co-authored-by: Marcus Schiesser <mail@marcusschiesser.de>
2024-06-10 17:29:25 +07:00
github-actions[bot] 9aa918f026 Release 0.3.16 (#896)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-06 07:20:58 -07:00
Marcus Schiesser 00a92cd125 fix: custom reader example 2024-06-06 12:04:27 +02:00
Marcus Schiesser 73819bf19d feat: Unify metadata and ID handling of documents, allow files to be read by Buffer 2024-06-06 11:51:54 +02:00
Marcus Schiesser d10cca28fc chore: use FileReader interface when possible (#912) 2024-06-06 15:37:20 +07:00
Alex Yang 1378ec4e50 feat: set default model to gpt-4o (#911) 2024-06-05 22:44:52 -07:00
Fabian Wimmer 24a9d1e816 feat: add json mode and image retrieval to LlamaParse (#910)
Co-authored-by: Alex Yang <himself65@outlook.com>
2024-06-05 13:50:51 -07:00
Yi Ding b100684bad chore: bump version (#892)
Co-authored-by: Alex Yang <himself65@outlook.com>
2024-06-05 13:50:33 -07:00
Alex Yang c375cd5c6b fix: multiple tool call (#905) 2024-06-05 10:23:41 -07:00
Fabian Wimmer 45952dee59 feat: add parallel processing to SimpleDirectoryReader (#908)
Co-authored-by: Alex Yang <himself65@outlook.com>
Co-authored-by: Marcus Schiesser <mail@marcusschiesser.de>
2024-06-05 23:17:47 +07:00
Marcus Schiesser 6db7f23ec7 Revert "feat: add parallel processing to SimpleDirectoryReader (#883)"
This reverts commit da1f025229.
2024-06-05 13:35:58 +02:00
Marcus Schiesser 0721a84900 fix: ignore empty vector store (#861) 2024-06-04 10:26:16 -07:00
Marcus Schiesser 4d4bd85448 fix: calling tools with large inputs (#901) 2024-06-04 09:07:19 -07:00
Philipp Serrer 11ae9267ae feat: add numCandidates setting to MongoDBAtlasVectorStore for tuning queries (#893)
Co-authored-by: Marcus Schiesser <marcus.schiesser@googlemail.com>
2024-06-04 16:11:54 +07:00
Fabian Wimmer 174cb3e6da docs: update data loader documentation (#900)
Co-authored-by: Alex Yang <himself65@outlook.com>
2024-06-03 13:50:48 -07:00
Alex Yang 5ab5e5191d fix: empty prefix with inputs (#899) 2024-06-03 12:11:57 -07:00
Parham Saidi 54230f0477 feat: Gemini latest GA released models (#898)
Co-authored-by: Alex Yang <himself65@outlook.com>
2024-06-03 11:41:15 -07:00
Oguz Vuruskaner 3d484da1c5 feat: DeepInfra Embeddings implementation (#890)
Co-authored-by: Alex Yang <himself65@outlook.com>
2024-06-03 11:34:07 -07:00
Oguz Vuruskaner 631f0001ef feat: DeepInfra LLM implementation (#894)
Co-authored-by: Alex Yang <himself65@outlook.com>
2024-06-03 11:21:23 -07:00
Alex Yang 060b700e09 chore: fix changelog 2024-06-03 09:53:15 -07:00
justinmann 83c24f4d50 cannot pass embedModel to MongoDBAtlasVectorStore (#887) 2024-06-03 23:08:33 +07:00
Parham Saidi 883266939e feat: Bedrock support added, only for Anthropic models (#847)
Co-authored-by: Alex Yang <himself65@outlook.com>
2024-06-03 09:07:17 -07:00
Philipp Serrer a29d8351c8 fix: setDocumentHash should be async (#868) 2024-06-03 09:05:23 -07:00
Fabian Wimmer da1f025229 feat: add parallel processing to SimpleDirectoryReader (#883)
Co-authored-by: Alex Yang <himself65@outlook.com>
Co-authored-by: Marcus Schiesser <mail@marcusschiesser.de>
2024-06-03 23:01:27 +07:00
Fabian Wimmer 6b1ded41a9 feat: LlamaParse: add gpt4o-mode, invalidate cache, skip diagonal text, update supported file types (#889)
Co-authored-by: Marcus Schiesser <marcus.schiesser@googlemail.com>
2024-06-03 22:22:18 +07:00
github-actions[bot] e01cc053e3 Release 0.3.15 (#884)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-06-03 21:29:46 +07:00
Marcus Schiesser 6e156edb11 feat: use images in context chat engine (#886) 2024-06-03 21:24:43 +07:00
Marcus Schiesser 0b519958e9 chore: downgrade changeset to patch 2024-06-03 11:18:15 +02:00
Philipp Serrer 265976df12 fix: incorrect hash because of missing params in decorator (#891) 2024-05-28 16:05:24 -07:00
Marcus Schiesser 7e1b96a2db fix: default to Settings.llm (#885) 2024-05-24 22:15:09 +07:00
Marcus Schiesser 8e26f753b7 feat: Add retrieval for images using multi-modal messages (#870) 2024-05-24 22:08:20 +07:00
github-actions[bot] 31e3251435 Release 0.3.14 (#878)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-05-23 16:00:09 -07:00
Yi Ding 058c275a72 New azure versions (#877) 2024-05-23 09:27:04 -07:00
Parham Saidi 6ff7576eb9 feature: added the latest gpt-4o to azure (#875) 2024-05-23 09:22:25 -07:00
Parham Saidi 94543decad feature: added latest gemini pro models (#876) 2024-05-23 09:21:52 -07:00
Marcus Schiesser b963782137 docs: reorder installation steps (#869) 2024-05-22 06:54:27 -07:00
434 changed files with 35112 additions and 3422 deletions
+4 -1
View File
@@ -1,3 +1,5 @@
const { join } = require("node:path");
module.exports = {
root: true,
extends: [
@@ -6,7 +8,7 @@ module.exports = {
"plugin:@typescript-eslint/recommended-type-checked-only",
],
parserOptions: {
project: true,
project: join(__dirname, "tsconfig.eslint.json"),
__tsconfigRootDir: __dirname,
},
settings: {
@@ -23,6 +25,7 @@ module.exports = {
ignoreIIFE: true,
},
],
"no-debugger": "error",
"@typescript-eslint/await-thenable": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/ban-types": "off",
+1 -1
View File
@@ -31,6 +31,6 @@ jobs:
- name: Publish @llamaindex/core
run: npx jsr publish --allow-slow-types
working-directory: packages/core
working-directory: packages/llamaindex
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+3 -3
View File
@@ -26,12 +26,12 @@ jobs:
- name: Build tarball
run: |
pnpm pack
working-directory: packages/core
working-directory: packages/llamaindex
- name: Create release
uses: ncipollo/release-action@v1
with:
artifacts: "packages/core/llamaindex-*.tgz"
artifacts: "packages/llamaindex/llamaindex-*.tgz"
name: Release ${{ github.ref }}
bodyFile: "packages/core/CHANGELOG.md"
bodyFile: "packages/llamaindex/CHANGELOG.md"
token: ${{ secrets.GITHUB_TOKEN }}
+8 -7
View File
@@ -71,7 +71,7 @@ jobs:
- name: Build
run: pnpm run build
- name: Use Build For Examples
run: pnpm link ../packages/core/
run: pnpm link ../packages/llamaindex/
working-directory: ./examples
- name: Run Type Check
run: pnpm run type-check
@@ -81,18 +81,19 @@ jobs:
if: failure()
with:
name: typecheck-build-dist
path: ./packages/core/dist
path: ./packages/llamaindex/dist
if-no-files-found: error
e2e-core-examples:
e2e-llamaindex-examples:
strategy:
fail-fast: false
matrix:
packages:
- cloudflare-worker-agent
- nextjs-agent
- nextjs-edge-runtime
- waku-query-engine
# - waku-query-engine
runs-on: ubuntu-latest
name: Build Core Example (${{ matrix.packages }})
name: Build LlamaIndex Example (${{ matrix.packages }})
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
@@ -107,7 +108,7 @@ jobs:
run: pnpm run build
- name: Build ${{ matrix.packages }}
run: pnpm run build
working-directory: packages/core/e2e/examples/${{ matrix.packages }}
working-directory: packages/llamaindex/e2e/examples/${{ matrix.packages }}
typecheck-examples:
runs-on: ubuntu-latest
@@ -131,7 +132,7 @@ jobs:
working-directory: packages/env
- name: Pack llamaindex
run: pnpm pack --pack-destination ${{ runner.temp }}
working-directory: packages/core
working-directory: packages/llamaindex
- name: Install
run: npm add ${{ runner.temp }}/*.tgz
working-directory: ${{ runner.temp }}/examples
+1 -1
View File
@@ -41,7 +41,7 @@ To run them, run
pnpm run test
```
To write new test cases write them in [packages/core/src/tests](/packages/core/src/tests)
To write new test cases write them in [packages/core/src/tests](/packages/llamaindex/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
+7 -7
View File
@@ -194,19 +194,19 @@ Check out our NextJS playground at https://llama-playground.vercel.app/. The sou
## 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/llamaindex/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/llamaindex/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/embeddings/OpenAIEmbedding.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. Because the default service context is OpenAI, the default embedding is `OpenAIEmbedding`. If using different models, say through Ollama, use this [Embedding](/packages/core/src/embeddings/OllamaEmbedding.ts) (see all [here](/packages/core/src/embeddings)).
- [Embedding](/packages/llamaindex/src/embeddings/OpenAIEmbedding.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. Because the default service context is OpenAI, the default embedding is `OpenAIEmbedding`. If using different models, say through Ollama, use this [Embedding](/packages/llamaindex/src/embeddings/OllamaEmbedding.ts) (see all [here](/packages/llamaindex/src/embeddings)).
- [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/llamaindex/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/engines/query/RetrieverQueryEngine.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. To build a query engine from your Index (recommended), use the [`asQueryEngine`](/packages/core/src/indices/BaseIndex.ts) method on your Index. See all query engines [here](/packages/core/src/engines/query).
- [QueryEngine](/packages/llamaindex/src/engines/query/RetrieverQueryEngine.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. To build a query engine from your Index (recommended), use the [`asQueryEngine`](/packages/llamaindex/src/indices/BaseIndex.ts) method on your Index. See all query engines [here](/packages/llamaindex/src/engines/query).
- [ChatEngine](/packages/core/src/engines/chat/SimpleChatEngine.ts): A ChatEngine helps you build a chatbot that will interact with your Indices. See all chat engines [here](/packages/core/src/engines/chat).
- [ChatEngine](/packages/llamaindex/src/engines/chat/SimpleChatEngine.ts): A ChatEngine helps you build a chatbot that will interact with your Indices. See all chat engines [here](/packages/llamaindex/src/engines/chat).
- [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/llamaindex/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.
## Tips when using in non-Node.js environments
+66
View File
@@ -1,5 +1,71 @@
# docs
## 0.0.27
### Patch Changes
- Updated dependencies [3c47910]
- Updated dependencies [ed467a9]
- Updated dependencies [cba5406]
- llamaindex@0.4.1
## 0.0.26
### Patch Changes
- b1a4a74: docs: updated Bedrock Opus region and added a basic README
- Updated dependencies [436bc41]
- Updated dependencies [a44e54f]
- Updated dependencies [a51ed8d]
- Updated dependencies [d3b635b]
- llamaindex@0.4.0
- @llamaindex/examples@0.0.5
## 0.0.25
### Patch Changes
- Updated dependencies [6bc5bdd]
- Updated dependencies [bf25ff6]
- Updated dependencies [e6d6576]
- llamaindex@0.3.17
## 0.0.24
### Patch Changes
- 631f000: feat: DeepInfra LLM implementation
- 8832669: Community bedrock support added
- a29d835: setDocumentHash should be async
- Updated dependencies [11ae926]
- Updated dependencies [631f000]
- Updated dependencies [1378ec4]
- Updated dependencies [6b1ded4]
- Updated dependencies [4d4bd85]
- Updated dependencies [24a9d1e]
- Updated dependencies [45952de]
- Updated dependencies [54230f0]
- Updated dependencies [a29d835]
- Updated dependencies [73819bf]
- llamaindex@0.3.16
## 0.0.23
### Patch Changes
- Updated dependencies [6e156ed]
- Updated dependencies [265976d]
- Updated dependencies [8e26f75]
- llamaindex@0.3.15
## 0.0.22
### Patch Changes
- Updated dependencies [6ff7576]
- Updated dependencies [94543de]
- llamaindex@0.3.14
## 0.0.21
### Patch Changes
@@ -10,21 +10,19 @@ import TSConfigSource from "!!raw-loader!../../../../../examples/tsconfig.json";
One of the most common use-cases for LlamaIndex is Retrieval-Augmented Generation or RAG, in which your data is indexed and selectively retrieved to be given to an LLM as source material for responding to a query. You can learn more about the [concepts behind RAG](../concepts).
## Before you start
## Set up the project
Make sure you have installed LlamaIndex.TS and have an OpenAI key. If you haven't, check out the [installation](../installation) steps.
You can use [other LLMs](../examples/other_llms) via their APIs; if you would prefer to use local models check out our [local LLM example](../../examples/local_llm).
## Set up
In a new folder:
In a new folder, run:
```bash npm2yarn
npm init
npm install -D typescript @types/node
```
Then, check out the [installation](../installation) steps to install LlamaIndex.TS and prepare an OpenAI key.
You can use [other LLMs](../examples/other_llms) via their APIs; if you would prefer to use local models check out our [local LLM example](../../examples/local_llm).
## Run queries
Create the file `example.ts`. This code will
+1 -1
View File
@@ -35,7 +35,7 @@ For more complex applications, our lower-level APIs allow advanced users to cust
`npm install llamaindex`
Our documentation includes [Installation Instructions](./getting_started/installation.mdx) and a [Starter Tutorial](./getting_started/starter.mdx) to build your first application.
Our documentation includes [Installation Instructions](./getting_started/installation.mdx) and a [Starter Tutorial](./getting_started/starter_tutorial/retrieval_augmented_generation.mdx) to build your first application.
Once you're up and running, [High-Level Concepts](./getting_started/concepts.md) has an overview of LlamaIndex's modular architecture. For more hands-on practical examples, look through our Examples section on the sidebar.
+27 -7
View File
@@ -6,6 +6,7 @@ import CodeBlock from "@theme/CodeBlock";
import CodeSource from "!raw-loader!../../../../examples/readers/src/simple-directory-reader";
import CodeSource2 from "!raw-loader!../../../../examples/readers/src/custom-simple-directory-reader";
import CodeSource3 from "!raw-loader!../../../../examples/readers/src/llamaparse";
import CodeSource4 from "!raw-loader!../../../../examples/readers/src/simple-directory-reader-with-llamaparse.ts";
# Loader
@@ -21,11 +22,13 @@ It is a simple reader that reads all files from a directory and its subdirectori
<CodeBlock language="ts">{CodeSource}</CodeBlock>
Currently, it supports reading `.csv`, `.docx`, `.html`, `.md` and `.pdf` files,
but support for other file types is planned.
Currently, it supports reading `.txt`, `.pdf`, `.csv`, `.md`, `.docx`, `.htm`, `.html`, `.jpg`, `.jpeg`, `.png` and `.gif` files, but support for other file types is planned.
Also, you can provide a `defaultReader` as a fallback for files with unsupported extensions.
Or pass new readers for `fileExtToReader` to support more file types.
You can override the default reader for all file types, inlcuding unsupported ones, with the `overrideReader` option.
Additionally, you can override the default reader for specific file types or add support for additional file types with the `fileExtToReader` option.
Also, you can provide a `defaultReader` as a fallback for files with unsupported extensions. By default it is `TextFileReader`.
SimpleDirectoryReader supports up to 9 concurrent requests. Use the `numWorkers` option to set the number of concurrent requests. By default it runs in sequential mode, i.e. set to 1.
<CodeBlock language="ts" showLineNumbers metastring="{8-12,17-21}">
{CodeSource2}
@@ -35,14 +38,31 @@ Or pass new readers for `fileExtToReader` to support more file types.
LlamaParse is an API created by LlamaIndex to efficiently parse files, e.g. it's great at converting PDF tables into markdown.
To use it, first login and get an API key from https://cloud.llamaindex.ai. Make sure to store the key in the environment variable `LLAMA_CLOUD_API_KEY`.
To use it, first login and get an API key from https://cloud.llamaindex.ai. Make sure to store the key as `apiKey` parameter or in the environment variable `LLAMA_CLOUD_API_KEY`.
Then, you can use the `LlamaParseReader` class to read a local PDF file and convert it into a markdown document that can be used by LlamaIndex:
Then, you can use the `LlamaParseReader` class to local files and convert them into a parsed document that can be used by LlamaIndex.
See [LlamaParseReader.ts](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/readers/LlamaParseReader.ts#L6) for a list of supported file types:
<CodeBlock language="ts">{CodeSource3}</CodeBlock>
Alternatively, you can set the [`resultType`](../api/classes/LlamaParseReader.md#resulttype) option to `text` to get the parsed document as a text string.
Additional options can be set with the `LlamaParseReader` constructor:
- `resultType` can be set to `markdown`, `text` or `.json`. Defaults to `text`
- `language` primarly helps with OCR recognition. Defaults to `en`. See [../readers/type.ts](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/core/src/readers/type.ts#L20) for a list of supported languages.
- `parsingInstructions` can help with complicated document structures. See this [LlamaIndex Blog Post](https://www.llamaindex.ai/blog/launching-the-first-genai-native-document-parsing-platform) for an example.
- `skipDiagonalText` set to true to ignore diagonal text.
- `invalidateCache` set to true to ignore the LlamaCloud cache. All document are kept in cache for 48hours after the job was completed to avoid processing the same document twice. Can be useful for testing when trying to re-parse the same document with, e.g. different `parsingInstructions`.
- `gpt4oMode` set to true to use GPT-4o to extract content.
- `gpt4oApiKey` set the GPT-4o API key. Optional. Lowers the cost of parsing by using your own API key. Your OpenAI account will be charged. Can also be set in the environment variable `LLAMA_CLOUD_GPT4O_API_KEY`.
- `numWorkers` as in the python version, is set in `SimpleDirectoryReader`. Default is 1.
## LlamaParse with SimpleDirectoryReader
Below a full example of `LlamaParse` integrated in `SimpleDirectoryReader` with additional options.
<CodeBlock language="ts">{CodeSource4}</CodeBlock>
## API Reference
- [SimpleDirectoryReader](../api/classes/SimpleDirectoryReader.md)
- [LlamaParseReader](../api/classes/LlamaParseReader.md)
@@ -0,0 +1,79 @@
# DeepInfra
To use DeepInfra embeddings, you need to import `DeepInfraEmbedding` from llamaindex.
Check out available embedding models [here](https://deepinfra.com/models/embeddings).
```ts
import {
DeepInfraEmbedding,
Settings,
Document,
VectorStoreIndex,
} from "llamaindex";
// Update Embed Model
Settings.embedModel = new DeepInfraEmbedding();
const document = new Document({ text: essay, id_: "essay" });
const index = await VectorStoreIndex.fromDocuments([document]);
const queryEngine = index.asQueryEngine();
const query = "What is the meaning of life?";
const results = await queryEngine.query({
query,
});
```
By default, DeepInfraEmbedding is using the sentence-transformers/clip-ViT-B-32 model. You can change the model by passing the model parameter to the constructor.
For example:
```ts
import { DeepInfraEmbedding } from "llamaindex";
const model = "intfloat/e5-large-v2";
Settings.embedModel = new DeepInfraEmbedding({
model,
});
```
You can also set the `maxRetries` and `timeout` parameters when initializing `DeepInfraEmbedding` for better control over the request behavior.
For example:
```ts
import { DeepInfraEmbedding, Settings } from "llamaindex";
const model = "intfloat/e5-large-v2";
const maxRetries = 5;
const timeout = 5000; // 5 seconds
Settings.embedModel = new DeepInfraEmbedding({
model,
maxRetries,
timeout,
});
```
Standalone usage:
```ts
import { DeepInfraEmbedding } from "llamaindex";
import { config } from "dotenv";
// For standalone usage, you need to configure DEEPINFRA_API_TOKEN in .env file
config();
const main = async () => {
const model = "intfloat/e5-large-v2";
const embeddings = new DeepInfraEmbedding({ model });
const text = "What is the meaning of life?";
const response = await embeddings.embed([text]);
console.log(response);
};
main();
```
For questions or feedback, please contact us at [feedback@deepinfra.com](mailto:feedback@deepinfra.com)
@@ -21,7 +21,7 @@ export OPENAI_API_KEY=your-api-key
Import the required modules:
```ts
import { CorrectnessEvaluator, OpenAI, Settings } from "llamaindex";
import { CorrectnessEvaluator, OpenAI, Settings, Response } from "llamaindex";
```
Let's setup gpt-4 for better results:
@@ -45,7 +45,7 @@ const evaluator = new CorrectnessEvaluator();
const result = await evaluator.evaluateResponse({
query,
response,
response: new Response(response),
});
console.log(
@@ -21,7 +21,13 @@ export OPENAI_API_KEY=your-api-key
Import the required modules:
```ts
import { RelevancyEvaluator, OpenAI, Settings } from "llamaindex";
import {
RelevancyEvaluator,
OpenAI,
Settings,
Document,
VectorStoreIndex,
} from "llamaindex";
```
Let's setup gpt-4 for better results:
@@ -0,0 +1,62 @@
# Bedrock
## Usage
```ts
import { BEDROCK_MODELS, Bedrock } from "@llamaindex/community";
Settings.llm = new Bedrock({
model: BEDROCK_MODELS.ANTHROPIC_CLAUDE_3_HAIKU,
region: "us-east-1", // can be provided via env AWS_REGION
credentials: {
accessKeyId: "...", // optional and can be provided via env AWS_ACCESS_KEY_ID
secretAccessKey: "...", // optional and can be provided via env AWS_SECRET_ACCESS_KEY
},
});
```
Currently only supports Anthropic models:
```ts
ANTHROPIC_CLAUDE_INSTANT_1 = "anthropic.claude-instant-v1";
ANTHROPIC_CLAUDE_2 = "anthropic.claude-v2";
ANTHROPIC_CLAUDE_2_1 = "anthropic.claude-v2:1";
ANTHROPIC_CLAUDE_3_SONNET = "anthropic.claude-3-sonnet-20240229-v1:0";
ANTHROPIC_CLAUDE_3_HAIKU = "anthropic.claude-3-haiku-20240307-v1:0";
ANTHROPIC_CLAUDE_3_OPUS = "anthropic.claude-3-opus-20240229-v1:0"; // available on us-west-2
ANTHROPIC_CLAUDE_3_5_SONNET = "anthropic.claude-3-5-sonnet-20240620-v1:0";
```
Sonnet, Haiku and Opus are multimodal, image_url only supports base64 data url format, e.g. `data:image/jpeg;base64,SGVsbG8sIFdvcmxkIQ==`
## Full Example
```ts
import { BEDROCK_MODELS, Bedrock } from "llamaindex";
Settings.llm = new Bedrock({
model: BEDROCK_MODELS.ANTHROPIC_CLAUDE_3_HAIKU,
});
async function main() {
const document = new Document({ text: essay, id_: "essay" });
// Load and index documents
const index = await VectorStoreIndex.fromDocuments([document]);
// Create a query engine
const queryEngine = index.asQueryEngine({
retriever,
});
const query = "What is the meaning of life?";
// Query
const response = await queryEngine.query({
query,
});
// Log the response
console.log(response.response);
}
```
@@ -0,0 +1,83 @@
# DeepInfra
Check out available LLMs [here](https://deepinfra.com/models/text-generation).
```ts
import { DeepInfra, Settings } from "llamaindex";
// Get the API key from `DEEPINFRA_API_TOKEN` environment variable
import { config } from "dotenv";
config();
Settings.llm = new DeepInfra();
// Set the API key
apiKey = "YOUR_API_KEY";
Settings.llm = new DeepInfra({ apiKey });
```
You can setup the apiKey on the environment variables, like:
```bash
export DEEPINFRA_API_TOKEN="<YOUR_API_KEY>"
```
## Load and index documents
For this example, we will use a single document. In a real-world scenario, you would have multiple documents to index.
```ts
const document = new Document({ text: essay, id_: "essay" });
const index = await VectorStoreIndex.fromDocuments([document]);
```
## Query
```ts
const queryEngine = index.asQueryEngine();
const query = "What is the meaning of life?";
const results = await queryEngine.query({
query,
});
```
## Full Example
```ts
import { DeepInfra, Document, VectorStoreIndex, Settings } from "llamaindex";
// Use custom LLM
const model = "meta-llama/Meta-Llama-3-8B-Instruct";
Settings.llm = new DeepInfra({ model, temperature: 0 });
async function main() {
const document = new Document({ text: essay, id_: "essay" });
// Load and index documents
const index = await VectorStoreIndex.fromDocuments([document]);
// get retriever
const retriever = index.asRetriever();
// Create a query engine
const queryEngine = index.asQueryEngine({
retriever,
});
const query = "What is the meaning of life?";
// Query
const response = await queryEngine.query({
query,
});
// Log the response
console.log(response.response);
}
```
## Feedback
If you have any feedback, please reach out to us at [feedback@deepinfra.com](mailto:feedback@deepinfra.com)
+1 -1
View File
@@ -167,7 +167,7 @@ const config = {
[
"docusaurus-plugin-typedoc",
{
entryPoints: ["../../packages/core/src/index.ts"],
entryPoints: ["../../packages/llamaindex/src/index.ts"],
tsconfig: "../../tsconfig.json",
readme: "none",
sourceLinkTemplate:
@@ -271,7 +271,7 @@ custom_edit_url: null
### setDocumentHash
`Abstract` **setDocumentHash**(`docId`, `docHash`): `void`
`Abstract` **setDocumentHash**(`docId`, `docHash`): `Promise`<`void`\>
#### Parameters
@@ -271,7 +271,7 @@ custom_edit_url: null
### setDocumentHash
`Abstract` **setDocumentHash**(`docId`, `docHash`): `void`
`Abstract` **setDocumentHash**(`docId`, `docHash`): `Promise`<`void`\>
#### Parameters
@@ -271,7 +271,7 @@ custom_edit_url: null
### setDocumentHash
`Abstract` **setDocumentHash**(`docId`, `docHash`): `void`
`Abstract` **setDocumentHash**(`docId`, `docHash`): `Promise`<`void`\>
#### Parameters
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "docs",
"version": "0.0.21",
"version": "0.0.27",
"private": true,
"scripts": {
"docusaurus": "docusaurus",
@@ -37,7 +37,7 @@
"docusaurus-plugin-typedoc": "^1.0.1",
"typedoc": "^0.25.13",
"typedoc-plugin-markdown": "^4.0.1",
"typescript": "^5.4.5"
"typescript": "^5.5.2"
},
"browserslist": {
"production": [
+10
View File
@@ -1,5 +1,15 @@
# examples
## 0.0.5
### Patch Changes
- Updated dependencies [436bc41]
- Updated dependencies [a44e54f]
- Updated dependencies [a51ed8d]
- Updated dependencies [d3b635b]
- llamaindex@0.4.0
## 0.0.4
### Patch Changes
+64
View File
@@ -0,0 +1,64 @@
import { FunctionTool, OpenAI, OpenAIAgent } from "llamaindex";
const csvData =
"TITLE,RELEASE_YEAR,SCORE,NUMBER_OF_VOTES,DURATION,MAIN_GENRE,MAIN_PRODUCTION\nDavid Attenborough: A Life on Our Planet,2020,9,31180,83,documentary,GB\nInception,2010,8.8,2268288,148,scifi,GB\nForrest Gump,1994,8.8,1994599,142,drama,US\nAnbe Sivam,2003,8.7,20595,160,comedy,IN\nBo Burnham: Inside,2021,8.7,44074,87,comedy,US\nSaving Private Ryan,1998,8.6,1346020,169,drama,US\nDjango Unchained,2012,8.4,1472668,165,western,US\nDangal,2016,8.4,180247,161,action,IN\nBo Burnham: Make Happy,2016,8.4,14356,60,comedy,US\nLouis C.K.: Hilarious,2010,8.4,11973,84,comedy,US\nDave Chappelle: Sticks & Stones,2019,8.4,25687,65,comedy,US\n3 Idiots,2009,8.4,385782,170,comedy,IN\nBlack Friday,2004,8.4,20611,143,crime,IN\nSuper Deluxe,2019,8.4,13680,176,thriller,IN\nWinter on Fire: Ukraine's Fight for Freedom,2015,8.3,17710,98,documentary,UA\nOnce Upon a Time in America,1984,8.3,342335,229,drama,US\nTaxi Driver,1976,8.3,795222,113,crime,US\nLike Stars on Earth,2007,8.3,188234,165,drama,IN\nBo Burnham: What.,2013,8.3,11488,60,comedy,US\nFull Metal Jacket,1987,8.3,723306,116,drama,GB\nWarrior,2011,8.2,463276,140,drama,US\nDrishyam,2015,8.2,79075,163,thriller,IN\nQueen,2014,8.2,64805,146,drama,IN\nPaan Singh Tomar,2012,8.2,35888,135,drama,IN";
const userQuestion = "which are the best comedies after 2010?";
(async () => {
// The agent will succeed if we increase `maxTokens` to 1024
const llm = new OpenAI({ model: "gpt-4-turbo", maxTokens: 256 });
type Input = {
code: string;
};
// initiate fake code interpreter
const interpreterTool = FunctionTool.from<Input>(
({ code }) => {
console.log(
`To answer the user's question, call the following code:\n${code}`,
);
return code;
},
{
name: "interpreter",
description:
"Execute python code in a Jupyter notebook cell and return any result, stdout, stderr, display_data, and error.",
parameters: {
type: "object",
properties: {
code: {
type: "string",
description: "The python code to execute in a single cell.",
},
},
required: ["code"],
},
},
);
const systemPrompt =
"You are a Python interpreter.\n - You are given tasks to complete and you run python code to solve them.\n - The python code runs in a Jupyter notebook. Every time you call $(interpreter) tool, the python code is executed in a separate cell. It's okay to make multiple calls to $(interpreter).\n - Display visualizations using matplotlib or any other visualization library directly in the notebook. Shouldn't save the visualizations to a file, just return the base64 encoded data.\n - You can install any pip package (if it exists) if you need to but the usual packages for data analysis are already preinstalled.\n - You can run any python code you want in a secure environment.";
const agent = new OpenAIAgent({
llm,
tools: [interpreterTool],
systemPrompt,
verbose: true,
});
console.log(`User question: ${userQuestion}\n`);
await agent.chat({
message: [
{
type: "text",
text: userQuestion,
},
{
type: "text",
text: `Use data from following CSV raw contents:\n${csvData}`,
},
],
});
})();
@@ -0,0 +1,74 @@
import { FunctionTool, OpenAI, ToolCallOptions } from "llamaindex";
(async () => {
// The tool call will generate a partial JSON for `gpt-4-turbo`
// See thread: https://community.openai.com/t/gpt-4o-doesnt-consistently-respect-json-schema-on-tool-use/751125/7
const models = ["gpt-4o", "gpt-4-turbo"];
for (const model of models) {
const validJSON = await callLLM({ model });
console.log(
`LLM call resulting in large tool input with '${model}': LLM generates ${validJSON ? "valid" : "invalid"} JSON.`,
);
}
})();
async function callLLM(init: Partial<OpenAI>) {
const csvData =
"Country,Average Height (cm)\nNetherlands,156\nDenmark,158\nNorway,160";
const userQuestion = "Describe data in this csv";
// fake code interpreter tool
const interpreterTool = FunctionTool.from(
({ code }: { code: string }) => code,
{
name: "interpreter",
description:
"Execute python code in a Jupyter notebook cell and return any result, stdout, stderr, display_data, and error.",
parameters: {
type: "object",
properties: {
code: {
type: "string",
description: "The python code to execute in a single cell.",
},
},
required: ["code"],
},
},
);
const systemPrompt =
"You are a Python interpreter.\n- You are given tasks to complete and you run python code to solve them.\n- The python code runs in a Jupyter notebook. Every time you call $(interpreter) tool, the python code is executed in a separate cell. It's okay to make multiple calls to $(interpreter).\n- Display visualizations using matplotlib or any other visualization library directly in the notebook. Shouldn't save the visualizations to a file, just return the base64 encoded data.\n- You can install any pip package (if it exists) if you need to but the usual packages for data analysis are already preinstalled.\n- You can run any python code you want in a secure environment.";
const llm = new OpenAI(init);
const response = await llm.chat({
tools: [interpreterTool],
messages: [
{ role: "system", content: systemPrompt },
{
role: "user",
content: [
{
type: "text",
text: userQuestion,
},
{
type: "text",
text: `Use data from following CSV raw contents:\n${csvData}`,
},
],
},
],
});
const options = response.message?.options as ToolCallOptions;
const input = options.toolCall[0].input as string;
try {
JSON.parse(input);
return true;
} catch {
return false;
}
}
+1 -1
View File
@@ -53,7 +53,7 @@ async function main() {
message: "How much is 5 + 5? then divide by 2",
});
console.log(response.response.message);
console.log(response.message);
}
void main().then(() => {
+1 -1
View File
@@ -68,7 +68,7 @@ async function main() {
});
// Chat with the agent
const { response } = await agent.chat({
const response = await agent.chat({
message: "Divide 16 by 2 then add 20",
});
+1 -1
View File
@@ -31,7 +31,7 @@ async function main() {
tools: [queryEngineTool],
});
const { response } = await agent.chat({
const response = await agent.chat({
message: "What was his salary?",
});
+1 -3
View File
@@ -68,9 +68,7 @@ async function main() {
console.log("Response:");
for await (const {
response: { delta },
} of stream) {
for await (const { delta } of stream) {
process.stdout.write(delta);
}
}
+1 -3
View File
@@ -16,9 +16,7 @@ async function main() {
stream: true,
});
for await (const {
response: { delta },
} of response) {
for await (const { delta } of response) {
process.stdout.write(delta);
}
}
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
Binary file not shown.
+19
View File
@@ -0,0 +1,19 @@
import { DeepInfra } from "llamaindex";
(async () => {
if (!process.env.DEEPINFRA_API_TOKEN) {
throw new Error("Please set the DEEPINFRA_API_TOKEN environment variable.");
}
const deepinfra = new DeepInfra({});
const result = await deepinfra.chat({
messages: [
{ content: "You want to talk in rhymes.", role: "system" },
{
content:
"How much wood would a woodchuck chuck if a woodchuck could chuck wood?",
role: "user",
},
],
});
console.log(result);
})();
+17
View File
@@ -0,0 +1,17 @@
import { DeepInfraEmbedding } from "llamaindex";
async function main() {
// API token can be provided as an environment variable too
// using DEEPINFRA_API_TOKEN variable
const apiToken = "YOUR_API_TOKEN" ?? process.env.DEEPINFRA_API_TOKEN;
const model = "BAAI/bge-large-en-v1.5";
const embedModel = new DeepInfraEmbedding({
model,
apiToken,
});
const texts = ["hello", "world"];
const embeddings = await embedModel.getTextEmbeddingsBatch(texts);
console.log(`\nWe have ${embeddings.length} embeddings`);
}
main().catch(console.error);
+1 -1
View File
@@ -35,4 +35,4 @@ async function main() {
console.log(response.response);
}
await main();
main().catch(console.error);
+54
View File
@@ -0,0 +1,54 @@
// call pnpm tsx multimodal/load.ts first to init the storage
import {
ContextChatEngine,
NodeWithScore,
ObjectType,
OpenAI,
RetrievalEndEvent,
Settings,
VectorStoreIndex,
} from "llamaindex";
import { getStorageContext } from "./storage";
// Update chunk size and overlap
Settings.chunkSize = 512;
Settings.chunkOverlap = 20;
// Update llm
Settings.llm = new OpenAI({ model: "gpt-4-turbo", maxTokens: 512 });
// Update callbackManager
Settings.callbackManager.on("retrieve-end", (event: RetrievalEndEvent) => {
const { nodes, query } = event.detail.payload;
const imageNodes = nodes.filter(
(node: NodeWithScore) => node.node.type === ObjectType.IMAGE_DOCUMENT,
);
const textNodes = nodes.filter(
(node: NodeWithScore) => node.node.type === ObjectType.TEXT,
);
console.log(
`Retrieved ${textNodes.length} text nodes and ${imageNodes.length} image nodes for query: ${query}`,
);
});
async function main() {
const storageContext = await getStorageContext();
const index = await VectorStoreIndex.init({
storageContext,
});
// topK for text is 0 and for image 1 => we only retrieve one image and no text based on the query
const retriever = index.asRetriever({ topK: { TEXT: 0, IMAGE: 1 } });
// NOTE: we set the contextRole to "user" (default is "system"). The reason is that GPT-4 does not support
// images in a system message
const chatEngine = new ContextChatEngine({ retriever, contextRole: "user" });
// the ContextChatEngine will use the Clip embedding to retrieve the closest image
// (the lady in the chair) and use it in the context for the query
const response = await chatEngine.chat({
message: "What is the name of the painting with the lady in the chair?",
});
console.log(response.response, "\n");
}
main().catch(console.error);
+6 -8
View File
@@ -1,5 +1,4 @@
import {
ImageType,
MultiModalResponseSynthesizer,
OpenAI,
RetrievalEndEvent,
@@ -22,8 +21,6 @@ Settings.callbackManager.on("retrieve-end", (event: RetrievalEndEvent) => {
});
async function main() {
const images: ImageType[] = [];
const storageContext = await getStorageContext();
const index = await VectorStoreIndex.init({
nodes: [],
@@ -34,13 +31,14 @@ async function main() {
responseSynthesizer: new MultiModalResponseSynthesizer(),
retriever: index.asRetriever({ topK: { TEXT: 3, IMAGE: 1 } }),
});
const result = await queryEngine.query({
const stream = await queryEngine.query({
query: "Tell me more about Vincent van Gogh's famous paintings",
stream: true,
});
console.log(result.response, "\n");
images.forEach((image) =>
console.log(`Image retrieved and used in inference: ${image.toString()}`),
);
for await (const chunk of stream) {
process.stdout.write(chunk.response);
}
process.stdout.write("\n");
}
main().catch(console.error);
+11 -11
View File
@@ -1,26 +1,26 @@
{
"name": "@llamaindex/examples",
"private": true,
"version": "0.0.4",
"version": "0.0.5",
"dependencies": {
"@aws-crypto/sha256-js": "^5.2.0",
"@datastax/astra-db-ts": "^1.1.0",
"@datastax/astra-db-ts": "^1.2.1",
"@notionhq/client": "^2.2.15",
"@pinecone-database/pinecone": "^2.2.0",
"@pinecone-database/pinecone": "^2.2.2",
"@zilliz/milvus2-sdk-node": "^2.4.2",
"chromadb": "^1.7.3",
"commander": "^12.0.0",
"chromadb": "^1.8.1",
"commander": "^12.1.0",
"dotenv": "^16.4.5",
"js-tiktoken": "^1.0.11",
"llamaindex": "*",
"mongodb": "^6.6.1",
"js-tiktoken": "^1.0.12",
"llamaindex": "^0.4.0",
"mongodb": "^6.7.0",
"pathe": "^1.1.2"
},
"devDependencies": {
"@types/node": "^20.12.11",
"@types/node": "^20.14.1",
"ts-node": "^10.9.2",
"tsx": "^4.9.3",
"typescript": "^5.4.5"
"tsx": "^4.15.6",
"typescript": "^5.5.2"
},
"scripts": {
"lint": "eslint ."
+4 -3
View File
@@ -11,14 +11,15 @@
"start:pdf": "node --import tsx ./src/pdf.ts",
"start:llamaparse": "node --import tsx ./src/llamaparse.ts",
"start:notion": "node --import tsx ./src/notion.ts",
"start:llamaparse2": "node --import tsx ./src/llamaparse_2.ts"
"start:llamaparse-dir": "node --import tsx ./src/simple-directory-reader-with-llamaparse.ts",
"start:llamaparse-json": "node --import tsx ./src/llamaparse-json.ts"
},
"dependencies": {
"llamaindex": "*"
},
"devDependencies": {
"@types/node": "^20.12.11",
"tsx": "^4.9.3",
"typescript": "^5.4.5"
"tsx": "^4.15.6",
"typescript": "^5.5.2"
}
}
@@ -1,12 +1,13 @@
import type { BaseReader, Document, Metadata } from "llamaindex";
import type { Document, Metadata } from "llamaindex";
import { FileReader } from "llamaindex";
import {
FILE_EXT_TO_READER,
SimpleDirectoryReader,
} from "llamaindex/readers/SimpleDirectoryReader";
import { TextFileReader } from "llamaindex/readers/TextFileReader";
class ZipReader implements BaseReader {
loadData(...args: any[]): Promise<Document<Metadata>[]> {
class ZipReader extends FileReader {
loadDataAsContent(fileContent: Buffer): Promise<Document<Metadata>[]> {
throw new Error("Implement me");
}
}
+30
View File
@@ -0,0 +1,30 @@
import fs from "fs/promises";
import { LlamaParseReader } from "llamaindex";
async function main() {
// Load PDF using LlamaParse json mode
const reader = new LlamaParseReader({ resultType: "json" });
const jsonObjs = await reader.loadJson("../data/uber_10q_march_2022.pdf");
// Write the JSON objects to a file
try {
await fs.writeFile("jsonObjs.json", JSON.stringify(jsonObjs, null, 4));
console.log("Array of JSON objects has been written to jsonObjs.json");
} catch (e) {
console.error("Error writing jsonObjs.json", e);
}
const jsonList = jsonObjs[0]["pages"];
// Write the list of JSON objects as a single array to a file
try {
await fs.writeFile("jsonList.json", JSON.stringify(jsonList, null, 4));
console.log(
"List of JSON objects as single array has been written to jsonList.json",
);
} catch (e) {
console.error("Error writing jsonList.json", e);
}
}
main().catch(console.error);
-26
View File
@@ -1,26 +0,0 @@
import fs from "fs/promises";
import { LlamaParseReader } from "llamaindex";
async function main() {
// Load PDF using LlamaParse. set apiKey here or in environment variable LLAMA_CLOUD_API_KEY
const reader = new LlamaParseReader({
resultType: "markdown",
language: "en",
parsingInstruction:
"The provided document is a manga comic book. Most pages do NOT have title. It does not contain tables. Try to reconstruct the dialogue happening in a cohesive way. Output any math equation in LATEX markdown (between $$)",
});
const documents = await reader.loadData("../data/manga.pdf"); // The manga.pdf in the data folder is just a copy of the TOS, due to copyright laws. You have to place your own. I used "The Manga Guide to Calculus" by Hiroyuki Kojima
// Assuming documents contain an array of pages or sections
const parsedManga = documents.map((page) => page.text).join("\n---\n");
// Output the parsed manga to .md file. Will be placed in ../example/readers/
try {
await fs.writeFile("./parsedManga.md", parsedManga);
console.log("Output successfully written to parsedManga.md");
} catch (err) {
console.error("Error writing to file:", err);
}
}
main().catch(console.error);
@@ -0,0 +1,35 @@
import {
LlamaParseReader,
SimpleDirectoryReader,
VectorStoreIndex,
} from "llamaindex";
async function main() {
const reader = new SimpleDirectoryReader();
const docs = await reader.loadData({
directoryPath: "../data/parallel", // brk-2022.pdf split into 6 parts
numWorkers: 2,
// set LlamaParse as the default reader for all file types. Set apiKey here or in environment variable LLAMA_CLOUD_API_KEY
overrideReader: new LlamaParseReader({
language: "en",
resultType: "markdown",
parsingInstruction:
"The provided files is Berkshire Hathaway's 2022 Annual Report. They contain figures, tables and raw data. Capture the data in a structured format. Mathematical equation should be put out as LATEX markdown (between $$).",
}),
});
const index = await VectorStoreIndex.fromDocuments(docs);
// Query the index
const queryEngine = index.asQueryEngine();
const response = await queryEngine.query({
query:
"What is the general strategy for shareholder safety outlined in the report? Use a concrete example with numbers",
});
// Output response
console.log(response.toString());
}
main().catch(console.error);
+10 -10
View File
@@ -14,25 +14,25 @@
"type-check": "tsc -b --diagnostics",
"release": "pnpm run check-minor-version && pnpm run build:release && changeset publish",
"release-snapshot": "pnpm run check-minor-version && pnpm run build:release && changeset publish --tag snapshot",
"check-minor-version": "node ./scripts/check-minor-version",
"new-version": "changeset version && pnpm run check-minor-version && pnpm format:write && pnpm run build:release",
"check-minor-version": "node ./scripts/check-minor-version.mjs",
"new-version": "changeset version && pnpm run check-minor-version && pnpm format:write && pnpm install && pnpm run build:release",
"new-snapshot": "pnpm run build:release && changeset version --snapshot"
},
"devDependencies": {
"@changesets/cli": "^2.27.1",
"@typescript-eslint/eslint-plugin": "^7.8.0",
"@changesets/cli": "^2.27.5",
"@typescript-eslint/eslint-plugin": "^7.13.1",
"eslint": "^8.57.0",
"eslint-config-next": "^14.2.3",
"eslint-config-next": "^14.2.4",
"eslint-config-prettier": "^9.1.0",
"eslint-config-turbo": "^1.13.3",
"eslint-config-turbo": "^1.13.4",
"eslint-plugin-react": "7.34.1",
"husky": "^9.0.11",
"lint-staged": "^15.2.2",
"lint-staged": "^15.2.7",
"madge": "^7.0.0",
"prettier": "^3.2.5",
"prettier": "^3.3.2",
"prettier-plugin-organize-imports": "^3.2.4",
"turbo": "^1.13.3",
"typescript": "^5.4.5"
"turbo": "^1.13.4",
"typescript": "^5.5.2"
},
"packageManager": "pnpm@9.0.5",
"pnpm": {
+11
View File
@@ -0,0 +1,11 @@
# @llamaindex/autotool
## 1.0.0
### Patch Changes
- Updated dependencies [436bc41]
- Updated dependencies [a44e54f]
- Updated dependencies [a51ed8d]
- Updated dependencies [d3b635b]
- llamaindex@0.4.0
@@ -4,6 +4,25 @@
### Patch Changes
- Updated dependencies [6e156ed]
- Updated dependencies [265976d]
- Updated dependencies [8e26f75]
- llamaindex@0.3.15
- @llamaindex/autotool@0.0.1
## null
### Patch Changes
- Updated dependencies [6ff7576]
- Updated dependencies [94543de]
- llamaindex@0.3.14
- @llamaindex/autotool@0.0.1
## null
### Patch Changes
- Updated dependencies [1b1081b]
- Updated dependencies [37525df]
- Updated dependencies [660a2b3]
@@ -5,10 +5,10 @@
"dependencies": {
"@llamaindex/autotool": "workspace:*",
"llamaindex": "workspace:*",
"openai": "^4.43.0"
"openai": "^4.52.0"
},
"devDependencies": {
"tsx": "^4.9.3"
"tsx": "^4.15.6"
},
"scripts": {
"start": "node --import tsx --import @llamaindex/autotool/node ./src/index.ts"
@@ -1,5 +1,72 @@
# @llamaindex/autotool-02-next-example
## 0.1.11
### Patch Changes
- Updated dependencies [3c47910]
- Updated dependencies [ed467a9]
- Updated dependencies [cba5406]
- llamaindex@0.4.1
- @llamaindex/autotool@1.0.0
## 0.1.10
### Patch Changes
- Updated dependencies [436bc41]
- Updated dependencies [a44e54f]
- Updated dependencies [a51ed8d]
- Updated dependencies [d3b635b]
- llamaindex@0.4.0
- @llamaindex/autotool@1.0.0
## 0.1.9
### Patch Changes
- Updated dependencies [6bc5bdd]
- Updated dependencies [bf25ff6]
- Updated dependencies [e6d6576]
- llamaindex@0.3.17
- @llamaindex/autotool@0.0.1
## 0.1.8
### Patch Changes
- Updated dependencies [11ae926]
- Updated dependencies [631f000]
- Updated dependencies [1378ec4]
- Updated dependencies [6b1ded4]
- Updated dependencies [4d4bd85]
- Updated dependencies [24a9d1e]
- Updated dependencies [45952de]
- Updated dependencies [54230f0]
- Updated dependencies [a29d835]
- Updated dependencies [73819bf]
- llamaindex@0.3.16
- @llamaindex/autotool@0.0.1
## 0.1.7
### Patch Changes
- Updated dependencies [6e156ed]
- Updated dependencies [265976d]
- Updated dependencies [8e26f75]
- llamaindex@0.3.15
- @llamaindex/autotool@0.0.1
## 0.1.6
### Patch Changes
- Updated dependencies [6ff7576]
- Updated dependencies [94543de]
- llamaindex@0.3.14
- @llamaindex/autotool@0.0.1
## 0.1.5
### Patch Changes
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/autotool-02-next-example",
"private": true,
"version": "0.1.5",
"version": "0.1.11",
"scripts": {
"dev": "next dev",
"build": "next build",
@@ -9,8 +9,8 @@
},
"dependencies": {
"@llamaindex/autotool": "workspace:*",
"@radix-ui/react-slot": "^1.0.2",
"ai": "^3.1.3",
"@radix-ui/react-slot": "^1.1.0",
"ai": "^3.2.1",
"class-variance-authority": "^0.7.0",
"dotenv": "^16.3.1",
"llamaindex": "workspace:*",
@@ -20,18 +20,18 @@
"react-dom": "^18.3.1",
"react-markdown": "^9.0.1",
"react-syntax-highlighter": "^15.5.0",
"sonner": "^1.4.41",
"sonner": "^1.5.0",
"tailwind-merge": "^2.1.0"
},
"devDependencies": {
"@types/node": "^20.12.11",
"@types/react": "^18.3.1",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@types/react-syntax-highlighter": "^15.5.11",
"autoprefixer": "^10.4.16",
"cross-env": "^7.0.3",
"postcss": "^8.4.32",
"tailwindcss": "^3.3.6",
"typescript": "^5.4.5"
"tailwindcss": "^3.4.4",
"typescript": "^5.5.2"
}
}
+10 -10
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/autotool",
"type": "module",
"version": "0.0.1",
"version": "1.0.0",
"description": "auto transpile your JS function to LLM Agent compatible",
"files": [
"dist",
@@ -45,13 +45,13 @@
"dev": "bunchee --watch"
},
"dependencies": {
"@swc/core": "^1.5.5",
"jotai": "^2.8.0",
"@swc/core": "^1.6.3",
"jotai": "^2.8.3",
"typedoc": "^0.25.13",
"unplugin": "^1.10.1"
},
"peerDependencies": {
"llamaindex": "^0.3.13",
"llamaindex": "^0.4.1",
"openai": "^4",
"typescript": "^4"
},
@@ -67,16 +67,16 @@
}
},
"devDependencies": {
"@swc/types": "^0.1.6",
"@swc/types": "^0.1.8",
"@types/json-schema": "^7.0.15",
"@types/node": "^20.12.11",
"bunchee": "^5.1.5",
"bunchee": "^5.2.1",
"llamaindex": "workspace:*",
"next": "14.2.3",
"rollup": "^4.17.2",
"tsx": "^4.9.3",
"typescript": "^5.4.5",
"rollup": "^4.18.0",
"tsx": "^4.15.6",
"typescript": "^5.5.2",
"vitest": "^1.6.0",
"webpack": "^5.91.0"
"webpack": "^5.92.1"
}
}
+1 -1
View File
@@ -10,7 +10,7 @@
"include": ["./src"],
"references": [
{
"path": "../core/tsconfig.json"
"path": "../llamaindex/tsconfig.json"
},
{
"path": "../env/tsconfig.json"
+48
View File
@@ -0,0 +1,48 @@
# @llamaindex/community
## 0.0.5
### Patch Changes
- ed467a9: Add model ids for Anthropic Claude 3.5 Sonnet model on Anthropic and Bedrock
- Updated dependencies [3c47910]
- Updated dependencies [ed467a9]
- Updated dependencies [cba5406]
- llamaindex@0.4.1
## 0.0.4
### Patch Changes
- b1a4a74: docs: updated Bedrock Opus region and added a basic README
- Updated dependencies [436bc41]
- Updated dependencies [a44e54f]
- Updated dependencies [a51ed8d]
- Updated dependencies [d3b635b]
- llamaindex@0.4.0
## 0.0.3
### Patch Changes
- Updated dependencies [6bc5bdd]
- Updated dependencies [bf25ff6]
- Updated dependencies [e6d6576]
- llamaindex@0.3.17
## 0.0.2
### Patch Changes
- 8832669: Community bedrock support added
- Updated dependencies [11ae926]
- Updated dependencies [631f000]
- Updated dependencies [1378ec4]
- Updated dependencies [6b1ded4]
- Updated dependencies [4d4bd85]
- Updated dependencies [24a9d1e]
- Updated dependencies [45952de]
- Updated dependencies [54230f0]
- Updated dependencies [a29d835]
- Updated dependencies [73819bf]
- llamaindex@0.3.16
+11
View File
@@ -0,0 +1,11 @@
# @llamaindex/community
> Tools written by the community for llamaindex
## Current Features:
- Bedrock support for the Anthropic Claude Models [usage](https://ts.llamaindex.ai/modules/llms/available_llms/bedrock)
## LICENSE
MIT
+8
View File
@@ -0,0 +1,8 @@
{
"name": "@llamaindex/community",
"version": "0.0.5",
"exports": {
".": "./src/index.ts",
"./type": "./src/type.ts"
}
}
+57
View File
@@ -0,0 +1,57 @@
{
"name": "@llamaindex/community",
"description": "Community package for LlamaIndexTS",
"version": "0.0.5",
"type": "module",
"types": "dist/type/index.d.ts",
"main": "dist/cjs/index.js",
"exports": {
".": {
"import": {
"types": "./dist/type/index.d.ts",
"default": "./dist/index.js"
},
"require": {
"types": "./dist/type/index.d.ts",
"default": "./dist/index.cjs"
}
},
"./llm/bedrock": {
"import": {
"types": "./dist/type/llm/bedrock.d.ts",
"default": "./dist/llm/bedrock/base.js"
},
"require": {
"types": "./dist/type/llm/bedrock.d.ts",
"default": "./dist/llm/bedrock/base.cjs"
}
}
},
"files": [
"dist",
"CHANGELOG.md",
"!**/*.tsbuildinfo"
],
"repository": {
"type": "git",
"url": "https://github.com/run-llama/LlamaIndexTS.git",
"directory": "packages/community"
},
"scripts": {
"build": "rm -rf ./dist && pnpm run build:code && pnpm run build:type",
"build:code": "tsup",
"build:type": "tsc -p tsconfig.json",
"dev": "concurrently \"pnpm run build:esm --watch\" \"pnpm run build:cjs --watch\" \"pnpm run build:type --watch\""
},
"devDependencies": {
"@swc/cli": "^0.3.12",
"@swc/core": "^1.6.3",
"concurrently": "^8.2.2",
"tsup": "^8.1.0"
},
"dependencies": {
"@aws-sdk/client-bedrock-runtime": "^3.600.0",
"@types/node": "^20.14.2",
"llamaindex": "workspace:*"
}
}
+1
View File
@@ -0,0 +1 @@
export { BEDROCK_MODELS, Bedrock } from "./llm/bedrock/base.js";
+355
View File
@@ -0,0 +1,355 @@
import {
BedrockRuntimeClient,
InvokeModelCommand,
InvokeModelWithResponseStreamCommand,
type BedrockRuntimeClientConfig,
type InvokeModelCommandInput,
type InvokeModelWithResponseStreamCommandInput,
} from "@aws-sdk/client-bedrock-runtime";
import type {
ChatMessage,
ChatResponse,
ChatResponseChunk,
CompletionResponse,
LLMChatParamsNonStreaming,
LLMChatParamsStreaming,
LLMCompletionParamsNonStreaming,
LLMCompletionParamsStreaming,
LLMMetadata,
ToolCallLLMMessageOptions,
} from "llamaindex";
import { ToolCallLLM, streamConverter, wrapLLMEvent } from "llamaindex";
import type {
AnthropicNoneStreamingResponse,
AnthropicTextContent,
StreamEvent,
} from "./types.js";
import {
mapChatMessagesToAnthropicMessages,
mapMessageContentToMessageContentDetails,
toUtf8,
} from "./utils.js";
export type BedrockAdditionalChatOptions = {};
export type BedrockChatParamsStreaming = LLMChatParamsStreaming<
BedrockAdditionalChatOptions,
ToolCallLLMMessageOptions
>;
export type BedrockChatStreamResponse = AsyncIterable<
ChatResponseChunk<ToolCallLLMMessageOptions>
>;
export type BedrockChatParamsNonStreaming = LLMChatParamsNonStreaming<
BedrockAdditionalChatOptions,
ToolCallLLMMessageOptions
>;
export type BedrockChatNonStreamResponse =
ChatResponse<ToolCallLLMMessageOptions>;
export enum BEDROCK_MODELS {
AMAZON_TITAN_TG1_LARGE = "amazon.titan-tg1-large",
AMAZON_TITAN_TEXT_EXPRESS_V1 = "amazon.titan-text-express-v1",
AI21_J2_GRANDE_INSTRUCT = "ai21.j2-grande-instruct",
AI21_J2_JUMBO_INSTRUCT = "ai21.j2-jumbo-instruct",
AI21_J2_MID = "ai21.j2-mid",
AI21_J2_MID_V1 = "ai21.j2-mid-v1",
AI21_J2_ULTRA = "ai21.j2-ultra",
AI21_J2_ULTRA_V1 = "ai21.j2-ultra-v1",
COHERE_COMMAND_TEXT_V14 = "cohere.command-text-v14",
ANTHROPIC_CLAUDE_INSTANT_1 = "anthropic.claude-instant-v1",
ANTHROPIC_CLAUDE_1 = "anthropic.claude-v1", // EOF: No longer supported
ANTHROPIC_CLAUDE_2 = "anthropic.claude-v2",
ANTHROPIC_CLAUDE_2_1 = "anthropic.claude-v2:1",
ANTHROPIC_CLAUDE_3_SONNET = "anthropic.claude-3-sonnet-20240229-v1:0",
ANTHROPIC_CLAUDE_3_HAIKU = "anthropic.claude-3-haiku-20240307-v1:0",
ANTHROPIC_CLAUDE_3_OPUS = "anthropic.claude-3-opus-20240229-v1:0",
ANTHROPIC_CLAUDE_3_5_SONNET = "anthropic.claude-3-5-sonnet-20240620-v1:0",
META_LLAMA2_13B_CHAT = "meta.llama2-13b-chat-v1",
META_LLAMA2_70B_CHAT = "meta.llama2-70b-chat-v1",
META_LLAMA3_8B_INSTRUCT = "meta.llama3-8b-instruct-v1:0",
META_LLAMA3_70B_INSTRUCT = "meta.llama3-70b-instruct-v1:0",
MISTRAL_7B_INSTRUCT = "mistral.mistral-7b-instruct-v0:2",
MISTRAL_MIXTRAL_7B_INSTRUCT = "mistral.mixtral-8x7b-instruct-v0:1",
MISTRAL_MIXTRAL_LARGE_2402 = "mistral.mistral-large-2402-v1:0",
}
/*
* Values taken from https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters.html#model-parameters-claude
*/
const COMPLETION_MODELS = {
[BEDROCK_MODELS.AMAZON_TITAN_TG1_LARGE]: 8000,
[BEDROCK_MODELS.AMAZON_TITAN_TEXT_EXPRESS_V1]: 8000,
[BEDROCK_MODELS.AI21_J2_GRANDE_INSTRUCT]: 8000,
[BEDROCK_MODELS.AI21_J2_JUMBO_INSTRUCT]: 8000,
[BEDROCK_MODELS.AI21_J2_MID]: 8000,
[BEDROCK_MODELS.AI21_J2_MID_V1]: 8000,
[BEDROCK_MODELS.AI21_J2_ULTRA]: 8000,
[BEDROCK_MODELS.AI21_J2_ULTRA_V1]: 8000,
[BEDROCK_MODELS.COHERE_COMMAND_TEXT_V14]: 4096,
};
const CHAT_ONLY_MODELS = {
[BEDROCK_MODELS.ANTHROPIC_CLAUDE_INSTANT_1]: 100000,
[BEDROCK_MODELS.ANTHROPIC_CLAUDE_1]: 100000,
[BEDROCK_MODELS.ANTHROPIC_CLAUDE_2]: 100000,
[BEDROCK_MODELS.ANTHROPIC_CLAUDE_2_1]: 200000,
[BEDROCK_MODELS.ANTHROPIC_CLAUDE_3_SONNET]: 200000,
[BEDROCK_MODELS.ANTHROPIC_CLAUDE_3_HAIKU]: 200000,
[BEDROCK_MODELS.ANTHROPIC_CLAUDE_3_OPUS]: 200000,
[BEDROCK_MODELS.ANTHROPIC_CLAUDE_3_5_SONNET]: 200000,
[BEDROCK_MODELS.META_LLAMA2_13B_CHAT]: 2048,
[BEDROCK_MODELS.META_LLAMA2_70B_CHAT]: 4096,
[BEDROCK_MODELS.META_LLAMA3_8B_INSTRUCT]: 8192,
[BEDROCK_MODELS.META_LLAMA3_70B_INSTRUCT]: 8192,
[BEDROCK_MODELS.MISTRAL_7B_INSTRUCT]: 32000,
[BEDROCK_MODELS.MISTRAL_MIXTRAL_7B_INSTRUCT]: 32000,
[BEDROCK_MODELS.MISTRAL_MIXTRAL_LARGE_2402]: 32000,
};
const BEDROCK_FOUNDATION_LLMS = { ...COMPLETION_MODELS, ...CHAT_ONLY_MODELS };
/*
* Only the following models support streaming as
* per result of Bedrock.Client.list_foundation_models
* https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/bedrock/client/list_foundation_models.html
*/
export const STREAMING_MODELS = new Set([
BEDROCK_MODELS.AMAZON_TITAN_TG1_LARGE,
BEDROCK_MODELS.AMAZON_TITAN_TEXT_EXPRESS_V1,
BEDROCK_MODELS.ANTHROPIC_CLAUDE_INSTANT_1,
BEDROCK_MODELS.ANTHROPIC_CLAUDE_1,
BEDROCK_MODELS.ANTHROPIC_CLAUDE_2,
BEDROCK_MODELS.ANTHROPIC_CLAUDE_2_1,
BEDROCK_MODELS.ANTHROPIC_CLAUDE_3_SONNET,
BEDROCK_MODELS.ANTHROPIC_CLAUDE_3_HAIKU,
BEDROCK_MODELS.ANTHROPIC_CLAUDE_3_OPUS,
BEDROCK_MODELS.ANTHROPIC_CLAUDE_3_5_SONNET,
BEDROCK_MODELS.META_LLAMA2_13B_CHAT,
BEDROCK_MODELS.META_LLAMA2_70B_CHAT,
BEDROCK_MODELS.META_LLAMA3_8B_INSTRUCT,
BEDROCK_MODELS.META_LLAMA3_70B_INSTRUCT,
BEDROCK_MODELS.MISTRAL_7B_INSTRUCT,
BEDROCK_MODELS.MISTRAL_MIXTRAL_7B_INSTRUCT,
BEDROCK_MODELS.MISTRAL_MIXTRAL_LARGE_2402,
]);
abstract class Provider {
abstract getTextFromResponse(response: Record<string, any>): string;
getTextFromStreamResponse(response: Record<string, any>): string {
return this.getTextFromResponse(response);
}
abstract getRequestBody<T extends ChatMessage>(
metadata: LLMMetadata,
messages: T[],
): InvokeModelCommandInput | InvokeModelWithResponseStreamCommandInput;
}
class AnthropicProvider extends Provider {
getResultFromResponse(
response: Record<string, any>,
): AnthropicNoneStreamingResponse {
return JSON.parse(toUtf8(response.body));
}
getTextFromResponse(response: Record<string, any>): string {
const result = this.getResultFromResponse(response);
return result.content
.filter((item) => item.type === "text")
.map((item) => (item as AnthropicTextContent).text)
.join(" ");
}
getTextFromStreamResponse(response: Record<string, any>): string {
const event: StreamEvent | undefined = response.chunk?.bytes
? JSON.parse(toUtf8(response.chunk?.bytes))
: undefined;
if (event?.type === "content_block_delta") return event.delta.text;
return "";
}
getRequestBody<T extends ChatMessage>(
metadata: LLMMetadata,
messages: T[],
): InvokeModelCommandInput | InvokeModelWithResponseStreamCommandInput {
return {
modelId: metadata.model,
contentType: "application/json",
accept: "application/json",
body: JSON.stringify({
anthropic_version: "bedrock-2023-05-31",
messages: mapChatMessagesToAnthropicMessages(messages),
max_tokens: metadata.maxTokens,
temperature: metadata.temperature,
top_p: metadata.topP,
}),
};
}
}
// Other providers could go here
const PROVIDERS: { [key: string]: Provider } = {
anthropic: new AnthropicProvider(),
};
const getProvider = (model: string): Provider => {
const providerName = model.split(".")[0];
if (!(providerName in PROVIDERS)) {
throw new Error(
`Provider ${providerName} for model ${model} is not supported`,
);
}
return PROVIDERS[providerName];
};
export type BedrockModelParams = {
model: keyof typeof BEDROCK_FOUNDATION_LLMS;
temperature?: number;
topP?: number;
maxTokens?: number;
};
const DEFAULT_BEDROCK_PARAMS = {
temperature: 0.1,
topP: 1,
maxTokens: 1024, // required by anthropic
};
export type BedrockParams = BedrockModelParams & BedrockRuntimeClientConfig;
/**
* ToolCallLLM for Bedrock
*/
export class Bedrock extends ToolCallLLM<BedrockAdditionalChatOptions> {
private client: BedrockRuntimeClient;
model: keyof typeof BEDROCK_FOUNDATION_LLMS;
temperature: number;
topP: number;
maxTokens?: number;
provider: Provider;
topK?: number;
// there should be no check for env variables. Bedrock can be authenticated in various ways
// AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_REGION are the env variables used directly by the sdk
constructor({
temperature,
topP,
maxTokens,
model,
...params
}: BedrockParams) {
super();
this.model = model;
this.provider = getProvider(this.model);
this.maxTokens = maxTokens ?? DEFAULT_BEDROCK_PARAMS.maxTokens;
this.temperature = temperature ?? DEFAULT_BEDROCK_PARAMS.temperature;
this.topP = topP ?? DEFAULT_BEDROCK_PARAMS.topP;
this.client = new BedrockRuntimeClient(params);
}
get supportToolCall(): boolean {
return false;
}
get metadata(): LLMMetadata {
// NOTE, Anthropic supports top_k but LLMMetadata does not
return {
model: this.model,
temperature: this.temperature,
topP: this.topP,
maxTokens: this.maxTokens,
contextWindow: BEDROCK_FOUNDATION_LLMS[this.model],
tokenizer: undefined,
};
}
protected async nonStreamChat(
params: BedrockChatParamsNonStreaming,
): Promise<BedrockChatNonStreamResponse> {
const input = this.provider.getRequestBody(this.metadata, params.messages);
const command = new InvokeModelCommand(input);
const response = await this.client.send(command);
return {
raw: response,
message: {
content: this.provider.getTextFromResponse(response),
role: "assistant",
},
};
}
protected async *streamChat(
params: BedrockChatParamsStreaming,
): BedrockChatStreamResponse {
if (!STREAMING_MODELS.has(this.model))
throw new Error(`The model: ${this.model} does not support streaming`);
const input = this.provider.getRequestBody(this.metadata, params.messages);
const command = new InvokeModelWithResponseStreamCommand(input);
const response = await this.client.send(command);
if (response.body)
yield* streamConverter(response.body, (response) => {
return {
delta: this.provider.getTextFromStreamResponse(response),
raw: response,
};
});
}
chat(params: BedrockChatParamsStreaming): Promise<BedrockChatStreamResponse>;
chat(
params: BedrockChatParamsNonStreaming,
): Promise<BedrockChatNonStreamResponse>;
@wrapLLMEvent
async chat(
params: BedrockChatParamsStreaming | BedrockChatParamsNonStreaming,
): Promise<BedrockChatStreamResponse | BedrockChatNonStreamResponse> {
if (params.stream) return this.streamChat(params);
return this.nonStreamChat(params);
}
complete(
params: LLMCompletionParamsStreaming,
): Promise<AsyncIterable<CompletionResponse>>;
complete(
params: LLMCompletionParamsNonStreaming,
): Promise<CompletionResponse>;
async complete(
params: LLMCompletionParamsStreaming | LLMCompletionParamsNonStreaming,
): Promise<CompletionResponse | AsyncIterable<CompletionResponse>> {
const message: ChatMessage = {
role: "user",
content: mapMessageContentToMessageContentDetails(params.prompt),
};
const input = this.provider.getRequestBody(this.metadata, [message]);
if (params.stream) {
const command = new InvokeModelWithResponseStreamCommand(input);
const response = await this.client.send(command);
if (response.body)
return streamConverter(response.body, (response) => {
return {
text: this.provider.getTextFromStreamResponse(response),
raw: response,
};
});
}
const command = new InvokeModelCommand(input);
const response = await this.client.send(command);
return {
text: this.provider.getTextFromResponse(response),
raw: response,
};
}
}
+109
View File
@@ -0,0 +1,109 @@
type Usage = {
input_tokens: number;
output_tokens: number;
};
type Message = {
id: string;
type: string;
role: string;
content: string[];
model: string;
stop_reason: string | null;
stop_sequence: string | null;
usage: Usage;
};
type ContentBlockStart = {
type: "content_block_start";
index: number;
content_block: {
type: string;
text: string;
};
};
type Delta = {
type: string;
text: string;
};
type ContentBlockDelta = {
type: "content_block_delta";
index: number;
delta: Delta;
};
type ContentBlockStop = {
type: "content_block_stop";
index: number;
};
type MessageDelta = {
type: "message_delta";
delta: {
stop_reason: string;
stop_sequence: string | null;
};
usage: Usage;
};
type InvocationMetrics = {
inputTokenCount: number;
outputTokenCount: number;
invocationLatency: number;
firstByteLatency: number;
};
type MessageStop = {
type: "message_stop";
"amazon-bedrock-invocationMetrics": InvocationMetrics;
};
export type StreamEvent =
| { type: "message_start"; message: Message }
| ContentBlockStart
| ContentBlockDelta
| ContentBlockStop
| MessageDelta
| MessageStop;
export type AnthropicContent = AnthropicTextContent | AnthropicImageContent;
export type AnthropicTextContent = {
type: "text";
text: string;
};
export type AnthropicMediaTypes =
| "image/jpeg"
| "image/png"
| "image/webp"
| "image/gif";
export type AnthropicImageSource = {
type: "base64";
media_type: AnthropicMediaTypes;
data: string; // base64 encoded image bytes
};
export type AnthropicImageContent = {
type: "image";
source: AnthropicImageSource;
};
export type AnthropicMessage = {
role: "user" | "assistant";
content: AnthropicContent[];
};
export type AnthropicNoneStreamingResponse = {
id: string;
type: "message";
role: "assistant";
content: AnthropicContent[];
model: string;
stop_reason: "end_turn" | "max_tokens" | "stop_sequence";
stop_sequence?: string;
usage: { input_tokens: number; output_tokens: number };
};
+144
View File
@@ -0,0 +1,144 @@
import type {
ChatMessage,
MessageContent,
MessageContentDetail,
} from "llamaindex";
import type {
AnthropicContent,
AnthropicImageContent,
AnthropicMediaTypes,
AnthropicMessage,
AnthropicTextContent,
} from "./types.js";
const ACCEPTED_IMAGE_MIME_TYPES = [
"image/jpeg",
"image/png",
"image/webp",
"image/gif",
];
export const mapMessageContentToMessageContentDetails = (
content: MessageContent,
): MessageContentDetail[] => {
return Array.isArray(content) ? content : [{ type: "text", text: content }];
};
export const mergeNeighboringSameRoleMessages = (
messages: AnthropicMessage[],
): AnthropicMessage[] => {
return messages.reduce(
(result: AnthropicMessage[], current: AnthropicMessage, index: number) => {
if (index > 0 && messages[index - 1].role === current.role) {
result[result.length - 1].content = [
...result[result.length - 1].content,
...current.content,
];
} else {
result.push(current);
}
return result;
},
[],
);
};
export const mapMessageContentDetailToAnthropicContent = <
T extends MessageContentDetail,
>(
detail: T,
): AnthropicContent => {
let content: AnthropicContent;
if (detail.type === "text") {
content = mapTextContent(detail.text);
} else if (detail.type === "image_url") {
content = mapImageContent(detail.image_url.url);
} else {
throw new Error("Unsupported content detail type");
}
return content;
};
export const mapMessageContentToAnthropicContent = <T extends MessageContent>(
content: T,
): AnthropicContent[] => {
return mapMessageContentToMessageContentDetails(content).map(
mapMessageContentDetailToAnthropicContent,
);
};
export const mapChatMessagesToAnthropicMessages = <T extends ChatMessage>(
messages: T[],
): AnthropicMessage[] => {
const mapped = messages
.flatMap((msg: T): AnthropicMessage[] => {
return mapMessageContentToMessageContentDetails(msg.content).map(
(detail: MessageContentDetail): AnthropicMessage => {
const content = mapMessageContentDetailToAnthropicContent(detail);
return {
role: msg.role === "assistant" ? "assistant" : "user",
content: [content],
};
},
);
})
.filter((message: AnthropicMessage) => {
const content = message.content[0];
if (content.type === "text" && !content.text) return false;
if (content.type === "image" && !content.source.data) return false;
return true;
});
return mergeNeighboringSameRoleMessages(mapped);
};
export const mapTextContent = (text: string): AnthropicTextContent => {
return { type: "text", text };
};
export const extractDataUrlComponents = (
dataUrl: string,
): {
mimeType: string;
base64: string;
} => {
const parts = dataUrl.split(";base64,");
if (parts.length !== 2 || !parts[0].startsWith("data:")) {
throw new Error("Invalid data URL");
}
const mimeType = parts[0].slice(5);
const base64 = parts[1];
return {
mimeType,
base64,
};
};
export const mapImageContent = (imageUrl: string): AnthropicImageContent => {
if (!imageUrl.startsWith("data:"))
throw new Error(
"For Anthropic please only use base64 data url, e.g.: data:image/jpeg;base64,SGVsbG8sIFdvcmxkIQ==",
);
const { mimeType, base64: data } = extractDataUrlComponents(imageUrl);
if (!ACCEPTED_IMAGE_MIME_TYPES.includes(mimeType))
throw new Error(
`Anthropic only accepts the following mimeTypes: ${ACCEPTED_IMAGE_MIME_TYPES.join("\n")}`,
);
return {
type: "image",
source: {
type: "base64",
media_type: mimeType as AnthropicMediaTypes,
data,
},
};
};
export const toUtf8 = (input: Uint8Array): string =>
new TextDecoder("utf-8").decode(input);
+19
View File
@@ -0,0 +1,19 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist/type",
"tsBuildInfoFile": "./dist/.tsbuildinfo",
"emitDeclarationOnly": true,
"module": "ESNext",
"moduleResolution": "bundler",
"types": ["node"]
},
"include": ["./src"],
"exclude": ["node_modules"],
"references": [
{
"path": "../llamaindex/tsconfig.json"
}
]
}
+9
View File
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./dist/script/type",
"tsBuildInfoFile": "./dist/script/.tsbuildinfo",
"emitDeclarationOnly": true
},
"include": ["./tsup.config.ts"]
}
+9
View File
@@ -0,0 +1,9 @@
import { defineConfig } from "tsup";
export default defineConfig([
{
entry: ["src/index.ts", "src/llm/bedrock/base.ts"],
format: ["cjs", "esm"],
sourcemap: true,
},
]);
@@ -1,403 +0,0 @@
{
"llmEventStart": [
{
"id": "PRESERVE_0",
"messages": [
{
"role": "user",
"content": "What is the weather in San Francisco?",
"options": {}
}
]
},
{
"id": "PRESERVE_1",
"messages": [
{
"role": "user",
"content": "What is the weather in San Francisco?",
"options": {}
},
{
"content": [
{
"type": "text",
"text": "<thinking>\nThe user is asking for the weather in a specific location, San Francisco. The Weather function is the relevant tool to answer this request, as it returns weather information for a given location.\n\nThe Weather function has one required parameter:\n- location (string): The user has directly provided the location of \"San Francisco\"\n\nSince the required location parameter has been provided by the user, we have all the necessary information to call the Weather function.\n</thinking>"
}
],
"role": "assistant",
"options": {
"toolCall": {
"id": "HIDDEN",
"name": "Weather",
"input": {
"location": "San Francisco"
}
}
}
},
{
"content": "35 degrees and sunny in San Francisco",
"role": "user",
"options": {
"toolResult": {
"isError": false,
"id": "HIDDEN"
}
}
}
]
},
{
"id": "PRESERVE_2",
"messages": [
{
"role": "user",
"content": "My name is Alex Yang. What is my unique id?",
"options": {}
}
]
},
{
"id": "PRESERVE_3",
"messages": [
{
"role": "user",
"content": "My name is Alex Yang. What is my unique id?",
"options": {}
},
{
"content": [
{
"type": "text",
"text": "<thinking>\nThe unique_id function is the relevant tool to answer the user's request for their unique ID. It requires two parameters:\nfirstName: The user provided their first name, which is \"Alex\"\nlastName: The user also provided their last name, \"Yang\"\nSince the user has provided all the required parameters, we can proceed with calling the unique_id function.\n</thinking>"
}
],
"role": "assistant",
"options": {
"toolCall": {
"id": "HIDDEN",
"name": "unique_id",
"input": {
"firstName": "Alex",
"lastName": "Yang"
}
}
}
},
{
"content": "123456789",
"role": "user",
"options": {
"toolResult": {
"isError": false,
"id": "HIDDEN"
}
}
}
]
},
{
"id": "PRESERVE_4",
"messages": [
{
"role": "user",
"content": "how much is 1 + 1?",
"options": {}
}
]
},
{
"id": "PRESERVE_5",
"messages": [
{
"role": "user",
"content": "how much is 1 + 1?",
"options": {}
},
{
"content": [
{
"type": "text",
"text": "<thinking>\nThe user is asking to sum the numbers 1 and 1. The relevant tool to use is the sumNumbers function, which takes two number parameters a and b.\nThe user has directly provided the values for the parameters:\na = 1 \nb = 1\nSince all the required parameters have been provided, we can proceed with calling the function.\n</thinking>"
}
],
"role": "assistant",
"options": {
"toolCall": {
"id": "HIDDEN",
"name": "sumNumbers",
"input": {
"a": 1,
"b": 1
}
}
}
},
{
"content": "2",
"role": "user",
"options": {
"toolResult": {
"isError": false,
"id": "HIDDEN"
}
}
}
]
}
],
"llmEventEnd": [
{
"id": "PRESERVE_0",
"response": {
"raw": {
"id": "HIDDEN",
"type": "message",
"role": "assistant",
"model": "claude-3-opus-20240229",
"stop_sequence": null,
"usage": {
"input_tokens": 462,
"output_tokens": 147
},
"content": [
{
"type": "text",
"text": "<thinking>\nThe user is asking for the weather in a specific location, San Francisco. The Weather function is the relevant tool to answer this request, as it returns weather information for a given location.\n\nThe Weather function has one required parameter:\n- location (string): The user has directly provided the location of \"San Francisco\"\n\nSince the required location parameter has been provided by the user, we have all the necessary information to call the Weather function.\n</thinking>"
},
{
"type": "tool_use",
"id": "HIDDEN",
"name": "Weather",
"input": {
"location": "San Francisco"
}
}
],
"stop_reason": "tool_use"
},
"message": {
"content": [
{
"type": "text",
"text": "<thinking>\nThe user is asking for the weather in a specific location, San Francisco. The Weather function is the relevant tool to answer this request, as it returns weather information for a given location.\n\nThe Weather function has one required parameter:\n- location (string): The user has directly provided the location of \"San Francisco\"\n\nSince the required location parameter has been provided by the user, we have all the necessary information to call the Weather function.\n</thinking>"
}
],
"role": "assistant",
"options": {
"toolCall": {
"id": "HIDDEN",
"name": "Weather",
"input": {
"location": "San Francisco"
}
}
}
}
}
},
{
"id": "PRESERVE_1",
"response": {
"raw": {
"id": "HIDDEN",
"type": "message",
"role": "assistant",
"model": "claude-3-opus-20240229",
"stop_sequence": null,
"usage": {
"input_tokens": 628,
"output_tokens": 18
},
"content": [
{
"type": "text",
"text": "The current weather in San Francisco is 35 degrees and sunny."
}
],
"stop_reason": "end_turn"
},
"message": {
"content": [
{
"type": "text",
"text": "The current weather in San Francisco is 35 degrees and sunny."
}
],
"role": "assistant",
"options": {}
}
}
},
{
"id": "PRESERVE_2",
"response": {
"raw": {
"id": "HIDDEN",
"type": "message",
"role": "assistant",
"model": "claude-3-opus-20240229",
"stop_sequence": null,
"usage": {
"input_tokens": 482,
"output_tokens": 152
},
"content": [
{
"type": "text",
"text": "<thinking>\nThe unique_id function is the relevant tool to answer the user's request for their unique ID. It requires two parameters:\nfirstName: The user provided their first name, which is \"Alex\"\nlastName: The user also provided their last name, \"Yang\"\nSince the user has provided all the required parameters, we can proceed with calling the unique_id function.\n</thinking>"
},
{
"type": "tool_use",
"id": "HIDDEN",
"name": "unique_id",
"input": {
"firstName": "Alex",
"lastName": "Yang"
}
}
],
"stop_reason": "tool_use"
},
"message": {
"content": [
{
"type": "text",
"text": "<thinking>\nThe unique_id function is the relevant tool to answer the user's request for their unique ID. It requires two parameters:\nfirstName: The user provided their first name, which is \"Alex\"\nlastName: The user also provided their last name, \"Yang\"\nSince the user has provided all the required parameters, we can proceed with calling the unique_id function.\n</thinking>"
}
],
"role": "assistant",
"options": {
"toolCall": {
"id": "HIDDEN",
"name": "unique_id",
"input": {
"firstName": "Alex",
"lastName": "Yang"
}
}
}
}
}
},
{
"id": "PRESERVE_3",
"response": {
"raw": {
"id": "HIDDEN",
"type": "message",
"role": "assistant",
"model": "claude-3-opus-20240229",
"stop_sequence": null,
"usage": {
"input_tokens": 648,
"output_tokens": 13
},
"content": [
{
"type": "text",
"text": "Your unique ID is 123456789."
}
],
"stop_reason": "end_turn"
},
"message": {
"content": [
{
"type": "text",
"text": "Your unique ID is 123456789."
}
],
"role": "assistant",
"options": {}
}
}
},
{
"id": "PRESERVE_4",
"response": {
"raw": {
"id": "HIDDEN",
"type": "message",
"role": "assistant",
"model": "claude-3-opus-20240229",
"stop_sequence": null,
"usage": {
"input_tokens": 498,
"output_tokens": 151
},
"content": [
{
"type": "text",
"text": "<thinking>\nThe user is asking to sum the numbers 1 and 1. The relevant tool to use is the sumNumbers function, which takes two number parameters a and b.\nThe user has directly provided the values for the parameters:\na = 1 \nb = 1\nSince all the required parameters have been provided, we can proceed with calling the function.\n</thinking>"
},
{
"type": "tool_use",
"id": "HIDDEN",
"name": "sumNumbers",
"input": {
"a": 1,
"b": 1
}
}
],
"stop_reason": "tool_use"
},
"message": {
"content": [
{
"type": "text",
"text": "<thinking>\nThe user is asking to sum the numbers 1 and 1. The relevant tool to use is the sumNumbers function, which takes two number parameters a and b.\nThe user has directly provided the values for the parameters:\na = 1 \nb = 1\nSince all the required parameters have been provided, we can proceed with calling the function.\n</thinking>"
}
],
"role": "assistant",
"options": {
"toolCall": {
"id": "HIDDEN",
"name": "sumNumbers",
"input": {
"a": 1,
"b": 1
}
}
}
}
}
},
{
"id": "PRESERVE_5",
"response": {
"raw": {
"id": "HIDDEN",
"type": "message",
"role": "assistant",
"model": "claude-3-opus-20240229",
"stop_sequence": null,
"usage": {
"input_tokens": 661,
"output_tokens": 16
},
"content": [
{
"type": "text",
"text": "So 1 + 1 = 2."
}
],
"stop_reason": "end_turn"
},
"message": {
"content": [
{
"type": "text",
"text": "So 1 + 1 = 2."
}
],
"role": "assistant",
"options": {}
}
}
}
],
"llmEventStream": []
}
@@ -1,310 +0,0 @@
{
"llmEventStart": [
{
"id": "PRESERVE_0",
"messages": [
{
"content": "Hello",
"role": "user",
"options": {}
}
]
},
{
"id": "PRESERVE_1",
"messages": [
{
"content": "hello",
"role": "user"
}
]
}
],
"llmEventEnd": [
{
"id": "PRESERVE_0",
"response": {
"raw": {
"id": "HIDDEN",
"type": "message",
"role": "assistant",
"model": "claude-3-opus-20240229",
"stop_sequence": null,
"usage": {
"input_tokens": 8,
"output_tokens": 12
},
"content": [
{
"type": "text",
"text": "Hello! How can I assist you today?"
}
],
"stop_reason": "end_turn"
},
"message": {
"content": "Hello! How can I assist you today?",
"role": "assistant",
"options": {}
}
}
},
{
"id": "PRESERVE_1",
"response": {
"raw": [
{
"raw": {
"type": "content_block_delta",
"index": 0,
"delta": {
"type": "text_delta",
"text": "Hello"
}
},
"delta": "Hello",
"options": {}
},
{
"raw": {
"type": "content_block_delta",
"index": 0,
"delta": {
"type": "text_delta",
"text": "!"
}
},
"delta": "!",
"options": {}
},
{
"raw": {
"type": "content_block_delta",
"index": 0,
"delta": {
"type": "text_delta",
"text": " How"
}
},
"delta": " How",
"options": {}
},
{
"raw": {
"type": "content_block_delta",
"index": 0,
"delta": {
"type": "text_delta",
"text": " can"
}
},
"delta": " can",
"options": {}
},
{
"raw": {
"type": "content_block_delta",
"index": 0,
"delta": {
"type": "text_delta",
"text": " I"
}
},
"delta": " I",
"options": {}
},
{
"raw": {
"type": "content_block_delta",
"index": 0,
"delta": {
"type": "text_delta",
"text": " assist"
}
},
"delta": " assist",
"options": {}
},
{
"raw": {
"type": "content_block_delta",
"index": 0,
"delta": {
"type": "text_delta",
"text": " you"
}
},
"delta": " you",
"options": {}
},
{
"raw": {
"type": "content_block_delta",
"index": 0,
"delta": {
"type": "text_delta",
"text": " today"
}
},
"delta": " today",
"options": {}
},
{
"raw": {
"type": "content_block_delta",
"index": 0,
"delta": {
"type": "text_delta",
"text": "?"
}
},
"delta": "?",
"options": {}
}
],
"message": {
"content": "Hello! How can I assist you today?",
"role": "assistant",
"options": {}
}
}
}
],
"llmEventStream": [
{
"id": "PRESERVE_1",
"chunk": {
"raw": {
"type": "content_block_delta",
"index": 0,
"delta": {
"type": "text_delta",
"text": "Hello"
}
},
"delta": "Hello",
"options": {}
}
},
{
"id": "PRESERVE_1",
"chunk": {
"raw": {
"type": "content_block_delta",
"index": 0,
"delta": {
"type": "text_delta",
"text": "!"
}
},
"delta": "!",
"options": {}
}
},
{
"id": "PRESERVE_1",
"chunk": {
"raw": {
"type": "content_block_delta",
"index": 0,
"delta": {
"type": "text_delta",
"text": " How"
}
},
"delta": " How",
"options": {}
}
},
{
"id": "PRESERVE_1",
"chunk": {
"raw": {
"type": "content_block_delta",
"index": 0,
"delta": {
"type": "text_delta",
"text": " can"
}
},
"delta": " can",
"options": {}
}
},
{
"id": "PRESERVE_1",
"chunk": {
"raw": {
"type": "content_block_delta",
"index": 0,
"delta": {
"type": "text_delta",
"text": " I"
}
},
"delta": " I",
"options": {}
}
},
{
"id": "PRESERVE_1",
"chunk": {
"raw": {
"type": "content_block_delta",
"index": 0,
"delta": {
"type": "text_delta",
"text": " assist"
}
},
"delta": " assist",
"options": {}
}
},
{
"id": "PRESERVE_1",
"chunk": {
"raw": {
"type": "content_block_delta",
"index": 0,
"delta": {
"type": "text_delta",
"text": " you"
}
},
"delta": " you",
"options": {}
}
},
{
"id": "PRESERVE_1",
"chunk": {
"raw": {
"type": "content_block_delta",
"index": 0,
"delta": {
"type": "text_delta",
"text": " today"
}
},
"delta": " today",
"options": {}
}
},
{
"id": "PRESERVE_1",
"chunk": {
"raw": {
"type": "content_block_delta",
"index": 0,
"delta": {
"type": "text_delta",
"text": "?"
}
},
"delta": "?",
"options": {}
}
}
]
}
-49
View File
@@ -1,49 +0,0 @@
import { encodingForModel } from "js-tiktoken";
export enum Tokenizers {
CL100K_BASE = "cl100k_base",
}
/**
* @internal Helper class singleton
*/
class GlobalsHelper {
defaultTokenizer: {
encode: (text: string) => Uint32Array;
decode: (tokens: Uint32Array) => string;
};
constructor() {
const encoding = encodingForModel("text-embedding-ada-002"); // cl100k_base
this.defaultTokenizer = {
encode: (text: string) => {
return new Uint32Array(encoding.encode(text));
},
decode: (tokens: Uint32Array) => {
const numberArray = Array.from(tokens);
const text = encoding.decode(numberArray);
const uint8Array = new TextEncoder().encode(text);
return new TextDecoder().decode(uint8Array);
},
};
}
tokenizer(encoding?: Tokenizers) {
if (encoding && encoding !== Tokenizers.CL100K_BASE) {
throw new Error(`Tokenizer encoding ${encoding} not yet supported`);
}
return this.defaultTokenizer!.encode.bind(this.defaultTokenizer);
}
tokenizerDecoder(encoding?: Tokenizers) {
if (encoding && encoding !== Tokenizers.CL100K_BASE) {
throw new Error(`Tokenizer encoding ${encoding} not yet supported`);
}
return this.defaultTokenizer!.decode.bind(this.defaultTokenizer);
}
}
export const globalsHelper = new GlobalsHelper();
-23
View File
@@ -1,23 +0,0 @@
import type { NodeWithScore } from "./Node.js";
/**
* Response is the output of a LLM
*/
export class Response {
response: string;
sourceNodes?: NodeWithScore[];
metadata: Record<string, unknown> = {};
constructor(response: string, sourceNodes?: NodeWithScore[]) {
this.response = response;
this.sourceNodes = sourceNodes || [];
}
protected _getFormattedSources() {
throw new Error("Not implemented yet");
}
toString() {
return this.response ?? "";
}
}
-13
View File
@@ -1,13 +0,0 @@
import { fs } from "@llamaindex/env";
import mammoth from "mammoth";
import { Document } from "../Node.js";
import type { FileReader } from "./type.js";
export class DocxReader implements FileReader {
/** DocxParser */
async loadData(file: string): Promise<Document[]> {
const dataBuffer = await fs.readFile(file);
const { value } = await mammoth.extractRawText({ buffer: dataBuffer });
return [new Document({ text: value, id_: file })];
}
}
@@ -1,168 +0,0 @@
import { fs, getEnv } from "@llamaindex/env";
import { filetypemime } from "magic-bytes.js";
import { Document } from "../Node.js";
import type { FileReader, Language, ResultType } from "./type.js";
const SupportedFiles: { [key: string]: string } = {
".pdf": "application/pdf",
".doc": "application/msword",
".docx":
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
".docm": "application/vnd.ms-word.document.macroEnabled.12",
".dot": "application/msword",
".dotx":
"application/vnd.openxmlformats-officedocument.wordprocessingml.template",
".dotm": "application/vnd.ms-word.template.macroEnabled.12",
".rtf": "application/rtf",
".wps": "application/vnd.ms-works",
".wpd": "application/wordperfect",
".sxw": "application/vnd.sun.xml.writer",
".stw": "application/vnd.sun.xml.writer.template",
".sxg": "application/vnd.sun.xml.writer.global",
".pages": "application/x-iwork-pages-sffpages",
".mw": "application/macwriteii",
".mcw": "application/macwriteii",
".uot": "application/x-uo",
".uof": "application/vnd.uoml+xml",
".uos": "application/vnd.sun.xml.calc",
".uop": "application/vnd.openofficeorg.presentation",
".ppt": "application/vnd.ms-powerpoint",
".pptx":
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
".pot": "application/vnd.ms-powerpoint",
".pptm": "application/vnd.ms-powerpoint.presentation.macroEnabled.12",
".potx":
"application/vnd.openxmlformats-officedocument.presentationml.template",
".potm": "application/vnd.ms-powerpoint.template.macroEnabled.12",
".key": "application/x-iwork-keynote-sffkey",
".odp": "application/vnd.oasis.opendocument.presentation",
".odg": "application/vnd.oasis.opendocument.graphics",
".otp": "application/vnd.oasis.opendocument.presentation-template",
".fopd": "application/vnd.oasis.opendocument.presentation",
".sxi": "application/vnd.sun.xml.impress",
".sti": "application/vnd.sun.xml.impress.template",
".epub": "application/epub+zip",
".html": "text/html",
".htm": "text/html",
};
/**
* Represents a reader for parsing files using the LlamaParse API.
* See https://github.com/run-llama/llama_parse
*/
export class LlamaParseReader implements FileReader {
// The API key for the LlamaParse API.
apiKey: string;
// The base URL of the Llama Parsing API.
baseUrl: string = "https://api.cloud.llamaindex.ai/api/parsing";
// The maximum timeout in seconds to wait for the parsing to finish.
maxTimeout = 2000;
// The interval in seconds to check if the parsing is done.
checkInterval = 1;
// Whether to print the progress of the parsing.
verbose = true;
// The result type for the parser.
resultType: ResultType = "text";
// The language of the text to parse.
language: Language = "en";
// The parsing instruction for the parser.
parsingInstruction: string = "";
constructor(params: Partial<LlamaParseReader> = {}) {
Object.assign(this, params);
params.apiKey = params.apiKey ?? getEnv("LLAMA_CLOUD_API_KEY");
if (!params.apiKey) {
throw new Error(
"API Key is required for LlamaParseReader. Please pass the apiKey parameter or set the LLAMA_CLOUD_API_KEY environment variable.",
);
}
this.apiKey = params.apiKey;
}
async loadData(file: string): Promise<Document[]> {
const metadata = { file_path: file };
// Load data, set the mime type
const data = await fs.readFile(file);
const mimeType = await this.getMimeType(data);
const body = new FormData();
body.set("file", new Blob([data], { type: mimeType }), file);
body.append("language", this.language);
body.append("parsingInstruction", this.parsingInstruction);
const headers = {
Authorization: `Bearer ${this.apiKey}`,
};
// Send the request, start job
const url = `${this.baseUrl}/upload`;
let response = await fetch(url, {
signal: AbortSignal.timeout(this.maxTimeout * 1000),
method: "POST",
body,
headers,
});
if (!response.ok) {
throw new Error(`Failed to parse the file: ${await response.text()}`);
}
const jsonResponse = await response.json();
// Check the status of the job, return when done
const jobId = jsonResponse.id;
if (this.verbose) {
console.log(`Started parsing the file under job id ${jobId}`);
}
const resultUrl = `${this.baseUrl}/job/${jobId}/result/${this.resultType}`;
const start = Date.now();
let tries = 0;
while (true) {
await new Promise((resolve) =>
setTimeout(resolve, this.checkInterval * 1000),
);
response = await fetch(resultUrl, {
headers,
signal: AbortSignal.timeout(this.maxTimeout * 1000),
});
if (!response.ok) {
const end = Date.now();
if (end - start > this.maxTimeout * 1000) {
throw new Error(
`Timeout while parsing the file: ${await response.text()}`,
);
}
if (this.verbose && tries % 10 === 0) {
process.stdout.write(".");
}
tries++;
continue;
}
const resultJson = await response.json();
return [
new Document({
text: resultJson[this.resultType],
metadata: metadata,
}),
];
}
}
private async getMimeType(data: Buffer): Promise<string> {
const mimes = filetypemime(data);
const validMime = mimes.find((mime) =>
Object.values(SupportedFiles).includes(mime),
);
if (!validMime) {
const supportedExtensions = Object.keys(SupportedFiles).join(", ");
throw new Error(
`File has type "${mimes}" which does not match supported MIME Types. Supported formats include: ${supportedExtensions}`,
);
}
return validMime;
}
}
-36
View File
@@ -1,36 +0,0 @@
import { fs } from "@llamaindex/env";
import { Document } from "../Node.js";
import type { BaseReader } from "./type.js";
/**
* Read the text of a PDF
*/
export class PDFReader implements BaseReader {
async loadData(file: string): Promise<Document[]> {
const content = await fs.readFile(file);
const pages = await readPDF(content);
return pages.map((text, page) => {
const id_ = `${file}_${page + 1}`;
const metadata = {
page_number: page + 1,
};
return new Document({ text, id_, metadata });
});
}
}
async function readPDF(data: Buffer): Promise<string[]> {
const parser = await import("pdf2json").then(
({ default: Pdfparser }) => new Pdfparser(null, 1),
);
const text = await new Promise<string>((resolve, reject) => {
parser.on("pdfParser_dataError", (error) => {
reject(error);
});
parser.on("pdfParser_dataReady", () => {
resolve((parser as any).getRawTextContent() as string);
});
parser.parseBuffer(data);
});
return text.split(/----------------Page \(\d+\) Break----------------/g);
}
@@ -1,131 +0,0 @@
import { fs, path } from "@llamaindex/env";
import { Document, type Metadata } from "../Node.js";
import { walk } from "../storage/FileSystem.js";
import { TextFileReader } from "./TextFileReader.js";
import type { BaseReader } from "./type.js";
type ReaderCallback = (
category: "file" | "directory",
name: string,
status: ReaderStatus,
message?: string,
) => boolean;
enum ReaderStatus {
STARTED = 0,
COMPLETE,
ERROR,
}
export type SimpleDirectoryReaderLoadDataParams = {
directoryPath: string;
defaultReader?: BaseReader | null;
fileExtToReader?: Record<string, BaseReader>;
};
/**
* Read all the documents in a directory.
* By default, supports the list of file types
* in the FILE_EXT_TO_READER map.
*/
export class SimpleDirectoryReader implements BaseReader {
constructor(private observer?: ReaderCallback) {}
async loadData(
params: SimpleDirectoryReaderLoadDataParams,
): Promise<Document[]>;
async loadData(directoryPath: string): Promise<Document[]>;
async loadData(
params: SimpleDirectoryReaderLoadDataParams | string,
): Promise<Document[]> {
if (typeof params === "string") {
params = { directoryPath: params };
}
const {
directoryPath,
defaultReader = new TextFileReader(),
fileExtToReader,
} = params;
// Observer can decide to skip the directory
if (
!this.doObserverCheck("directory", directoryPath, ReaderStatus.STARTED)
) {
return [];
}
const docs: Document[] = [];
for await (const filePath of walk(directoryPath)) {
try {
const fileExt = path.extname(filePath).slice(1).toLowerCase();
// Observer can decide to skip each file
if (!this.doObserverCheck("file", filePath, ReaderStatus.STARTED)) {
// Skip this file
continue;
}
let reader: BaseReader;
if (fileExtToReader && fileExt in fileExtToReader) {
reader = fileExtToReader[fileExt];
} else if (defaultReader != null) {
reader = defaultReader;
} else {
const msg = `No reader for file extension of ${filePath}`;
console.warn(msg);
// In an error condition, observer's false cancels the whole process.
if (
!this.doObserverCheck("file", filePath, ReaderStatus.ERROR, msg)
) {
return [];
}
continue;
}
const fileDocs = await reader.loadData(filePath, fs);
fileDocs.forEach(addMetaData(filePath));
// Observer can still cancel addition of the resulting docs from this file
if (this.doObserverCheck("file", filePath, ReaderStatus.COMPLETE)) {
docs.push(...fileDocs);
}
} catch (e) {
const msg = `Error reading file ${filePath}: ${e}`;
console.error(msg);
// In an error condition, observer's false cancels the whole process.
if (!this.doObserverCheck("file", filePath, ReaderStatus.ERROR, msg)) {
return [];
}
}
}
// After successful import of all files, directory completion
// is only a notification for observer, cannot be cancelled.
this.doObserverCheck("directory", directoryPath, ReaderStatus.COMPLETE);
return docs;
}
private doObserverCheck(
category: "file" | "directory",
name: string,
status: ReaderStatus,
message?: string,
): boolean {
if (this.observer) {
return this.observer(category, name, status, message);
}
return true;
}
}
function addMetaData(filePath: string): (doc: Document<Metadata>) => void {
return (doc: Document<Metadata>) => {
doc.metadata["file_path"] = path.resolve(filePath);
doc.metadata["file_name"] = path.basename(filePath);
};
}
@@ -1,14 +0,0 @@
import { fs } from "@llamaindex/env";
import { Document } from "../Node.js";
import type { BaseReader } from "./type.js";
/**
* Read a .txt file
*/
export class TextFileReader implements BaseReader {
async loadData(file: string): Promise<Document[]> {
const dataBuffer = await fs.readFile(file, "utf-8");
return [new Document({ text: dataBuffer, id_: file })];
}
}
+6
View File
@@ -1,5 +1,11 @@
# @llamaindex/env
## 0.1.4
### Patch Changes
- 56fabbb: Release env changes to tokenizer
## 0.1.3
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/env",
"version": "0.1.3",
"version": "0.1.4",
"exports": {
".": "./src/index.ts"
},
+8 -5
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/env",
"description": "environment wrapper, supports all JS environment including node, deno, bun, edge runtime, and cloudflare worker",
"version": "0.1.3",
"version": "0.1.4",
"type": "module",
"types": "dist/type/index.d.ts",
"main": "dist/cjs/index.js",
@@ -48,7 +48,8 @@
},
"files": [
"dist",
"CHANGELOG.md"
"CHANGELOG.md",
"!**/*.tsbuildinfo"
],
"repository": {
"type": "git",
@@ -68,18 +69,20 @@
"devDependencies": {
"@aws-crypto/sha256-js": "^5.2.0",
"@swc/cli": "^0.3.12",
"@swc/core": "^1.5.5",
"@swc/core": "^1.6.3",
"concurrently": "^8.2.2",
"pathe": "^1.1.2",
"vitest": "^1.6.0"
},
"dependencies": {
"@types/lodash": "^4.17.1",
"@types/lodash": "^4.17.5",
"@types/node": "^20.12.11"
},
"peerDependencies": {
"@aws-crypto/sha256-js": "^5.2.0",
"pathe": "^1.1.2"
"js-tiktoken": "^1.0.12",
"pathe": "^1.1.2",
"tiktoken": "^1.0.15"
},
"peerDependenciesMeta": {
"@aws-crypto/sha256-js": {
+2
View File
@@ -4,3 +4,5 @@
* @module
*/
export * from "./polyfill.js";
export { Tokenizers, tokenizers, type Tokenizer } from "./tokenizers/js.js";
+4 -3
View File
@@ -35,14 +35,15 @@ export function createSHA256(): SHA256 {
};
}
export { Tokenizers, tokenizers, type Tokenizer } from "./tokenizers/node.js";
export { AsyncLocalStorage, CustomEvent, getEnv, setEnvs } from "./utils.js";
export {
EOL,
ReadableStream,
TransformStream,
WritableStream,
fs,
ok,
path,
randomUUID,
ReadableStream,
TransformStream,
WritableStream,
};
+2
View File
@@ -12,3 +12,5 @@ export * from "./polyfill.js";
export function getEnv(name: string): string | undefined {
return INTERNAL_ENV[name];
}
export { Tokenizers, tokenizers, type Tokenizer } from "./tokenizers/node.js";
+35
View File
@@ -0,0 +1,35 @@
// Note: js-tiktoken it's 60x slower than the WASM implementation - use it only for unsupported environments
import { getEncoding } from "js-tiktoken";
import type { Tokenizer } from "./types.js";
import { Tokenizers } from "./types.js";
class TokenizerSingleton {
private defaultTokenizer: Tokenizer;
constructor() {
const encoding = getEncoding("cl100k_base");
this.defaultTokenizer = {
encode: (text: string) => {
return new Uint32Array(encoding.encode(text));
},
decode: (tokens: Uint32Array) => {
const numberArray = Array.from(tokens);
const text = encoding.decode(numberArray);
const uint8Array = new TextEncoder().encode(text);
return new TextDecoder().decode(uint8Array);
},
};
}
tokenizer(encoding?: Tokenizers) {
if (encoding && encoding !== Tokenizers.CL100K_BASE) {
throw new Error(`Tokenizer encoding ${encoding} not yet supported`);
}
return this.defaultTokenizer;
}
}
export const tokenizers = new TokenizerSingleton();
export { Tokenizers, type Tokenizer };
+38
View File
@@ -0,0 +1,38 @@
// Note: This is using th WASM implementation of tiktoken which is 60x faster
import cl100k_base from "tiktoken/encoders/cl100k_base.json";
import { Tiktoken } from "tiktoken/lite";
import type { Tokenizer } from "./types.js";
import { Tokenizers } from "./types.js";
class TokenizerSingleton {
private defaultTokenizer: Tokenizer;
constructor() {
const encoding = new Tiktoken(
cl100k_base.bpe_ranks,
cl100k_base.special_tokens,
cl100k_base.pat_str,
);
this.defaultTokenizer = {
encode: (text: string) => {
return encoding.encode(text);
},
decode: (tokens: Uint32Array) => {
const text = encoding.decode(tokens);
return new TextDecoder().decode(text);
},
};
}
tokenizer(encoding?: Tokenizers): Tokenizer {
if (encoding && encoding !== Tokenizers.CL100K_BASE) {
throw new Error(`Tokenizer encoding ${encoding} not yet supported`);
}
return this.defaultTokenizer;
}
}
export const tokenizers: TokenizerSingleton = new TokenizerSingleton();
export { Tokenizers, type Tokenizer };
+8
View File
@@ -0,0 +1,8 @@
export enum Tokenizers {
CL100K_BASE = "cl100k_base",
}
export interface Tokenizer {
encode: (text: string) => Uint32Array;
decode: (tokens: Uint32Array) => string;
}
+2 -1
View File
@@ -7,7 +7,8 @@
"emitDeclarationOnly": true,
"module": "node16",
"moduleResolution": "node16",
"types": ["node"]
"types": ["node"],
"resolveJsonModule": true
},
"include": ["./src"],
"exclude": ["node_modules"]
+61
View File
@@ -1,5 +1,66 @@
# @llamaindex/experimental
## 0.0.36
### Patch Changes
- Updated dependencies [3c47910]
- Updated dependencies [ed467a9]
- Updated dependencies [cba5406]
- llamaindex@0.4.1
## 0.0.35
### Patch Changes
- Updated dependencies [436bc41]
- Updated dependencies [a44e54f]
- Updated dependencies [a51ed8d]
- Updated dependencies [d3b635b]
- llamaindex@0.4.0
## 0.0.34
### Patch Changes
- Updated dependencies [6bc5bdd]
- Updated dependencies [bf25ff6]
- Updated dependencies [e6d6576]
- llamaindex@0.3.17
## 0.0.33
### Patch Changes
- Updated dependencies [11ae926]
- Updated dependencies [631f000]
- Updated dependencies [1378ec4]
- Updated dependencies [6b1ded4]
- Updated dependencies [4d4bd85]
- Updated dependencies [24a9d1e]
- Updated dependencies [45952de]
- Updated dependencies [54230f0]
- Updated dependencies [a29d835]
- Updated dependencies [73819bf]
- llamaindex@0.3.16
## 0.0.32
### Patch Changes
- Updated dependencies [6e156ed]
- Updated dependencies [265976d]
- Updated dependencies [8e26f75]
- llamaindex@0.3.15
## 0.0.31
### Patch Changes
- Updated dependencies [6ff7576]
- Updated dependencies [94543de]
- llamaindex@0.3.14
## 0.0.30
### Patch Changes
+5 -4
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/experimental",
"description": "Experimental package for LlamaIndexTS",
"version": "0.0.30",
"version": "0.0.36",
"type": "module",
"types": "dist/type/index.d.ts",
"main": "dist/cjs/index.js",
@@ -37,7 +37,8 @@
},
"files": [
"dist",
"CHANGELOG.md"
"CHANGELOG.md",
"!**/*.tsbuildinfo"
],
"repository": {
"type": "git",
@@ -56,13 +57,13 @@
"devDependencies": {
"@aws-crypto/sha256-js": "^5.2.0",
"@swc/cli": "^0.3.12",
"@swc/core": "^1.5.5",
"@swc/core": "^1.6.3",
"@types/jsonpath": "^0.2.4",
"concurrently": "^8.2.2",
"pathe": "^1.1.2"
},
"dependencies": {
"@types/lodash": "^4.17.1",
"@types/lodash": "^4.17.5",
"@types/node": "^20.12.11",
"jsonpath": "^1.1.1",
"llamaindex": "workspace:*",
@@ -1,6 +1,6 @@
import jsonpath from "jsonpath";
import { Response } from "llamaindex";
import { EngineResponse } from "llamaindex";
import { serviceContextFromDefaults, type ServiceContext } from "llamaindex";
@@ -147,11 +147,13 @@ export class JSONQueryEngine implements QueryEngine {
return JSON.stringify(this.jsonSchema);
}
query(params: QueryEngineParamsStreaming): Promise<AsyncIterable<Response>>;
query(params: QueryEngineParamsNonStreaming): Promise<Response>;
query(
params: QueryEngineParamsStreaming,
): Promise<AsyncIterable<EngineResponse>>;
query(params: QueryEngineParamsNonStreaming): Promise<EngineResponse>;
async query(
params: QueryEngineParamsStreaming | QueryEngineParamsNonStreaming,
): Promise<Response | AsyncIterable<Response>> {
): Promise<EngineResponse | AsyncIterable<EngineResponse>> {
const { query, stream } = params;
if (stream) {
@@ -200,7 +202,7 @@ export class JSONQueryEngine implements QueryEngine {
jsonPathResponseStr,
};
const response = new Response(responseStr, []);
const response = EngineResponse.fromResponse(responseStr, false);
response.metadata = responseMetadata;
+1 -1
View File
@@ -13,7 +13,7 @@
"exclude": ["node_modules"],
"references": [
{
"path": "../core/tsconfig.json"
"path": "../llamaindex/tsconfig.json"
}
]
}
@@ -1,5 +1,65 @@
# llamaindex
## 0.4.1
### Patch Changes
- 3c47910: fix: groq llm
- ed467a9: Add model ids for Anthropic Claude 3.5 Sonnet model on Anthropic and Bedrock
- cba5406: fix: every Llama Parse job being called "blob"
- Updated dependencies [56fabbb]
- @llamaindex/env@0.1.4
## 0.4.0
### Minor Changes
- 436bc41: Unify chat engine response and agent response
### Patch Changes
- a44e54f: Truncate text to embed for OpenAI if it exceeds maxTokens
- a51ed8d: feat: add support for managed identity for Azure OpenAI
- d3b635b: fix: agents to use chat history
## 0.3.17
### Patch Changes
- 6bc5bdd: feat: add cache disabling, fast mode, do not unroll columns mode and custom page seperator to LlamaParseReader
- bf25ff6: fix: polyfill for cloudflare worker
- e6d6576: chore: use `unpdf`
## 0.3.16
### Patch Changes
- 11ae926: feat: add numCandidates setting to MongoDBAtlasVectorStore for tuning queries
- 631f000: feat: DeepInfra LLM implementation
- 1378ec4: feat: set default model to `gpt-4o`
- 6b1ded4: add gpt4o-mode, invalidate cache and skip diagonal text to LlamaParseReader
- 4d4bd85: Show error message if agent tool is called with partial JSON
- 24a9d1e: add json mode and image retrieval to LlamaParseReader
- 45952de: add concurrency management for SimpleDirectoryReader
- 54230f0: feat: Gemini GA release models
- a29d835: setDocumentHash should be async
- 73819bf: Unify metadata and ID handling of documents, allow files to be read by `Buffer`
## 0.3.15
### Patch Changes
- 6e156ed: Use images in context chat engine
- 265976d: fix bug with node decorator
- 8e26f75: Add retrieval for images using multi-modal messages
## 0.3.14
### Patch Changes
- 6ff7576: Added GPT-4o for Azure
- 94543de: Added the latest preview gemini models and multi modal images taken into account
## 0.3.13
### Patch Changes
@@ -41,7 +41,7 @@ To run them, run
pnpm run test
```
To write new test cases write them in [packages/core/src/tests](/packages/core/src/tests)
To write new test cases write them in [packages/core/src/tests](/packages/llamaindex/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
@@ -1,5 +1,11 @@
# @llamaindex/core-e2e
## 0.0.7
### Patch Changes
- bf25ff6: fix: polyfill for cloudflare worker
## 0.0.6
### Patch Changes
@@ -1,5 +1,67 @@
# @llamaindex/cloudflare-worker-agent-test
## 0.0.20
### Patch Changes
- Updated dependencies [3c47910]
- Updated dependencies [ed467a9]
- Updated dependencies [cba5406]
- llamaindex@0.4.1
## 0.0.19
### Patch Changes
- Updated dependencies [436bc41]
- Updated dependencies [a44e54f]
- Updated dependencies [a51ed8d]
- Updated dependencies [d3b635b]
- llamaindex@0.4.0
## 0.0.18
### Patch Changes
- bf25ff6: fix: polyfill for cloudflare worker
- Updated dependencies [6bc5bdd]
- Updated dependencies [bf25ff6]
- Updated dependencies [e6d6576]
- llamaindex@0.3.17
## 0.0.17
### Patch Changes
- Updated dependencies [11ae926]
- Updated dependencies [631f000]
- Updated dependencies [1378ec4]
- Updated dependencies [6b1ded4]
- Updated dependencies [4d4bd85]
- Updated dependencies [24a9d1e]
- Updated dependencies [45952de]
- Updated dependencies [54230f0]
- Updated dependencies [a29d835]
- Updated dependencies [73819bf]
- llamaindex@0.3.16
## 0.0.16
### Patch Changes
- Updated dependencies [6e156ed]
- Updated dependencies [265976d]
- Updated dependencies [8e26f75]
- llamaindex@0.3.15
## 0.0.15
### Patch Changes
- Updated dependencies [6ff7576]
- Updated dependencies [94543de]
- llamaindex@0.3.14
## 0.0.14
### Patch Changes
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/cloudflare-worker-agent-test",
"version": "0.0.14",
"version": "0.0.20",
"type": "module",
"private": true,
"scripts": {
@@ -12,13 +12,13 @@
"cf-typegen": "wrangler types"
},
"devDependencies": {
"@cloudflare/vitest-pool-workers": "^0.2.6",
"@cloudflare/workers-types": "^4.20240502.0",
"@cloudflare/vitest-pool-workers": "^0.4.3",
"@cloudflare/workers-types": "^4.20240605.0",
"@vitest/runner": "1.3.0",
"@vitest/snapshot": "1.3.0",
"typescript": "^5.4.5",
"typescript": "^5.5.2",
"vitest": "1.3.0",
"wrangler": "^3.53.1"
"wrangler": "^3.60.1"
},
"dependencies": {
"llamaindex": "workspace:*"

Some files were not shown because too many files have changed in this diff Show More