Skip to content
Snippets Groups Projects
Unverified Commit 570973b9 authored by Alex Yang's avatar Alex Yang Committed by GitHub
Browse files

docs: add stackblitz playground (#439)

parent 09d19b99
No related branches found
No related tags found
No related merge requests found
...@@ -11,6 +11,10 @@ Use your own data with large language models (LLMs, OpenAI ChatGPT and others) i ...@@ -11,6 +11,10 @@ Use your own data with large language models (LLMs, OpenAI ChatGPT and others) i
Documentation: https://ts.llamaindex.ai/ Documentation: https://ts.llamaindex.ai/
Try examples online:
[![Open in Stackblitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/run-llama/LlamaIndexTS/tree/main/examples)
## What is LlamaIndex.TS? ## 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. 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.
......
# 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 ## Usage
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
Make sure to call `npm install` before running these examples: ```shell
# export your API key
export OPENAI_API_KEY="sk-..."
```bash npx ts-node ./chatEngine.ts
npm install
``` ```
Then run the examples with `ts-node`, for example `npx ts-node vectorIndex.ts` ## Build your own RAG app
## Using the local build
```bash ```shell
pnpm install npx create llama
pnpm --filter llamaindex build
pnpm link ../packages/core
``` ```
Then run the examples with `ts-node`, for example `pnpx ts-node vectorIndex.ts`
...@@ -10,7 +10,7 @@ import { ...@@ -10,7 +10,7 @@ import {
VectorStoreIndex, VectorStoreIndex,
} from "llamaindex"; } from "llamaindex";
import essay from "./essay.js"; import essay from "./essay";
async function main() { async function main() {
const document = new Document({ text: essay }); const document = new Document({ text: essay });
......
...@@ -3,7 +3,7 @@ import { ...@@ -3,7 +3,7 @@ import {
KeywordTableIndex, KeywordTableIndex,
KeywordTableRetrieverMode, KeywordTableRetrieverMode,
} from "llamaindex"; } from "llamaindex";
import essay from "./essay.js"; import essay from "./essay";
async function main() { async function main() {
const document = new Document({ text: essay, id_: "essay" }); const document = new Document({ text: essay, id_: "essay" });
......
{ {
"version": "0.0.3",
"private": true,
"name": "examples", "name": "examples",
"private": true,
"dependencies": { "dependencies": {
"@datastax/astra-db-ts": "^0.1.2", "@datastax/astra-db-ts": "^0.1.2",
"@notionhq/client": "^2.2.14", "@notionhq/client": "^2.2.14",
......
...@@ -6,7 +6,7 @@ import { ...@@ -6,7 +6,7 @@ import {
VectorStoreIndex, VectorStoreIndex,
serviceContextFromDefaults, serviceContextFromDefaults,
} from "llamaindex"; } from "llamaindex";
import essay from "./essay.js"; import essay from "./essay";
async function main() { async function main() {
const document = new Document({ text: essay, id_: "essay" }); const document = new Document({ text: essay, id_: "essay" });
......
...@@ -3,7 +3,7 @@ import { ...@@ -3,7 +3,7 @@ import {
storageContextFromDefaults, storageContextFromDefaults,
VectorStoreIndex, VectorStoreIndex,
} from "llamaindex"; } from "llamaindex";
import essay from "./essay.js"; import essay from "./essay";
async function main() { async function main() {
// Create Document object with essay // Create Document object with essay
......
import { Document, SubQuestionQueryEngine, VectorStoreIndex } from "llamaindex"; import { Document, SubQuestionQueryEngine, VectorStoreIndex } from "llamaindex";
import essay from "./essay.js"; import essay from "./essay";
(async () => { (async () => {
const document = new Document({ text: essay, id_: essay }); const document = new Document({ text: essay, id_: essay });
......
...@@ -5,7 +5,7 @@ import { ...@@ -5,7 +5,7 @@ import {
SummaryRetrieverMode, SummaryRetrieverMode,
serviceContextFromDefaults, serviceContextFromDefaults,
} from "llamaindex"; } from "llamaindex";
import essay from "./essay.js"; import essay from "./essay";
async function main() { async function main() {
const serviceContext = serviceContextFromDefaults({ const serviceContext = serviceContextFromDefaults({
......
{ {
"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": { "ts-node": {
"files": true, "files": true,
"compilerOptions": { "compilerOptions": {
......
...@@ -6,7 +6,7 @@ import { ...@@ -6,7 +6,7 @@ import {
SimilarityPostprocessor, SimilarityPostprocessor,
VectorStoreIndex, VectorStoreIndex,
} from "llamaindex"; } from "llamaindex";
import essay from "./essay.js"; import essay from "./essay";
// Customize retrieval and query args // Customize retrieval and query args
async function main() { async function main() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment