diff --git a/README.md b/README.md index 93bd71413f9d050fdcdf58a15946f13eb6b65d7c..4d52c6abe64f1542b41af19dd43a14ab6e2d7eee 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,10 @@ Use your own data with large language models (LLMs, OpenAI ChatGPT and others) i Documentation: https://ts.llamaindex.ai/ +Try examples online: + +[](https://stackblitz.com/github/run-llama/LlamaIndexTS/tree/main/examples) + ## What is LlamaIndex.TS? LlamaIndex.TS aims to be a lightweight, easy to use set of libraries to help you integrate large language models into your applications with your own data. diff --git a/examples/README.md b/examples/README.md index eb16a1088305b7bf908ffc732f4122bc43eb7926..2b4fc0db5b1712aad5f17f064717f260442e5e9f 100644 --- a/examples/README.md +++ b/examples/README.md @@ -1,29 +1,19 @@ -# Simple Examples +# LlamaIndexTS Examples -Before running any of the examples, make sure to set your OpenAI environment variable: +Before running any of the code examples, +make sure you have basic knowledge of the [LlamaIndexTS](https://ts.llamaindex.ai/). -```bash -export OPENAI_API_KEY="sk-..." -``` - -There are two ways to run the examples, using the latest published version of `llamaindex` or using a local build. - -## Using the latest published version +## Usage -Make sure to call `npm install` before running these examples: +```shell +# export your API key +export OPENAI_API_KEY="sk-..." -```bash -npm install +npx ts-node ./chatEngine.ts ``` -Then run the examples with `ts-node`, for example `npx ts-node vectorIndex.ts` - -## Using the local build +## Build your own RAG app -```bash -pnpm install -pnpm --filter llamaindex build -pnpm link ../packages/core +```shell +npx create llama ``` - -Then run the examples with `ts-node`, for example `pnpx ts-node vectorIndex.ts` diff --git a/examples/chatEngine.ts b/examples/chatEngine.ts index eb7580ac75086723a587cc80658ca4383d2395c9..52538944b5f95c9f6de426841590d5e0599a9c4a 100644 --- a/examples/chatEngine.ts +++ b/examples/chatEngine.ts @@ -10,7 +10,7 @@ import { VectorStoreIndex, } from "llamaindex"; -import essay from "./essay.js"; +import essay from "./essay"; async function main() { const document = new Document({ text: essay }); diff --git a/examples/keywordIndex.ts b/examples/keywordIndex.ts index edca73fbc18ee5de4df02836333311232b498cff..ad6c7b1d3642083fd67be9b6790c68d164a85f8f 100644 --- a/examples/keywordIndex.ts +++ b/examples/keywordIndex.ts @@ -3,7 +3,7 @@ import { KeywordTableIndex, KeywordTableRetrieverMode, } from "llamaindex"; -import essay from "./essay.js"; +import essay from "./essay"; async function main() { const document = new Document({ text: essay, id_: "essay" }); diff --git a/examples/package.json b/examples/package.json index b0c8fcc53dd2ddf9c0b4ac011003d1c2ecb5cb48..66bec6144fddf465406388a0b5a58d659773f76b 100644 --- a/examples/package.json +++ b/examples/package.json @@ -1,7 +1,6 @@ { - "version": "0.0.3", - "private": true, "name": "examples", + "private": true, "dependencies": { "@datastax/astra-db-ts": "^0.1.2", "@notionhq/client": "^2.2.14", diff --git a/examples/sentenceWindow.ts b/examples/sentenceWindow.ts index 63c303faaef7b2688459bf470d206e7fda0047f6..fcb89d99d7b946cf0f08da381f3b6bff76b80d72 100644 --- a/examples/sentenceWindow.ts +++ b/examples/sentenceWindow.ts @@ -6,7 +6,7 @@ import { VectorStoreIndex, serviceContextFromDefaults, } from "llamaindex"; -import essay from "./essay.js"; +import essay from "./essay"; async function main() { const document = new Document({ text: essay, id_: "essay" }); diff --git a/examples/storageContext.ts b/examples/storageContext.ts index 9f62f8f7372e0af121662aa4f183aac4fe6d8bb5..74fbd43fba868bb46ba11edf8347e1e6a6d97548 100644 --- a/examples/storageContext.ts +++ b/examples/storageContext.ts @@ -3,7 +3,7 @@ import { storageContextFromDefaults, VectorStoreIndex, } from "llamaindex"; -import essay from "./essay.js"; +import essay from "./essay"; async function main() { // Create Document object with essay diff --git a/examples/subquestion.ts b/examples/subquestion.ts index 772447581411e5c233efa40b7436e7585474b151..b1e692e1f305668a21f8ac12076ea247cc7046e8 100644 --- a/examples/subquestion.ts +++ b/examples/subquestion.ts @@ -1,6 +1,6 @@ import { Document, SubQuestionQueryEngine, VectorStoreIndex } from "llamaindex"; -import essay from "./essay.js"; +import essay from "./essay"; (async () => { const document = new Document({ text: essay, id_: essay }); diff --git a/examples/summaryIndex.ts b/examples/summaryIndex.ts index 9f7b6c8238de14bb3a8e445ed81e90435be7c394..d11a47031af81146ba8a3b45fc8250d82f4b4614 100644 --- a/examples/summaryIndex.ts +++ b/examples/summaryIndex.ts @@ -5,7 +5,7 @@ import { SummaryRetrieverMode, serviceContextFromDefaults, } from "llamaindex"; -import essay from "./essay.js"; +import essay from "./essay"; async function main() { const serviceContext = serviceContextFromDefaults({ diff --git a/examples/tsconfig.json b/examples/tsconfig.json index 05ebd271f69172732a92bb211a4e97c3b03e12ec..289a2d66dc6a249aeca758ac7f1da6504e38e67e 100644 --- a/examples/tsconfig.json +++ b/examples/tsconfig.json @@ -1,5 +1,17 @@ { - "extends": "../tsconfig.json", + "compilerOptions": { + "target": "es2016", + "module": "esnext", + "moduleResolution": "bundler", + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "skipLibCheck": true, + "outDir": "./lib", + "tsBuildInfoFile": "./lib/.tsbuildinfo", + "incremental": true, + "composite": true, + }, "ts-node": { "files": true, "compilerOptions": { diff --git a/examples/vectorIndexCustomize.ts b/examples/vectorIndexCustomize.ts index 48175f2afa62242b0458b427df7cb6d8a0be6a8b..e9013a0e6510b0cea292b53bd959bbcc787132b3 100644 --- a/examples/vectorIndexCustomize.ts +++ b/examples/vectorIndexCustomize.ts @@ -6,7 +6,7 @@ import { SimilarityPostprocessor, VectorStoreIndex, } from "llamaindex"; -import essay from "./essay.js"; +import essay from "./essay"; // Customize retrieval and query args async function main() {