Compare commits

...

23 Commits

Author SHA1 Message Date
github-actions[bot] 449274ca5a Release 0.6.12 (#1273)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-09-30 16:34:14 -07:00
Alex Yang 78037a664c chore: update changelog 2024-09-30 16:13:22 -07:00
Alex Yang 1d9e3b1000 fix: export llama reader in non-nodejs runtime (#1279) 2024-09-30 16:13:07 -07:00
Alex Yang df83e32107 fix: bypass service context embed model (#1280) 2024-09-30 16:02:48 -07:00
Thuc Pham f7b4e94231 feat: add filters for pinecone (#1272) 2024-09-30 17:04:43 +07:00
Marcus Schiesser 4c07a2655d text: add cycle test (#1270) 2024-09-29 23:13:59 -07:00
Marcus Schiesser 5c0c8b2ec4 test: add concurrent test for workflows (#1269) 2024-09-29 22:10:21 -07:00
Emmanuel Ferdman e5e18688a6 fix: update reader reference (#1268)
Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
2024-09-28 14:44:44 -07:00
github-actions[bot] b6fb10eba8 Release 0.6.11 (#1267)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-09-27 13:19:52 -07:00
Alex Yang df441e28f4 chore: release for new env package 2024-09-27 12:54:14 -07:00
github-actions[bot] a4e05ec7ab Release 0.6.10 (#1263)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-09-27 01:51:07 -07:00
irevived1 96f72ad86e fix: openai streaming with token usage and finish_reason (#1265)
Co-authored-by: Alex Yang <himself65@outlook.com>
2024-09-26 17:51:59 -07:00
Alex Yang f3556c011c chore: update changeset 2024-09-26 09:36:20 -07:00
Alex Yang ebc510582b feat: support @vercel/postgres (#1262) 2024-09-25 22:39:32 -07:00
Alex Yang f3bfdc29e3 chore: fix changeset 2024-09-25 20:09:37 -07:00
Alex Yang 6cce3b12ea feat: support npm:postgres (#1248) 2024-09-25 19:40:20 -07:00
Alex Yang 0273e9739a chore: fix docs build with turbo (#1260) 2024-09-25 07:32:37 -07:00
Alex Yang 7c8b883448 fix: turbo cache (#1259) 2024-09-25 04:47:01 -07:00
Alex Yang c2bb418542 chore: fix url in package.json (#1258) 2024-09-25 03:52:33 -07:00
Alex Yang ed6acbead0 fix(core): backward support for legacy typescript (#1257) 2024-09-25 03:19:41 -07:00
Alex Yang 976cce40d7 docs: update README.md (#1255) 2024-09-24 15:03:48 -07:00
Alex Yang e4fd4158bb feat: move agent into core (#1254) 2024-09-24 14:55:40 -07:00
Alex Yang 31d5dffcef refactor: move ollama standalone (#1253) 2024-09-24 12:15:50 -07:00
153 changed files with 2353 additions and 2140 deletions
+11 -7
View File
@@ -89,13 +89,7 @@ jobs:
- name: Run Type Check
run: pnpm run type-check
- name: Run Circular Dependency Check
run: pnpm dlx turbo run circular-check
- uses: actions/upload-artifact@v3
if: failure()
with:
name: typecheck-build-dist
path: ./packages/llamaindex/dist
if-no-files-found: error
run: pnpm run circular-check
e2e-llamaindex-examples:
strategy:
fail-fast: false
@@ -151,6 +145,9 @@ jobs:
- name: Pack @llamaindex/groq
run: pnpm pack --pack-destination ${{ runner.temp }}
working-directory: packages/llm/groq
- name: Pack @llamaindex/ollama
run: pnpm pack --pack-destination ${{ runner.temp }}
working-directory: packages/llm/ollama
- name: Pack @llamaindex/core
run: pnpm pack --pack-destination ${{ runner.temp }}
working-directory: packages/core
@@ -166,3 +163,10 @@ jobs:
- name: Run Type Check
run: npx tsc --project ./tsconfig.json
working-directory: ${{ runner.temp }}/examples
- uses: actions/upload-artifact@v4
if: failure()
with:
name: build-dist
path: |
${{ runner.temp }}/*.tgz
if-no-files-found: error
+95 -44
View File
@@ -7,7 +7,7 @@
LlamaIndex is a data framework for your LLM application.
Use your own data with large language models (LLMs, OpenAI ChatGPT and others) in Typescript and Javascript.
Use your own data with large language models (LLMs, OpenAI ChatGPT and others) in JS runtime environments with TypeScript support.
Documentation: https://ts.llamaindex.ai/
@@ -19,17 +19,36 @@ Try examples online:
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.
## Multiple JS Environment Support
## Compatibility
### Multiple JS Environment Support
LlamaIndex.TS supports multiple JS environments, including:
- Node.js (18, 20, 22) ✅
- Deno ✅
- Bun ✅
- React Server Components (Next.js)
- Nitro
- Vercel Edge Runtime ✅ (with some limitations)
- Cloudflare Workers ✅ (with some limitations)
For now, browser support is limited due to the lack of support for [AsyncLocalStorage-like APIs](https://github.com/tc39/proposal-async-context)
### Supported LLMs:
- OpenAI LLms
- Anthropic LLms
- Groq LLMs
- Llama2, Llama3, Llama3.1 LLMs
- MistralAI LLMs
- Fireworks LLMs
- DeepSeek LLMs
- ReplicateAI LLMs
- TogetherAI LLMs
- HuggingFace LLms
- DeepInfra LLMs
- Gemini LLMs
## Getting started
```shell
@@ -77,7 +96,7 @@ See more about [moduleResolution](https://www.typescriptlang.org/docs/handbook/m
### Node.js
```ts
import fs from "fs/promises";
import fs from "node:fs/promises";
import { Document, VectorStoreIndex } from "llamaindex";
async function main() {
@@ -111,9 +130,9 @@ main();
node --import tsx ./main.ts
```
### React Server Component (Next.js, Waku, Redwood.JS...)
### Next.js
First, you will need to add a llamaindex plugin to your Next.js project.
You will need to add a llamaindex plugin to your Next.js project.
```js
// next.config.js
@@ -124,20 +143,18 @@ module.exports = withLlamaIndex({
});
```
You can combine `ai` with `llamaindex` in Next.js with RSC (React Server Components).
### React Server Actions
You can combine `ai` with `llamaindex` in Next.js, Waku or Redwood.js with RSC (React Server Components).
```tsx
// src/apps/page.tsx
"use client";
import { chatWithAgent } from "@/actions";
import type { JSX } from "react";
import { useFormState } from "react-dom";
// You can use the Edge runtime in Next.js by adding this line:
// export const runtime = "edge";
import { useActionState } from "react";
export default function Home() {
const [ui, action] = useFormState<JSX.Element | null>(async () => {
const [ui, action] = useActionState<JSX.Element | null>(async () => {
return chatWithAgent("hello!", []);
}, null);
return (
@@ -191,6 +208,48 @@ export async function chatWithAgent(
}
```
### Cloudflare Workers
> [!TIP]
> Some modules are not supported in Cloudflare Workers which require Node.js APIs.
```ts
// add `OPENAI_API_KEY` to the `.dev.vars` file
interface Env {
OPENAI_API_KEY: string;
}
export default {
async fetch(
request: Request,
env: Env,
ctx: ExecutionContext,
): Promise<Response> {
const { OpenAIAgent, OpenAI } = await import("@llamaindex/openai");
const text = await request.text();
const agent = new OpenAIAgent({
llm: new OpenAI({
apiKey: env.OPENAI_API_KEY,
}),
tools: [],
});
const responseStream = await agent.chat({
stream: true,
message: text,
});
const textEncoder = new TextEncoder();
const response = responseStream.pipeThrough<Uint8Array>(
new TransformStream({
transform: (chunk, controller) => {
controller.enqueue(textEncoder.encode(chunk.delta));
},
}),
);
return new Response(response);
},
};
```
### Vite
We have some wasm dependencies for better performance. You can use `vite-plugin-wasm` to load them.
@@ -206,29 +265,9 @@ export default {
};
```
## Playground
### Tips when using in non-Node.js environments
Check out our NextJS playground at https://llama-playground.vercel.app/. The source is available at https://github.com/run-llama/ts-playground
## Core concepts for getting started:
- [Document](/packages/llamaindex/src/Node.ts): A document represents a text file, PDF file or other contiguous piece of data.
- [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/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 question. 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/llamaindex/src/indices/): Indices store the Nodes and the embeddings of those nodes. QueryEngines retrieve Nodes from these Indices using embedding similarity.
- [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/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/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
When you are importing `llamaindex` in a non-Node.js environment(such as React Server Components, Cloudflare Workers, etc.)
When you are importing `llamaindex` in a non-Node.js environment(such as Vercel Edge, Cloudflare Workers, etc.)
Some classes are not exported from top-level entry file.
The reason is that some classes are only compatible with Node.js runtime,(e.g. `PDFReader`) which uses Node.js specific APIs(like `fs`, `child_process`, `crypto`).
@@ -264,19 +303,31 @@ export async function getDocuments() {
You'll find a complete example with LlamaIndexTS here: https://github.com/run-llama/create_llama_projects/tree/main/nextjs-edge-llamaparse
## Supported LLMs:
## Playground
- OpenAI GPT-3.5-turbo and GPT-4
- Anthropic Claude 3 (Opus, Sonnet, and Haiku) and the legacy models (Claude 2 and Instant)
- Groq LLMs
- Llama2/3 Chat LLMs (70B, 13B, and 7B parameters)
- MistralAI Chat LLMs
- Fireworks Chat LLMs
Check out our NextJS playground at https://llama-playground.vercel.app/. The source is available at https://github.com/run-llama/ts-playground
## Core concepts for getting started:
- [Document](/packages/llamaindex/src/Node.ts): A document represents a text file, PDF file or other contiguous piece of data.
- [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/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 question. 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/llamaindex/src/indices/): Indices store the Nodes and the embeddings of those nodes. QueryEngines retrieve Nodes from these Indices using embedding similarity.
- [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/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/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.
## Contributing:
We are in the very early days of LlamaIndex.TS. If youre interested in hacking on it with us check out our [contributing guide](/CONTRIBUTING.md)
Please see our [contributing guide](CONTRIBUTING.md) for more information.
You are highly encouraged to contribute to LlamaIndex.TS!
## Bugs? Questions?
## Community
Please join our Discord! https://discord.com/invite/eN6D2HQ4aX
+24
View File
@@ -1,5 +1,29 @@
# docs
## 0.0.81
### Patch Changes
- Updated dependencies [f7b4e94]
- Updated dependencies [78037a6]
- Updated dependencies [1d9e3b1]
- llamaindex@0.6.12
## 0.0.80
### Patch Changes
- Updated dependencies [df441e2]
- llamaindex@0.6.11
## 0.0.79
### Patch Changes
- Updated dependencies [ebc5105]
- Updated dependencies [6cce3b1]
- llamaindex@0.6.10
## 0.0.78
### Patch Changes
@@ -13,7 +13,7 @@ Official documentation for LlamaParse can be found [here](https://docs.cloud.lla
## Usage
You can then use the `LlamaParseReader` class to load 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/llamaindex/src/readers/LlamaParseReader.ts) for a list of supported file types:
See [reader.ts](https://github.com/run-llama/LlamaIndexTS/blob/main/packages/cloud/src/reader.ts) for a list of supported file types:
<CodeBlock language="ts">{CodeSource}</CodeBlock>
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "docs",
"version": "0.0.78",
"version": "0.0.81",
"private": true,
"scripts": {
"docusaurus": "docusaurus",
+8
View File
@@ -0,0 +1,8 @@
{
"extends": ["//"],
"tasks": {
"build": {
"outputs": ["build/**", ".docusaurus/**"]
}
}
}
+3 -1
View File
@@ -9,6 +9,7 @@
"@llamaindex/core": "^0.2.0",
"@notionhq/client": "^2.2.15",
"@pinecone-database/pinecone": "^3.0.2",
"@vercel/postgres": "^0.10.0",
"@zilliz/milvus2-sdk-node": "^2.4.6",
"chromadb": "^1.8.1",
"commander": "^12.1.0",
@@ -16,7 +17,8 @@
"js-tiktoken": "^1.0.14",
"llamaindex": "^0.6.0",
"mongodb": "^6.7.0",
"pathe": "^1.1.2"
"pathe": "^1.1.2",
"postgres": "^3.4.4"
},
"devDependencies": {
"@types/node": "^22.5.1",
+1 -1
View File
@@ -1,4 +1,4 @@
import { createMessageContent } from "@llamaindex/core/utils";
import { createMessageContent } from "@llamaindex/core/response-synthesizers";
import {
Document,
ImageNode,
+9
View File
@@ -0,0 +1,9 @@
# neon template
PGHOST=
PGDATABASE=
PGUSER=
PGPASSWORD=
ENDPOINT_ID=
# vercel template
POSTGRES_URL=
@@ -1,11 +1,11 @@
// load-docs.ts
import fs from "fs/promises";
import {
PGVectorStore,
SimpleDirectoryReader,
storageContextFromDefaults,
VectorStoreIndex,
} from "llamaindex";
import fs from "node:fs/promises";
async function getSourceFilenames(sourceDir: string) {
return await fs
+45
View File
@@ -0,0 +1,45 @@
/* eslint-disable turbo/no-undeclared-env-vars */
import dotenv from "dotenv";
import { Document, PGVectorStore, VectorStoreQueryMode } from "llamaindex";
import postgres from "postgres";
dotenv.config();
const { PGHOST, PGDATABASE, PGUSER, ENDPOINT_ID } = process.env;
const PGPASSWORD = decodeURIComponent(process.env.PGPASSWORD!);
const sql = postgres({
host: PGHOST,
database: PGDATABASE,
username: PGUSER,
password: PGPASSWORD,
port: 5432,
ssl: "require",
connection: {
options: `project=${ENDPOINT_ID}`,
},
});
await sql`CREATE EXTENSION IF NOT EXISTS vector`;
const vectorStore = new PGVectorStore({
dimensions: 3,
client: sql,
});
await vectorStore.add([
new Document({
text: "hello, world",
embedding: [1, 2, 3],
}),
]);
const results = await vectorStore.query({
mode: VectorStoreQueryMode.DEFAULT,
similarityTopK: 1,
queryEmbedding: [1, 2, 3],
});
console.log("result", results);
await sql.end();
+5
View File
@@ -0,0 +1,5 @@
{
"name": "pg-vector-store",
"type": "module",
"private": true
}
+9
View File
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./dist",
"types": ["node"],
"skipLibCheck": true
},
"include": ["./**/*.ts"]
}
+30
View File
@@ -0,0 +1,30 @@
// https://vercel.com/docs/storage/vercel-postgres/sdk
import { sql } from "@vercel/postgres";
import dotenv from "dotenv";
import { Document, PGVectorStore, VectorStoreQueryMode } from "llamaindex";
dotenv.config();
await sql`CREATE EXTENSION IF NOT EXISTS vector`;
const vectorStore = new PGVectorStore({
dimensions: 3,
client: sql,
});
await vectorStore.add([
new Document({
text: "hello, world",
embedding: [1, 2, 3],
}),
]);
const results = await vectorStore.query({
mode: VectorStoreQueryMode.DEFAULT,
similarityTopK: 1,
queryEmbedding: [1, 2, 3],
});
console.log("result", results);
await sql.end();
+2 -1
View File
@@ -12,6 +12,7 @@
"e2e": "turbo run e2e",
"test": "turbo run test",
"type-check": "tsc -b --diagnostics",
"circular-check": "madge --circular ./packages/**/**/dist/index.js",
"release": "pnpm run build:release && changeset publish",
"release-snapshot": "pnpm run build:release && changeset publish --tag snapshot",
"new-version": "changeset version && pnpm format:write && pnpm run build:release",
@@ -30,7 +31,7 @@
"madge": "^8.0.0",
"prettier": "^3.3.3",
"prettier-plugin-organize-imports": "^4.0.0",
"turbo": "^2.1.0",
"turbo": "^2.1.2",
"typescript": "^5.6.2"
},
"packageManager": "pnpm@9.5.0",
+25
View File
@@ -1,5 +1,30 @@
# @llamaindex/autotool
## 3.0.12
### Patch Changes
- Updated dependencies [f7b4e94]
- Updated dependencies [78037a6]
- Updated dependencies [1d9e3b1]
- llamaindex@0.6.12
## 3.0.11
### Patch Changes
- df441e2: fix: consoleLogger is missing from `@llamaindex/env`
- Updated dependencies [df441e2]
- llamaindex@0.6.11
## 3.0.10
### Patch Changes
- Updated dependencies [ebc5105]
- Updated dependencies [6cce3b1]
- llamaindex@0.6.10
## 3.0.9
### Patch Changes
@@ -1,5 +1,32 @@
# @llamaindex/autotool-01-node-example
## 0.0.21
### Patch Changes
- Updated dependencies [f7b4e94]
- Updated dependencies [78037a6]
- Updated dependencies [1d9e3b1]
- llamaindex@0.6.12
- @llamaindex/autotool@3.0.12
## 0.0.20
### Patch Changes
- Updated dependencies [df441e2]
- @llamaindex/autotool@3.0.11
- llamaindex@0.6.11
## 0.0.19
### Patch Changes
- Updated dependencies [ebc5105]
- Updated dependencies [6cce3b1]
- llamaindex@0.6.10
- @llamaindex/autotool@3.0.10
## 0.0.18
### Patch Changes
@@ -13,5 +13,5 @@
"scripts": {
"start": "node --import tsx --import @llamaindex/autotool/node ./src/index.ts"
},
"version": "0.0.18"
"version": "0.0.21"
}
@@ -1,5 +1,32 @@
# @llamaindex/autotool-02-next-example
## 0.1.65
### Patch Changes
- Updated dependencies [f7b4e94]
- Updated dependencies [78037a6]
- Updated dependencies [1d9e3b1]
- llamaindex@0.6.12
- @llamaindex/autotool@3.0.12
## 0.1.64
### Patch Changes
- Updated dependencies [df441e2]
- @llamaindex/autotool@3.0.11
- llamaindex@0.6.11
## 0.1.63
### Patch Changes
- Updated dependencies [ebc5105]
- Updated dependencies [6cce3b1]
- llamaindex@0.6.10
- @llamaindex/autotool@3.0.10
## 0.1.62
### Patch Changes
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/autotool-02-next-example",
"private": true,
"version": "0.1.62",
"version": "0.1.65",
"scripts": {
"dev": "next dev",
"build": "next build",
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/autotool",
"type": "module",
"version": "3.0.9",
"version": "3.0.12",
"description": "auto transpile your JS function to LLM Agent compatible",
"files": [
"dist",
+9
View File
@@ -1,5 +1,14 @@
# @llamaindex/cloud
## 0.2.9
### Patch Changes
- df441e2: fix: consoleLogger is missing from `@llamaindex/env`
- Updated dependencies [df441e2]
- @llamaindex/core@0.2.8
- @llamaindex/env@0.1.13
## 0.2.8
### Patch Changes
+8
View File
@@ -0,0 +1,8 @@
{
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": "./dist/index.js",
"private": true
}
+20 -19
View File
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/cloud",
"version": "0.2.8",
"version": "0.2.9",
"type": "module",
"license": "MIT",
"scripts": {
@@ -9,54 +9,55 @@
},
"files": [
"openapi.json",
"dist"
"./api",
"./reader"
],
"exports": {
"./openapi.json": "./openapi.json",
"./api": {
"require": {
"types": "./dist/api.d.cts",
"default": "./dist/api.cjs"
"types": "./api/dist/index.d.cts",
"default": "./api/dist/index.cjs"
},
"import": {
"types": "./dist/api.d.ts",
"default": "./dist/api.js"
"types": "./api/dist/index.d.ts",
"default": "./api/dist/index.js"
},
"default": {
"types": "./dist/api.d.ts",
"default": "./dist/api.js"
"types": "./api/dist/index.d.ts",
"default": "./api/dist/index.js"
}
},
"./reader": {
"require": {
"types": "./dist/reader.d.cts",
"default": "./dist/reader.cjs"
"types": "./reader/dist/index.d.cts",
"default": "./reader/dist/index.cjs"
},
"import": {
"types": "./dist/reader.d.ts",
"default": "./dist/reader.js"
"types": "./reader/dist/index.d.ts",
"default": "./reader/dist/index.js"
},
"default": {
"types": "./dist/reader.d.ts",
"default": "./dist/reader.js"
"types": "./reader/dist/index.d.ts",
"default": "./reader/dist/index.js"
}
}
},
"repository": {
"type": "git",
"url": "https://github.com/himself65/LlamaIndexTS.git",
"url": "https://github.com/run-llama/LlamaIndexTS.git",
"directory": "packages/cloud"
},
"devDependencies": {
"@hey-api/client-fetch": "^0.2.4",
"@hey-api/openapi-ts": "^0.53.0",
"@llamaindex/core": "workspace:^0.2.3",
"@llamaindex/env": "workspace:^0.1.11",
"@llamaindex/core": "workspace:^0.2.8",
"@llamaindex/env": "workspace:^0.1.13",
"bunchee": "5.3.2"
},
"peerDependencies": {
"@llamaindex/core": "workspace:^0.2.3",
"@llamaindex/env": "workspace:^0.1.11"
"@llamaindex/core": "workspace:^0.2.8",
"@llamaindex/env": "workspace:^0.1.13"
},
"dependencies": {
"magic-bytes.js": "^1.10.0"
+8
View File
@@ -0,0 +1,8 @@
{
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": "./dist/index.js",
"private": true
}
+1 -1
View File
@@ -2,7 +2,7 @@
"extends": ["//"],
"tasks": {
"build": {
"outputs": ["dist/**", "src/client/**"]
"outputs": ["**/dist/**", "src/client/**"]
}
}
}
+16
View File
@@ -1,5 +1,21 @@
# @llamaindex/community
## 0.0.42
### Patch Changes
- df441e2: fix: consoleLogger is missing from `@llamaindex/env`
- Updated dependencies [df441e2]
- @llamaindex/core@0.2.8
- @llamaindex/env@0.1.13
## 0.0.41
### Patch Changes
- Updated dependencies [6cce3b1]
- @llamaindex/core@0.2.7
## 0.0.40
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/community",
"description": "Community package for LlamaIndexTS",
"version": "0.0.40",
"version": "0.0.42",
"type": "module",
"types": "dist/type/index.d.ts",
"main": "dist/cjs/index.js",
+2 -1
View File
@@ -16,7 +16,7 @@ import {
ToolCallLLM,
type ToolCallLLMMessageOptions,
} from "@llamaindex/core/llms";
import { streamConverter, wrapLLMEvent } from "@llamaindex/core/utils";
import { streamConverter } from "@llamaindex/core/utils";
import {
type BedrockAdditionalChatOptions,
type BedrockChatStreamResponse,
@@ -24,6 +24,7 @@ import {
} from "./provider";
import { mapMessageContentToMessageContentDetails } from "./utils";
import { wrapLLMEvent } from "@llamaindex/core/decorator";
import { AnthropicProvider } from "./anthropic/provider";
import { MetaProvider } from "./meta/provider";
+14
View File
@@ -1,5 +1,19 @@
# @llamaindex/core
## 0.2.8
### Patch Changes
- df441e2: fix: consoleLogger is missing from `@llamaindex/env`
- Updated dependencies [df441e2]
- @llamaindex/env@0.1.13
## 0.2.7
### Patch Changes
- 6cce3b1: feat: support `npm:postgres`
## 0.2.6
### Patch Changes
+8
View File
@@ -0,0 +1,8 @@
{
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": "./dist/index.js",
"private": true
}
+8
View File
@@ -0,0 +1,8 @@
{
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": "./dist/index.js",
"private": true
}
+8
View File
@@ -0,0 +1,8 @@
{
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": "./dist/index.js",
"private": true
}
+8
View File
@@ -0,0 +1,8 @@
{
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": "./dist/index.js",
"private": true
}
+8
View File
@@ -0,0 +1,8 @@
{
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": "./dist/index.js",
"private": true
}
+8
View File
@@ -0,0 +1,8 @@
{
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": "./dist/index.js",
"private": true
}
+8
View File
@@ -0,0 +1,8 @@
{
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": "./dist/index.js",
"private": true
}
+8
View File
@@ -0,0 +1,8 @@
{
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": "./dist/index.js",
"private": true
}
+8
View File
@@ -0,0 +1,8 @@
{
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": "./dist/index.js",
"private": true
}
+8
View File
@@ -0,0 +1,8 @@
{
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": "./dist/index.js",
"private": true
}
+159 -100
View File
@@ -1,236 +1,295 @@
{
"name": "@llamaindex/core",
"type": "module",
"version": "0.2.6",
"version": "0.2.8",
"description": "LlamaIndex Core Module",
"exports": {
"./node-parser": {
"./agent": {
"require": {
"types": "./dist/node-parser/index.d.cts",
"default": "./dist/node-parser/index.cjs"
"types": "./agent/dist/index.d.cts",
"default": "./agent/dist/index.cjs"
},
"import": {
"types": "./dist/node-parser/index.d.ts",
"default": "./dist/node-parser/index.js"
"types": "./agent/dist/index.d.ts",
"default": "./agent/dist/index.js"
},
"default": {
"types": "./dist/node-parser/index.d.ts",
"default": "./dist/node-parser/index.js"
"types": "./agent/dist/index.d.ts",
"default": "./agent/dist/index.js"
}
},
"./objects": {
"require": {
"types": "./objects/dist/index.d.cts",
"default": "./objects/dist/index.cjs"
},
"import": {
"types": "./objects/dist/index.d.ts",
"default": "./objects/dist/index.js"
},
"default": {
"types": "./objects/dist/index.d.ts",
"default": "./objects/dist/index.js"
}
},
"./node-parser": {
"require": {
"types": "./node-parser/dist/index.d.cts",
"default": "./node-parser/dist/index.cjs"
},
"import": {
"types": "./node-parser/dist/index.d.ts",
"default": "./node-parser/dist/index.js"
},
"default": {
"types": "./node-parser/dist/index.d.ts",
"default": "./node-parser/dist/index.js"
}
},
"./query-engine": {
"require": {
"types": "./dist/query-engine/index.d.cts",
"default": "./dist/query-engine/index.cjs"
"types": "./query-engine/dist/index.d.cts",
"default": "./query-engine/dist/index.cjs"
},
"import": {
"types": "./dist/query-engine/index.d.ts",
"default": "./dist/query-engine/index.js"
"types": "./query-engine/dist/index.d.ts",
"default": "./query-engine/dist/index.js"
},
"default": {
"types": "./dist/query-engine/index.d.ts",
"default": "./dist/query-engine/index.js"
"types": "./query-engine/dist/index.d.ts",
"default": "./query-engine/dist/index.js"
}
},
"./llms": {
"require": {
"types": "./dist/llms/index.d.cts",
"default": "./dist/llms/index.cjs"
"types": "./llms/dist/index.d.cts",
"default": "./llms/dist/index.cjs"
},
"import": {
"types": "./dist/llms/index.d.ts",
"default": "./dist/llms/index.js"
"types": "./llms/dist/index.d.ts",
"default": "./llms/dist/index.js"
},
"default": {
"types": "./dist/llms/index.d.ts",
"default": "./dist/llms/index.js"
"types": "./llms/dist/index.d.ts",
"default": "./llms/dist/index.js"
}
},
"./decorator": {
"require": {
"types": "./dist/decorator/index.d.cts",
"default": "./dist/decorator/index.cjs"
"types": "./decorator/dist/index.d.cts",
"default": "./decorator/dist/index.cjs"
},
"import": {
"types": "./dist/decorator/index.d.ts",
"default": "./dist/decorator/index.js"
"types": "./decorator/dist/index.d.ts",
"default": "./decorator/dist/index.js"
},
"default": {
"types": "./dist/decorator/index.d.ts",
"default": "./dist/decorator/index.js"
"types": "./decorator/dist/index.d.ts",
"default": "./decorator/dist/index.js"
}
},
"./embeddings": {
"require": {
"types": "./dist/embeddings/index.d.cts",
"default": "./dist/embeddings/index.cjs"
"types": "./embeddings/dist/index.d.cts",
"default": "./embeddings/dist/index.cjs"
},
"import": {
"types": "./dist/embeddings/index.d.ts",
"default": "./dist/embeddings/index.js"
"types": "./embeddings/dist/index.d.ts",
"default": "./embeddings/dist/index.js"
},
"default": {
"types": "./dist/embeddings/index.d.ts",
"default": "./dist/embeddings/index.js"
"types": "./embeddings/dist/index.d.ts",
"default": "./embeddings/dist/index.js"
}
},
"./global": {
"require": {
"types": "./dist/global/index.d.cts",
"default": "./dist/global/index.cjs"
"types": "./global/dist/index.d.cts",
"default": "./global/dist/index.cjs"
},
"import": {
"types": "./dist/global/index.d.ts",
"default": "./dist/global/index.js"
"types": "./global/dist/index.d.ts",
"default": "./global/dist/index.js"
},
"default": {
"types": "./dist/global/index.d.ts",
"default": "./dist/global/index.js"
"types": "./global/dist/index.d.ts",
"default": "./global/dist/index.js"
}
},
"./schema": {
"require": {
"types": "./dist/schema/index.d.cts",
"default": "./dist/schema/index.cjs"
"types": "./schema/dist/index.d.cts",
"default": "./schema/dist/index.cjs"
},
"import": {
"types": "./dist/schema/index.d.ts",
"default": "./dist/schema/index.js"
"types": "./schema/dist/index.d.ts",
"default": "./schema/dist/index.js"
},
"default": {
"types": "./dist/schema/index.d.ts",
"default": "./dist/schema/index.js"
"types": "./schema/dist/index.d.ts",
"default": "./schema/dist/index.js"
}
},
"./utils": {
"require": {
"types": "./dist/utils/index.d.cts",
"default": "./dist/utils/index.cjs"
"types": "./utils/dist/index.d.cts",
"default": "./utils/dist/index.cjs"
},
"import": {
"types": "./dist/utils/index.d.ts",
"default": "./dist/utils/index.js"
"types": "./utils/dist/index.d.ts",
"default": "./utils/dist/index.js"
},
"default": {
"types": "./dist/utils/index.d.ts",
"default": "./dist/utils/index.js"
"types": "./utils/dist/index.d.ts",
"default": "./utils/dist/index.js"
}
},
"./prompts": {
"require": {
"types": "./dist/prompts/index.d.cts",
"default": "./dist/prompts/index.cjs"
"types": "./prompts/dist/index.d.cts",
"default": "./prompts/dist/index.cjs"
},
"import": {
"types": "./dist/prompts/index.d.ts",
"default": "./dist/prompts/index.js"
"types": "./prompts/dist/index.d.ts",
"default": "./prompts/dist/index.js"
},
"default": {
"types": "./dist/prompts/index.d.ts",
"default": "./dist/prompts/index.js"
"types": "./prompts/dist/index.d.ts",
"default": "./prompts/dist/index.js"
}
},
"./indices": {
"require": {
"types": "./dist/indices/index.d.cts",
"default": "./dist/indices/index.cjs"
"types": "./indices/dist/index.d.cts",
"default": "./indices/dist/index.cjs"
},
"import": {
"types": "./dist/indices/index.d.ts",
"default": "./dist/indices/index.js"
"types": "./indices/dist/index.d.ts",
"default": "./indices/dist/index.js"
},
"default": {
"types": "./dist/indices/index.d.ts",
"default": "./dist/indices/index.js"
"types": "./indices/dist/index.d.ts",
"default": "./indices/dist/index.js"
}
},
"./workflow": {
"require": {
"types": "./dist/workflow/index.d.cts",
"default": "./dist/workflow/index.cjs"
"types": "./workflow/dist/index.d.cts",
"default": "./workflow/dist/index.cjs"
},
"import": {
"types": "./dist/workflow/index.d.ts",
"default": "./dist/workflow/index.js"
"types": "./workflow/dist/index.d.ts",
"default": "./workflow/dist/index.js"
},
"default": {
"types": "./dist/workflow/index.d.ts",
"default": "./dist/workflow/index.js"
"types": "./workflow/dist/index.d.ts",
"default": "./workflow/dist/index.js"
}
},
"./memory": {
"require": {
"types": "./dist/memory/index.d.cts",
"default": "./dist/memory/index.cjs"
"types": "./memory/dist/index.d.cts",
"default": "./memory/dist/index.cjs"
},
"import": {
"types": "./dist/memory/index.d.ts",
"default": "./dist/memory/index.js"
"types": "./memory/dist/index.d.ts",
"default": "./memory/dist/index.js"
},
"default": {
"types": "./dist/memory/index.d.ts",
"default": "./dist/memory/index.js"
"types": "./memory/dist/index.d.ts",
"default": "./memory/dist/index.js"
}
},
"./storage/chat-store": {
"require": {
"types": "./dist/storage/chat-store/index.d.cts",
"default": "./dist/storage/chat-store/index.cjs"
"types": "./storage/chat-store/dist/index.d.cts",
"default": "./storage/chat-store/dist/index.cjs"
},
"import": {
"types": "./dist/storage/chat-store/index.d.ts",
"default": "./dist/storage/chat-store/index.js"
"types": "./storage/chat-store/dist/index.d.ts",
"default": "./storage/chat-store/dist/index.js"
},
"default": {
"types": "./dist/storage/chat-store/index.d.ts",
"default": "./dist/storage/chat-store/index.js"
"types": "./storage/chat-store/dist/index.d.ts",
"default": "./storage/chat-store/dist/index.js"
}
},
"./response-synthesizers": {
"require": {
"types": "./dist/response-synthesizers/index.d.cts",
"default": "./dist/response-synthesizers/index.cjs"
"types": "./response-synthesizers/dist/index.d.cts",
"default": "./response-synthesizers/dist/index.cjs"
},
"import": {
"types": "./dist/response-synthesizers/index.d.ts",
"default": "./dist/response-synthesizers/index.js"
"types": "./response-synthesizers/dist/index.d.ts",
"default": "./response-synthesizers/dist/index.js"
},
"default": {
"types": "./dist/response-synthesizers/index.d.ts",
"default": "./dist/response-synthesizers/index.js"
"types": "./response-synthesizers/dist/index.d.ts",
"default": "./response-synthesizers/dist/index.js"
}
},
"./chat-engine": {
"require": {
"types": "./dist/chat-engine/index.d.cts",
"default": "./dist/chat-engine/index.cjs"
"types": "./chat-engine/dist/index.d.cts",
"default": "./chat-engine/dist/index.cjs"
},
"import": {
"types": "./dist/chat-engine/index.d.ts",
"default": "./dist/chat-engine/index.js"
"types": "./chat-engine/dist/index.d.ts",
"default": "./chat-engine/dist/index.js"
},
"default": {
"types": "./dist/chat-engine/index.d.ts",
"default": "./dist/chat-engine/index.js"
"types": "./chat-engine/dist/index.d.ts",
"default": "./chat-engine/dist/index.js"
}
},
"./retriever": {
"require": {
"types": "./dist/retriever/index.d.cts",
"default": "./dist/retriever/index.cjs"
"types": "./retriever/dist/index.d.cts",
"default": "./retriever/dist/index.cjs"
},
"import": {
"types": "./dist/retriever/index.d.ts",
"default": "./dist/retriever/index.js"
"types": "./retriever/dist/index.d.ts",
"default": "./retriever/dist/index.js"
},
"default": {
"types": "./dist/retriever/index.d.ts",
"default": "./dist/retriever/index.js"
"types": "./retriever/dist/index.d.ts",
"default": "./retriever/dist/index.js"
}
},
"./vector-store": {
"require": {
"types": "./dist/vector-store/index.d.cts",
"default": "./dist/vector-store/index.cjs"
},
"import": {
"types": "./dist/vector-store/index.d.ts",
"default": "./dist/vector-store/index.js"
},
"default": {
"types": "./dist/vector-store/index.d.ts",
"default": "./dist/vector-store/index.js"
}
}
},
"files": [
"dist"
"./agent",
"./objects",
"./node-parser",
"./query-engine",
"./llms",
"./decorator",
"./embeddings",
"./global",
"./schema",
"./utils",
"./prompts",
"./indices",
"./workflow",
"./memory",
"./storage",
"./response-synthesizers",
"./chat-engine",
"./retriever"
],
"scripts": {
"dev": "bunchee --watch",
@@ -239,7 +298,7 @@
"repository": {
"type": "git",
"directory": "packages/core",
"url": "https://github.com/himself65/LlamaIndexTS.git"
"url": "https://github.com/run-llama/LlamaIndexTS.git"
},
"devDependencies": {
"@edge-runtime/vm": "^4.0.3",
+8
View File
@@ -0,0 +1,8 @@
{
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": "./dist/index.js",
"private": true
}
+8
View File
@@ -0,0 +1,8 @@
{
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": "./dist/index.js",
"private": true
}
@@ -0,0 +1,8 @@
{
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": "./dist/index.js",
"private": true
}
+8
View File
@@ -0,0 +1,8 @@
{
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": "./dist/index.js",
"private": true
}
+8
View File
@@ -0,0 +1,8 @@
{
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": "./dist/index.js",
"private": true
}
@@ -1,23 +1,21 @@
import { consoleLogger, emptyLogger, randomUUID } from "@llamaindex/env";
import {
BaseChatEngine,
type NonStreamingChatEngineParams,
type StreamingChatEngineParams,
} from "@llamaindex/core/chat-engine";
} from "../chat-engine";
import { wrapEventCaller } from "../decorator";
import { Settings } from "../global";
import type {
BaseToolWithCall,
ChatMessage,
LLM,
MessageContent,
ToolOutput,
} from "@llamaindex/core/llms";
import { BaseMemory } from "@llamaindex/core/memory";
import { EngineResponse } from "@llamaindex/core/schema";
import { wrapEventCaller } from "@llamaindex/core/utils";
import { randomUUID } from "@llamaindex/env";
import { Settings } from "../Settings.js";
import { consoleLogger, emptyLogger } from "../internal/logger.js";
import { isReadableStream } from "../internal/utils.js";
import { ObjectRetriever } from "../objects/index.js";
} from "../llms";
import { BaseMemory } from "../memory";
import type { ObjectRetriever } from "../objects";
import { EngineResponse } from "../schema";
import type {
AgentTaskContext,
TaskHandler,
@@ -374,7 +372,7 @@ export abstract class AgentRunner<
this.#chatHistory = [...stepOutput.taskStep.context.store.messages];
if (stepOutput.isLast) {
const { output } = stepOutput;
if (isReadableStream(output)) {
if (output instanceof ReadableStream) {
return output.pipeThrough<EngineResponse>(
new TransformStream({
transform(chunk, controller) {
+11
View File
@@ -0,0 +1,11 @@
export { AgentRunner, AgentWorker, type AgentParamsBase } from "./base.js";
export { LLMAgent, LLMAgentWorker, type LLMAgentParams } from "./llm.js";
export type { AgentEndEvent, AgentStartEvent, TaskHandler } from "./types.js";
export {
callTool,
consumeAsyncIterable,
createReadableStream,
stepTools,
stepToolsStreaming,
validateAgentParams,
} from "./utils.js";
@@ -1,6 +1,6 @@
import type { BaseToolWithCall, LLM } from "@llamaindex/core/llms";
import { ObjectRetriever } from "../objects/index.js";
import { Settings } from "../Settings.js";
import { Settings } from "../global";
import type { BaseToolWithCall, LLM } from "../llms";
import { ObjectRetriever } from "../objects";
import { AgentRunner, AgentWorker, type AgentParamsBase } from "./base.js";
import { validateAgentParams } from "./utils.js";
@@ -1,3 +1,5 @@
import type { Logger } from "@llamaindex/env";
import type { UUID } from "../global";
import type {
BaseToolWithCall,
ChatMessage,
@@ -6,9 +8,7 @@ import type {
LLM,
MessageContent,
ToolOutput,
} from "@llamaindex/core/llms";
import type { Logger } from "../internal/logger.js";
import type { UUID } from "../types.js";
} from "../llms";
export type AgentTaskContext<
Model extends LLM,
@@ -1,8 +1,6 @@
import {
type JSONObject,
type JSONValue,
Settings,
} from "@llamaindex/core/global";
import type { Logger } from "@llamaindex/env";
import { z } from "zod";
import { type JSONObject, type JSONValue, Settings } from "../global";
import type {
BaseTool,
ChatMessage,
@@ -14,15 +12,13 @@ import type {
ToolCall,
ToolCallLLMMessageOptions,
ToolOutput,
} from "@llamaindex/core/llms";
import { baseToolWithCallSchema } from "@llamaindex/core/schema";
import { z } from "zod";
import type { Logger } from "../internal/logger.js";
} from "../llms";
import { baseToolWithCallSchema } from "../schema";
import {
isAsyncIterable,
prettifyError,
stringifyJSONToMessageContent,
} from "../internal/utils.js";
} from "../utils";
import type { AgentParamsBase } from "./base.js";
import type { TaskHandler } from "./types.js";
@@ -0,0 +1,48 @@
import { AsyncLocalStorage } from "@llamaindex/env";
import { withEventCaller } from "../global";
import { isAsyncIterable, isIterable } from "../utils";
export function wrapEventCaller<This, Result, Args extends unknown[]>(
originalMethod: (this: This, ...args: Args) => Result,
context: ClassMethodDecoratorContext<object>,
) {
const name = context.name;
context.addInitializer(function () {
// @ts-expect-error
const fn = this[name].bind(this);
// @ts-expect-error
this[name] = (...args: unknown[]) => {
return withEventCaller(this, () => fn(...args));
};
});
return function (this: This, ...args: Args): Result {
const result = originalMethod.call(this, ...args);
// patch for iterators because AsyncLocalStorage doesn't work with them
if (isAsyncIterable(result)) {
const iter = result[Symbol.asyncIterator]();
const snapshot = AsyncLocalStorage.snapshot();
return (async function* asyncGeneratorWrapper() {
while (true) {
const { value, done } = await snapshot(() => iter.next());
if (done) {
break;
}
yield value;
}
})() as Result;
} else if (isIterable(result)) {
const iter = result[Symbol.iterator]();
const snapshot = AsyncLocalStorage.snapshot();
return (function* generatorWrapper() {
while (true) {
const { value, done } = snapshot(() => iter.next());
if (done) {
break;
}
yield value;
}
})() as Result;
}
return result;
};
}
+3 -67
View File
@@ -1,67 +1,3 @@
import { getEnv } from "@llamaindex/env";
import { Settings } from "../global";
import type { BaseNode } from "../schema/node";
const emitOnce = false;
export function chunkSizeCheck<
This extends { id_: string },
Args extends any[],
Return,
>(
contentGetter: (this: This, ...args: Args) => string,
_context: ClassMethodDecoratorContext<
This,
(this: This, ...args: Args) => Return
>,
) {
return function (this: This, ...args: Args) {
const content = contentGetter.call(this, ...args);
const chunkSize = Settings.chunkSize;
const enableChunkSizeCheck = getEnv("ENABLE_CHUNK_SIZE_CHECK") === "true";
if (
enableChunkSizeCheck &&
chunkSize !== undefined &&
content.length > chunkSize
) {
console.warn(
`Node (${this.id_}) is larger than chunk size: ${content.length} > ${chunkSize}`,
);
if (!emitOnce) {
console.warn(
"Will truncate the content if it is larger than chunk size",
);
console.warn("If you want to disable this behavior:");
console.warn(" 1. Set Settings.chunkSize = undefined");
console.warn(" 2. Set Settings.chunkSize to a larger value");
console.warn(
" 3. Change the way of splitting content into smaller chunks",
);
}
return content.slice(0, chunkSize);
}
return content;
};
}
export function lazyInitHash(
value: ClassAccessorDecoratorTarget<BaseNode, string>,
_context: ClassAccessorDecoratorContext,
): ClassAccessorDecoratorResult<BaseNode, string> {
return {
get() {
const oldValue = value.get.call(this);
if (oldValue === "") {
const hash = this.generateHash();
value.set.call(this, hash);
}
return value.get.call(this);
},
set(newValue: string) {
value.set.call(this, newValue);
},
init(value: string): string {
return value;
},
};
}
export { wrapEventCaller } from "./event-caller";
export { lazyInitHash } from "./lazy-init-hash";
export { wrapLLMEvent } from "./wrap-llm-event";
@@ -0,0 +1,23 @@
import type { BaseNode } from "../schema";
export function lazyInitHash(
value: ClassAccessorDecoratorTarget<BaseNode, string>,
_context: ClassAccessorDecoratorContext,
): ClassAccessorDecoratorResult<BaseNode, string> {
return {
get() {
const oldValue = value.get.call(this);
if (oldValue === "") {
const hash = this.generateHash();
value.set.call(this, hash);
}
return value.get.call(this);
},
set(newValue: string) {
value.set.call(this, newValue);
},
init(value: string): string {
return value;
},
};
}
+6 -1
View File
@@ -9,4 +9,9 @@ export type {
LLMToolResultEvent,
LlamaIndexEventMaps,
} from "./settings/callback-manager";
export type { JSONArray, JSONObject, JSONValue } from "./type";
export {
EventCaller,
getEventCaller,
withEventCaller,
} from "./settings/event-caller";
export type { JSONArray, JSONObject, JSONValue, UUID } from "./type";
+13 -1
View File
@@ -1,4 +1,4 @@
import type { Tokenizer } from "@llamaindex/env";
import { getEnv, type Tokenizer } from "@llamaindex/env";
import type { LLM } from "../llms";
import {
type CallbackManager,
@@ -61,4 +61,16 @@ export const Settings = {
): Result {
return withCallbackManager(callbackManager, fn);
},
get debug() {
let debug = getEnv("DEBUG");
if (typeof window !== "undefined") {
debug ||= window.localStorage.debug;
}
return (
(Boolean(debug) && debug?.includes("llamaindex")) ||
debug === "*" ||
debug === "true"
);
},
};
@@ -1,4 +1,5 @@
import { AsyncLocalStorage, CustomEvent } from "@llamaindex/env";
import type { AgentEndEvent, AgentStartEvent } from "../../agent";
import type {
ChatMessage,
ChatResponse,
@@ -13,8 +14,8 @@ import type {
} from "../../response-synthesizers";
import type { RetrieveEndEvent, RetrieveStartEvent } from "../../retriever";
import { TextNode } from "../../schema";
import { EventCaller, getEventCaller } from "../../utils";
import type { UUID } from "../type";
import { EventCaller, getEventCaller } from "./event-caller";
export type LLMStartEvent = {
id: UUID;
@@ -72,6 +73,8 @@ export interface LlamaIndexEventMaps {
"synthesize-end": SynthesizeEndEvent;
"retrieve-start": RetrieveStartEvent;
"retrieve-end": RetrieveEndEvent;
"agent-start": AgentStartEvent;
"agent-end": AgentEndEvent;
}
export class LlamaIndexCustomEvent<T = any> extends CustomEvent<T> {
@@ -0,0 +1,55 @@
import { AsyncLocalStorage, randomUUID } from "@llamaindex/env";
const eventReasonAsyncLocalStorage = new AsyncLocalStorage<EventCaller>();
/**
* EventCaller is used to track the caller of an event.
*/
export class EventCaller {
public readonly id = randomUUID();
private constructor(
public readonly caller: unknown,
public readonly parent: EventCaller | null,
) {}
#computedCallers: unknown[] | null = null;
public get computedCallers(): unknown[] {
if (this.#computedCallers != null) {
return this.#computedCallers;
}
const callers = [this.caller];
let parent = this.parent;
while (parent != null) {
callers.push(parent.caller);
parent = parent.parent;
}
this.#computedCallers = callers;
return callers;
}
public static create(
caller: unknown,
parent: EventCaller | null,
): EventCaller {
return new EventCaller(caller, parent);
}
}
export function getEventCaller(): EventCaller | null {
return eventReasonAsyncLocalStorage.getStore() ?? null;
}
/**
* @param caller who is calling this function, pass in `this` if it's a class method
* @param fn
*/
export function withEventCaller<T>(caller: unknown, fn: () => T) {
// create a chain of event callers
const parentCaller = getEventCaller();
return eventReasonAsyncLocalStorage.run(
EventCaller.create(caller, parentCaller),
fn,
);
}
+78
View File
@@ -0,0 +1,78 @@
/**
* @todo refactor this module, most of the part is broken
* reference
* - https://github.com/run-llama/LlamaIndexTS/pull/531
* - https://github.com/run-llama/LlamaIndexTS/pull/416
*/
import type { MessageContent } from "../llms";
import { BaseRetriever } from "../retriever";
import { BaseNode, TextNode } from "../schema";
import { extractText } from "../utils";
// Assuming that necessary interfaces and classes (like OT, TextNode, BaseNode, etc.) are defined elsewhere
// Import statements (e.g., for TextNode, BaseNode) should be added based on your project's structure
export abstract class BaseObjectNodeMapping {
// TypeScript doesn't support Python's classmethod directly, but we can use static methods as an alternative
abstract fromObjects<OT>(objs: OT[], ...args: any[]): BaseObjectNodeMapping;
// Abstract methods in TypeScript
abstract objNodeMapping(): Record<any, any>;
abstract toNode(obj: any): TextNode;
// Concrete methods can be defined as usual
validateObject(obj: any): void {}
// Implementing the add object logic
addObj(obj: any): void {
this.validateObject(obj);
this._addObj(obj);
}
// Abstract method for internal add object logic
abstract _addObj(obj: any): void;
// Implementing toNodes method
toNodes(objs: any[]): TextNode[] {
return objs.map((obj) => this.toNode(obj));
}
// Abstract method for internal from node logic
abstract _fromNode(node: BaseNode): any;
// Implementing fromNode method
fromNode(node: BaseNode): any {
const obj = this._fromNode(node);
this.validateObject(obj);
return obj;
}
// Abstract methods for persistence
abstract persist(persistDir: string, objNodeMappingFilename: string): void;
}
export class ObjectRetriever<T = unknown> {
_retriever: BaseRetriever;
_objectNodeMapping: BaseObjectNodeMapping;
constructor(
retriever: BaseRetriever,
objectNodeMapping: BaseObjectNodeMapping,
) {
this._retriever = retriever;
this._objectNodeMapping = objectNodeMapping;
}
// In TypeScript, getters are defined like this.
get retriever(): BaseRetriever {
return this._retriever;
}
// Translating the retrieve method
async retrieve(strOrQueryBundle: MessageContent): Promise<T[]> {
const nodes = await this.retriever.retrieve({
query: extractText(strOrQueryBundle),
});
const objs = nodes.map((n) => this._objectNodeMapping.fromNode(n.node));
return objs;
}
}
+1 -1
View File
@@ -1,9 +1,9 @@
import { randomUUID } from "@llamaindex/env";
import { wrapEventCaller } from "../decorator";
import { Settings } from "../global";
import type { MessageContent } from "../llms";
import { PromptMixin } from "../prompts";
import { EngineResponse, type NodeWithScore } from "../schema";
import { wrapEventCaller } from "../utils";
/**
* @link https://docs.llamaindex.ai/en/stable/api_reference/schema/?h=querybundle#llama_index.core.schema.QueryBundle
@@ -16,11 +16,12 @@ import {
type NodeWithScore,
TextNode,
} from "../schema";
import { createMessageContent, extractText, streamConverter } from "../utils";
import { extractText, streamConverter } from "../utils";
import {
BaseSynthesizer,
type BaseSynthesizerOptions,
} from "./base-synthesizer";
import { createMessageContent } from "./utils";
const responseModeSchema = z.enum([
"refine",
@@ -8,3 +8,4 @@ export type {
SynthesizeQuery,
SynthesizeStartEvent,
} from "./type";
export { createMessageContent } from "./utils";
@@ -0,0 +1,72 @@
// eslint-disable-next-line max-params
import type { MessageContentDetail } from "../llms";
import type { BasePromptTemplate } from "../prompts";
import {
type BaseNode,
ImageNode,
MetadataMode,
ModalityType,
splitNodesByType,
} from "../schema";
import { imageToDataUrl } from "../utils";
async function createContentPerModality(
prompt: BasePromptTemplate,
type: ModalityType,
nodes: BaseNode[],
extraParams: Record<string, string>,
metadataMode: MetadataMode,
): Promise<MessageContentDetail[]> {
switch (type) {
case ModalityType.TEXT:
return [
{
type: "text",
text: prompt.format({
...extraParams,
context: nodes.map((r) => r.getContent(metadataMode)).join("\n\n"),
}),
},
];
case ModalityType.IMAGE:
const images: MessageContentDetail[] = await Promise.all(
(nodes as ImageNode[]).map(async (node) => {
return {
type: "image_url",
image_url: {
url: await imageToDataUrl(node.image),
},
} satisfies MessageContentDetail;
}),
);
return images;
default:
return [];
}
}
export async function createMessageContent(
prompt: BasePromptTemplate,
nodes: BaseNode[],
extraParams: Record<string, string> = {},
metadataMode: MetadataMode = MetadataMode.NONE,
): Promise<MessageContentDetail[]> {
const content: MessageContentDetail[] = [];
const nodeMap = splitNodesByType(nodes);
for (const type in nodeMap) {
// for each retrieved modality type, create message content
const nodes = nodeMap[type as ModalityType];
if (nodes) {
content.push(
...(await createContentPerModality(
prompt,
type as ModalityType,
nodes,
extraParams,
metadataMode,
)),
);
}
}
return content;
}
+2 -1
View File
@@ -1,5 +1,6 @@
import { createSHA256, path, randomUUID } from "@llamaindex/env";
import { chunkSizeCheck, lazyInitHash } from "../decorator";
import { lazyInitHash } from "../decorator";
import { chunkSizeCheck } from "./utils/chunk-size-check";
export enum NodeRelationship {
SOURCE = "SOURCE",
@@ -0,0 +1,44 @@
import { getEnv } from "@llamaindex/env";
import { Settings } from "../../global";
const emitOnce = false;
export function chunkSizeCheck<
This extends { id_: string },
Args extends any[],
Return,
>(
contentGetter: (this: This, ...args: Args) => string,
_context: ClassMethodDecoratorContext<
This,
(this: This, ...args: Args) => Return
>,
) {
return function (this: This, ...args: Args) {
const content = contentGetter.call(this, ...args);
const chunkSize = Settings.chunkSize;
const enableChunkSizeCheck = getEnv("ENABLE_CHUNK_SIZE_CHECK") === "true";
if (
enableChunkSizeCheck &&
chunkSize !== undefined &&
content.length > chunkSize
) {
console.warn(
`Node (${this.id_}) is larger than chunk size: ${content.length} > ${chunkSize}`,
);
if (!emitOnce) {
console.warn(
"Will truncate the content if it is larger than chunk size",
);
console.warn("If you want to disable this behavior:");
console.warn(" 1. Set Settings.chunkSize = undefined");
console.warn(" 2. Set Settings.chunkSize to a larger value");
console.warn(
" 3. Change the way of splitting content into smaller chunks",
);
}
return content.slice(0, chunkSize);
}
return content;
};
}
-110
View File
@@ -1,110 +0,0 @@
import { AsyncLocalStorage, randomUUID } from "@llamaindex/env";
export const isAsyncIterable = (
obj: unknown,
): obj is AsyncIterable<unknown> => {
return obj != null && typeof obj === "object" && Symbol.asyncIterator in obj;
};
export const isIterable = (obj: unknown): obj is Iterable<unknown> => {
return obj != null && typeof obj === "object" && Symbol.iterator in obj;
};
const eventReasonAsyncLocalStorage = new AsyncLocalStorage<EventCaller>();
/**
* EventCaller is used to track the caller of an event.
*/
export class EventCaller {
public readonly id = randomUUID();
private constructor(
public readonly caller: unknown,
public readonly parent: EventCaller | null,
) {}
#computedCallers: unknown[] | null = null;
public get computedCallers(): unknown[] {
if (this.#computedCallers != null) {
return this.#computedCallers;
}
const callers = [this.caller];
let parent = this.parent;
while (parent != null) {
callers.push(parent.caller);
parent = parent.parent;
}
this.#computedCallers = callers;
return callers;
}
public static create(
caller: unknown,
parent: EventCaller | null,
): EventCaller {
return new EventCaller(caller, parent);
}
}
export function getEventCaller(): EventCaller | null {
return eventReasonAsyncLocalStorage.getStore() ?? null;
}
/**
* @param caller who is calling this function, pass in `this` if it's a class method
* @param fn
*/
function withEventCaller<T>(caller: unknown, fn: () => T) {
// create a chain of event callers
const parentCaller = getEventCaller();
return eventReasonAsyncLocalStorage.run(
EventCaller.create(caller, parentCaller),
fn,
);
}
export function wrapEventCaller<This, Result, Args extends unknown[]>(
originalMethod: (this: This, ...args: Args) => Result,
context: ClassMethodDecoratorContext<object>,
) {
const name = context.name;
context.addInitializer(function () {
// @ts-expect-error
const fn = this[name].bind(this);
// @ts-expect-error
this[name] = (...args: unknown[]) => {
return withEventCaller(this, () => fn(...args));
};
});
return function (this: This, ...args: Args): Result {
const result = originalMethod.call(this, ...args);
// patch for iterators because AsyncLocalStorage doesn't work with them
if (isAsyncIterable(result)) {
const iter = result[Symbol.asyncIterator]();
const snapshot = AsyncLocalStorage.snapshot();
return (async function* asyncGeneratorWrapper() {
while (true) {
const { value, done } = await snapshot(() => iter.next());
if (done) {
break;
}
yield value;
}
})() as Result;
} else if (isIterable(result)) {
const iter = result[Symbol.iterator]();
const snapshot = AsyncLocalStorage.snapshot();
return (function* generatorWrapper() {
while (true) {
const { value, done } = snapshot(() => iter.next());
if (done) {
break;
}
yield value;
}
})() as Result;
}
return result;
};
}
+25 -3
View File
@@ -1,4 +1,14 @@
export { EventCaller, getEventCaller, wrapEventCaller } from "./event-caller";
import type { JSONValue } from "../global";
export const isAsyncIterable = (
obj: unknown,
): obj is AsyncIterable<unknown> => {
return obj != null && typeof obj === "object" && Symbol.asyncIterator in obj;
};
export const isIterable = (obj: unknown): obj is Iterable<unknown> => {
return obj != null && typeof obj === "object" && Symbol.iterator in obj;
};
export async function* streamConverter<S, D>(
stream: AsyncIterable<S>,
@@ -44,10 +54,22 @@ export async function* streamReducer<S, D>(params: {
}
}
export { wrapLLMEvent } from "./wrap-llm-event";
/**
* Prettify an error for AI to read
*/
export function prettifyError(error: unknown): string {
if (error instanceof Error) {
return `Error(${error.name}): ${error.message}`;
} else {
return `${error}`;
}
}
export function stringifyJSONToMessageContent(value: JSONValue): string {
return JSON.stringify(value, null, 2).replace(/"([^"]*)"/g, "$1");
}
export {
createMessageContent,
extractDataUrlComponents,
extractImage,
extractSingleText,
-70
View File
@@ -7,16 +7,8 @@ import type {
MessageContentTextDetail,
ToolMetadata,
} from "../llms";
import type { BasePromptTemplate } from "../prompts";
import type { QueryType } from "../query-engine";
import type { ImageType } from "../schema";
import {
type BaseNode,
ImageNode,
MetadataMode,
ModalityType,
splitNodesByType,
} from "../schema";
/**
* Extracts just the text whether from
@@ -151,65 +143,3 @@ export async function imageToDataUrl(
}
return await blobToDataUrl(input);
}
// eslint-disable-next-line max-params
async function createContentPerModality(
prompt: BasePromptTemplate,
type: ModalityType,
nodes: BaseNode[],
extraParams: Record<string, string>,
metadataMode: MetadataMode,
): Promise<MessageContentDetail[]> {
switch (type) {
case ModalityType.TEXT:
return [
{
type: "text",
text: prompt.format({
...extraParams,
context: nodes.map((r) => r.getContent(metadataMode)).join("\n\n"),
}),
},
];
case ModalityType.IMAGE:
const images: MessageContentDetail[] = await Promise.all(
(nodes as ImageNode[]).map(async (node) => {
return {
type: "image_url",
image_url: {
url: await imageToDataUrl(node.image),
},
} satisfies MessageContentDetail;
}),
);
return images;
default:
return [];
}
}
export async function createMessageContent(
prompt: BasePromptTemplate,
nodes: BaseNode[],
extraParams: Record<string, string> = {},
metadataMode: MetadataMode = MetadataMode.NONE,
): Promise<MessageContentDetail[]> {
const content: MessageContentDetail[] = [];
const nodeMap = splitNodesByType(nodes);
for (const type in nodeMap) {
// for each retrieved modality type, create message content
const nodes = nodeMap[type as ModalityType];
if (nodes) {
content.push(
...(await createContentPerModality(
prompt,
type as ModalityType,
nodes,
extraParams,
metadataMode,
)),
);
}
}
return content;
}
+13
View File
@@ -0,0 +1,13 @@
/**
* should compatible with npm:pg and npm:postgres
*/
export interface IsomorphicDB {
query: (sql: string, params?: any[]) => Promise<any[]>;
// begin will wrap the multiple queries in a transaction
begin: <T>(fn: (query: IsomorphicDB["query"]) => Promise<T>) => Promise<T>;
// event handler
connect: () => Promise<void>;
close: () => Promise<void>;
onCloseEvent: (listener: () => void) => void;
}
@@ -0,0 +1,8 @@
{
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": "./dist/index.js",
"private": true
}
@@ -1,4 +1,4 @@
import { validateAgentParams } from "llamaindex/agent/utils";
import { validateAgentParams } from "@llamaindex/core/agent";
import { expect, test } from "vitest";
import { ZodError } from "zod";
+64
View File
@@ -166,4 +166,68 @@ describe("Workflow", () => {
greeting: "Hello Alice, you are 30 years old!",
});
});
test("workflow with two concurrent steps", async () => {
const concurrentFlow = new Workflow({ verbose: true });
const step1 = vi.fn(async (_context, _ev: StartEvent) => {
await new Promise((resolve) => setTimeout(resolve, 200));
return new StopEvent({ result: "Step 1 completed" });
});
const step2 = vi.fn(async (_context, _ev: StartEvent) => {
await new Promise((resolve) => setTimeout(resolve, 100));
return new StopEvent({ result: "Step 2 completed" });
});
concurrentFlow.addStep(StartEvent, step1);
concurrentFlow.addStep(StartEvent, step2);
const startTime = new Date();
const result = await concurrentFlow.run("start");
const endTime = new Date();
const duration = endTime.getTime() - startTime.getTime();
expect(step1).toHaveBeenCalledTimes(1);
expect(step2).toHaveBeenCalledTimes(1);
expect(duration).toBeLessThan(200);
expect(result.data.result).toBe("Step 2 completed");
});
test("workflow with two concurrent cyclic steps", async () => {
const concurrentCyclicFlow = new Workflow({ verbose: true });
class Step1Event extends WorkflowEvent {}
class Step2Event extends WorkflowEvent {}
let step2Count = 0;
const step1 = vi.fn(async (_context, ev: StartEvent | Step1Event) => {
await new Promise((resolve) => setTimeout(resolve, 1000));
return new Step1Event({ result: "Step 1 completed" });
});
const step2 = vi.fn(async (_context, ev: StartEvent | Step2Event) => {
await new Promise((resolve) => setTimeout(resolve, 100));
step2Count++;
if (step2Count >= 5) {
return new StopEvent({ result: "Step 2 completed 5 times" });
}
return new Step2Event({ result: "Step 2 completed" });
});
concurrentCyclicFlow.addStep([StartEvent, Step1Event], step1);
concurrentCyclicFlow.addStep([StartEvent, Step2Event], step2);
const startTime = new Date();
const result = await concurrentCyclicFlow.run("start");
const endTime = new Date();
const duration = endTime.getTime() - startTime.getTime();
expect(step1).toHaveBeenCalledTimes(1);
expect(step2).toHaveBeenCalledTimes(5);
expect(duration).toBeGreaterThan(500); // At least 5 * 100ms for step2
expect(duration).toBeLessThan(1000); // Less than 1 second
expect(result.data.result).toBe("Step 2 completed 5 times");
});
});
+1 -1
View File
@@ -8,7 +8,7 @@
"moduleResolution": "Bundler",
"skipLibCheck": true,
"strict": true,
"lib": ["ESNext", "DOM"],
"lib": ["ESNext", "DOM", "DOM.AsyncIterable"],
"types": ["node"]
},
"include": ["./src"],
+8
View File
@@ -0,0 +1,8 @@
{
"extends": ["//"],
"tasks": {
"build": {
"outputs": ["**/dist/**"]
}
}
}
+8
View File
@@ -0,0 +1,8 @@
{
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": "./dist/index.js",
"private": true
}
+8
View File
@@ -0,0 +1,8 @@
{
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": "./dist/index.js",
"private": true
}
-7
View File
@@ -1,7 +0,0 @@
{
"detectiveOptions": {
"ts": {
"skipTypeImports": true
}
}
}
+6
View File
@@ -1,5 +1,11 @@
# @llamaindex/env
## 0.1.13
### Patch Changes
- df441e2: fix: consoleLogger is missing from `@llamaindex/env`
## 0.1.12
### Patch Changes
+2 -3
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.12",
"version": "0.1.13",
"type": "module",
"types": "dist/type/index.d.ts",
"main": "dist/cjs/index.js",
@@ -57,7 +57,7 @@
],
"repository": {
"type": "git",
"url": "https://github.com/himself65/LlamaIndexTS.git",
"url": "https://github.com/run-llama/LlamaIndexTS.git",
"directory": "packages/env"
},
"scripts": {
@@ -67,7 +67,6 @@
"build:type": "tsc -p tsconfig.json",
"postbuild": "node -e \"require('fs').writeFileSync('./dist/cjs/package.json', JSON.stringify({ type: 'commonjs' }))\"",
"dev": "concurrently \"pnpm run build:esm --watch\" \"pnpm run build:cjs --watch\" \"pnpm run build:type --watch\"",
"circular-check": "madge -c ./src/index.ts",
"test": "vitest"
},
"devDependencies": {
+1
View File
@@ -6,6 +6,7 @@
import "./global-check.js";
export * from "./web-polyfill.js";
export { consoleLogger, emptyLogger, type Logger } from "./logger/index.js";
export {
loadTransformers,
setTransformers,
+1
View File
@@ -6,6 +6,7 @@
import "./global-check.js";
export * from "./node-polyfill.js";
export { consoleLogger, emptyLogger, type Logger } from "./logger/index.js";
export {
loadTransformers,
setTransformers,
+1
View File
@@ -33,6 +33,7 @@ export function createSHA256(): SHA256 {
};
}
export { consoleLogger, emptyLogger, type Logger } from "./logger/index.js";
export {
loadTransformers,
setTransformers,
+1
View File
@@ -13,6 +13,7 @@ export function getEnv(name: string): string | undefined {
return INTERNAL_ENV[name];
}
export { consoleLogger, emptyLogger, type Logger } from "./logger/index.js";
export {
loadTransformers,
setTransformers,
@@ -4,10 +4,12 @@ export type Logger = {
warn: (...args: unknown[]) => void;
};
function noop() {}
export const emptyLogger: Logger = Object.freeze({
log: () => {},
error: () => {},
warn: () => {},
log: noop,
error: noop,
warn: noop,
});
export const consoleLogger: Logger = Object.freeze({
+25
View File
@@ -1,5 +1,30 @@
# @llamaindex/experimental
## 0.0.90
### Patch Changes
- Updated dependencies [f7b4e94]
- Updated dependencies [78037a6]
- Updated dependencies [1d9e3b1]
- llamaindex@0.6.12
## 0.0.89
### Patch Changes
- df441e2: fix: consoleLogger is missing from `@llamaindex/env`
- Updated dependencies [df441e2]
- llamaindex@0.6.11
## 0.0.88
### Patch Changes
- Updated dependencies [ebc5105]
- Updated dependencies [6cce3b1]
- llamaindex@0.6.10
## 0.0.87
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/experimental",
"description": "Experimental package for LlamaIndexTS",
"version": "0.0.87",
"version": "0.0.90",
"type": "module",
"types": "dist/type/index.d.ts",
"main": "dist/cjs/index.js",
-7
View File
@@ -1,7 +0,0 @@
{
"detectiveOptions": {
"ts": {
"skipTypeImports": true
}
}
}
+34
View File
@@ -1,5 +1,39 @@
# llamaindex
## 0.6.12
### Patch Changes
- f7b4e94: feat: add filters for pinecone
- 78037a6: fix: bypass service context embed model
- 1d9e3b1: fix: export llama reader in non-nodejs runtime
## 0.6.11
### Patch Changes
- df441e2: fix: consoleLogger is missing from `@llamaindex/env`
- Updated dependencies [df441e2]
- @llamaindex/cloud@0.2.9
- @llamaindex/core@0.2.8
- @llamaindex/env@0.1.13
- @llamaindex/ollama@0.0.3
- @llamaindex/openai@0.1.10
- @llamaindex/groq@0.0.9
## 0.6.10
### Patch Changes
- ebc5105: feat: support `@vercel/postgres`
- 6cce3b1: feat: support `npm:postgres`
- Updated dependencies [96f72ad]
- Updated dependencies [6cce3b1]
- @llamaindex/openai@0.1.9
- @llamaindex/core@0.2.7
- @llamaindex/groq@0.0.8
- @llamaindex/ollama@0.0.2
## 0.6.9
### Patch Changes
@@ -1,5 +1,29 @@
# @llamaindex/cloudflare-worker-agent-test
## 0.0.74
### Patch Changes
- Updated dependencies [f7b4e94]
- Updated dependencies [78037a6]
- Updated dependencies [1d9e3b1]
- llamaindex@0.6.12
## 0.0.73
### Patch Changes
- Updated dependencies [df441e2]
- llamaindex@0.6.11
## 0.0.72
### Patch Changes
- Updated dependencies [ebc5105]
- Updated dependencies [6cce3b1]
- llamaindex@0.6.10
## 0.0.71
### Patch Changes
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/cloudflare-worker-agent-test",
"version": "0.0.71",
"version": "0.0.74",
"type": "module",
"private": true,
"scripts": {
@@ -12,13 +12,13 @@
"cf-typegen": "wrangler types"
},
"devDependencies": {
"@cloudflare/vitest-pool-workers": "^0.4.27",
"@cloudflare/workers-types": "^4.20240821.1",
"@vitest/runner": "1.5.3",
"@vitest/snapshot": "1.5.3",
"@cloudflare/vitest-pool-workers": "^0.5.8",
"@cloudflare/workers-types": "^4.20240924.0",
"@vitest/runner": "2.1.1",
"@vitest/snapshot": "2.1.1",
"typescript": "^5.6.2",
"vitest": "1.5.3",
"wrangler": "^3.73.0"
"vitest": "2.1.1",
"wrangler": "^3.78.8"
},
"dependencies": {
"llamaindex": "workspace:*"
@@ -1,21 +1,26 @@
// add `OPENAI_API_KEY` to the `.dev.vars` file
interface Env {
OPENAI_API_KEY: string;
}
export default {
async fetch(
request: Request,
env: Env,
ctx: ExecutionContext,
): Promise<Response> {
const { setEnvs } = await import("@llamaindex/env");
setEnvs(env);
const { OpenAIAgent } = await import("llamaindex");
const { OpenAIAgent, OpenAI } = await import("@llamaindex/openai");
const text = await request.text();
const agent = new OpenAIAgent({
llm: new OpenAI({
apiKey: env.OPENAI_API_KEY,
}),
tools: [],
});
console.log(1);
const responseStream = await agent.chat({
stream: true,
message: "Hello? What is the weather today?",
message: text,
});
console.log(2);
const textEncoder = new TextEncoder();
const response = responseStream.pipeThrough<Uint8Array>(
new TransformStream({
@@ -14,7 +14,11 @@ describe("Hello World worker", () => {
const request = new IncomingRequest("http://example.com");
// Create an empty context to pass to `worker.fetch()`.
const ctx = createExecutionContext();
const response = await worker.fetch(request, env, ctx);
const response = await worker.fetch(
request,
{ ...env, OPENAI_API_KEY: "sk-1234" },
ctx,
);
// Wait for all `Promise`s passed to `ctx.waitUntil()` to settle before running test assertions
await waitOnExecutionContext(ctx);
// fixme: should be not "Hello World!"
@@ -1,5 +1,12 @@
# @llamaindex/llama-parse-browser-test
## 0.0.5
### Patch Changes
- Updated dependencies [df441e2]
- @llamaindex/cloud@0.2.9
## 0.0.4
### Patch Changes
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/llama-parse-browser-test",
"private": true,
"version": "0.0.4",
"version": "0.0.5",
"type": "module",
"scripts": {
"dev": "vite",
@@ -1,5 +1,29 @@
# @llamaindex/next-agent-test
## 0.1.74
### Patch Changes
- Updated dependencies [f7b4e94]
- Updated dependencies [78037a6]
- Updated dependencies [1d9e3b1]
- llamaindex@0.6.12
## 0.1.73
### Patch Changes
- Updated dependencies [df441e2]
- llamaindex@0.6.11
## 0.1.72
### Patch Changes
- Updated dependencies [ebc5105]
- Updated dependencies [6cce3b1]
- llamaindex@0.6.10
## 0.1.71
### Patch Changes
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/next-agent-test",
"version": "0.1.71",
"version": "0.1.74",
"private": true,
"scripts": {
"dev": "next dev",
@@ -1,5 +1,29 @@
# test-edge-runtime
## 0.1.73
### Patch Changes
- Updated dependencies [f7b4e94]
- Updated dependencies [78037a6]
- Updated dependencies [1d9e3b1]
- llamaindex@0.6.12
## 0.1.72
### Patch Changes
- Updated dependencies [df441e2]
- llamaindex@0.6.11
## 0.1.71
### Patch Changes
- Updated dependencies [ebc5105]
- Updated dependencies [6cce3b1]
- llamaindex@0.6.10
## 0.1.70
### Patch Changes

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