Compare commits

..

11 Commits

Author SHA1 Message Date
Clelia (Astra) Bertelli df71df48c0 ci: linting, type checking and testing - fix 2025-08-08 16:30:40 +02:00
Clelia (Astra) Bertelli d4b6fe6156 Merge branch 'main' into clelia/llm-exec-response-format 2025-08-08 15:41:30 +02:00
Clelia (Astra) Bertelli 6a426305da chore: add example for structured response 2025-07-22 13:39:51 +02:00
Clelia (Astra) Bertelli 56924edded chore: move all tool examples to zod/v4 2025-07-22 13:37:18 +02:00
Clelia (Astra) Bertelli b0985d1b8c chore: move tools to zod/v4 for better schema conversion 2025-07-22 13:18:17 +02:00
Logan Markewich 72d681be47 remove tests 2025-07-18 10:09:45 -06:00
Logan Markewich da751b28fe fix typing 2025-07-18 09:32:25 -06:00
Logan Markewich 3109f6640f fix typing 2025-07-18 09:21:07 -06:00
Clelia (Astra) Bertelli 1214b5f3ef fix: better schema for the tool 2025-07-18 16:08:54 +02:00
Clelia (Astra) Bertelli 53a8cb9b4a chore: changesets 2025-07-18 12:34:05 +02:00
Clelia (Astra) Bertelli d647786e67 feat: add responseFormat to llm.exec 2025-07-18 12:32:12 +02:00
210 changed files with 1548 additions and 4214 deletions
+9
View File
@@ -0,0 +1,9 @@
---
"@llamaindex/workflow": minor
"@llamaindex/tools": minor
"@llamaindex/core": minor
"@llamaindex/resolution-tests": patch
"@llamaindex/e2e": patch
---
Moving tools from zod to zod/v4; adding responseFormat to llm.exec
+2 -3
View File
@@ -105,7 +105,6 @@ jobs:
run: |
pnpm pack --pack-destination ${{ runner.temp }} -C packages/llamaindex
pnpm pack --pack-destination ${{ runner.temp }} -C packages/workflow
pnpm pack --pack-destination ${{ runner.temp }} -C packages/core
- name: Install packed packages
run: npm add ${{ runner.temp }}/*.tgz
working-directory: e2e/npm
@@ -163,7 +162,7 @@ jobs:
github_token: ${{ secrets.GITHUB_TOKEN }}
directory: e2e/examples/vite-import-llamaindex
skip_step: "install"
build_script: ci-build
build_script: build
package_manager: pnpm
typecheck-examples:
@@ -204,7 +203,7 @@ jobs:
fi
done
- name: Install
run: npm add ${{ runner.temp }}/*.tgz --legacy-peer-deps
run: npm add ${{ runner.temp }}/*.tgz
working-directory: ${{ runner.temp }}/examples
- name: Run Type Check
run: npx tsc --project ./tsconfig.json
-39
View File
@@ -1,44 +1,5 @@
# @llamaindex/doc
## 0.2.54
### Patch Changes
- ed37c64: Addition of APAC_ANTHROPIC_CLAUDE_4_SONNET type/record in @llamaindex/aws for APAC support for claude 4 sonnet per issue 2184.
- Updated dependencies [8929dcf]
- Updated dependencies [5da1cda]
- llamaindex@0.11.29
- @llamaindex/core@0.6.21
- @llamaindex/workflow@1.1.23
- @llamaindex/openai@0.4.19
- @llamaindex/cloud@4.1.3
- @llamaindex/node-parser@2.0.21
- @llamaindex/readers@3.1.20
## 0.2.53
### Patch Changes
- Updated dependencies [1995b38]
- Updated dependencies [001a515]
- Updated dependencies [9d7d205]
- @llamaindex/workflow@1.1.22
- @llamaindex/openai@0.4.18
- llamaindex@0.11.28
## 0.2.52
### Patch Changes
- Updated dependencies [0267bb0]
- @llamaindex/core@0.6.20
- @llamaindex/cloud@4.1.2
- llamaindex@0.11.27
- @llamaindex/node-parser@2.0.20
- @llamaindex/openai@0.4.17
- @llamaindex/readers@3.1.19
- @llamaindex/workflow@1.1.21
## 0.2.51
### Patch Changes
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/doc",
"version": "0.2.54",
"version": "0.2.51",
"private": true,
"scripts": {
"postinstall": "fumadocs-mdx",
@@ -15,7 +15,7 @@
"dependencies": {
"@huggingface/transformers": "^3.5.0",
"@icons-pack/react-simple-icons": "^10.1.0",
"@llamaindex/chat-ui-docs": "^0.1.0",
"@llamaindex/chat-ui-docs": "^0.0.5",
"@llamaindex/cloud": "workspace:*",
"@llamaindex/core": "workspace:*",
"@llamaindex/node-parser": "workspace:*",
@@ -115,7 +115,6 @@ EU_AMAZON_NOVA_MICRO_1 = "eu.amazon.nova-micro-v1:0";
APAC_ANTHROPIC_CLAUDE_3_5_SONNET = "apac.anthropic.claude-3-5-sonnet-20240620-v1:0";
APAC_ANTHROPIC_CLAUDE_3_5_SONNET_V2 = "apac.anthropic.claude-3-5-sonnet-20241022-v2:0";
APAC_ANTHROPIC_CLAUDE_3_7_SONNET = "apac.anthropic.claude-3-7-sonnet-20250219-v1:0";
APAC_ANTHROPIC_CLAUDE_4_SONNET = "apac.anthropic.claude-sonnet-4-20250514-v1:0";
APAC_ANTHROPIC_CLAUDE_3_HAIKU = "apac.anthropic.claude-3-haiku-20240307-v1:0";
APAC_ANTHROPIC_CLAUDE_3_SONNET = "apac.anthropic.claude-3-sonnet-20240229-v1:0";
APAC_AMAZON_NOVA_PRO_1 = "apac.amazon.nova-pro-v1:0";
@@ -1,47 +0,0 @@
---
title: Custom Model Per Request
---
There are scenarios, such as the case of a multi-tenant backend API, where it may be required to handle each request with a custom model.
In such a scenario, modifying the `Settings` object directly as follows is not recommended:
```typescript
import { Settings } from 'llamaindex';
import { OpenAIEmbedding } from '@llamaindex/embeddings-openai';
Settings.embedModel = new OpenAIEmbedding({ apiKey: 'CLIENT_API_KEY' });
Settings.llm = openai({ apiKey: key, model: 'gpt-4o' })
```
Setting `llm` and `embedModel` directly will lead to unpredictable responses, since `Settings` is global and mutable.
This can lead to race conditions, as each request modifies `Settings.embedModel` or `Settings.llm`.
The recommended approach is to use `Settings.withEmbedModel` or `Settings.withLLM` as follows:
```typescript
const embedModel = new OpenAIEmbedding({
apiKey: process.env.OPENAI_API_KEY,
});
const llm = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
const llmResponse = await Settings.withEmbedModel(embedModel, async () => {
return Settings.withLLM(llm, async () => {
const path = "node_modules/llamaindex/examples/abramov.txt";
const essay = await fs.readFile(path, "utf-8");
// Create Document object with essay
const document = new Document({ text: essay, id_: path });
// Split text and create embeddings. Store them in a VectorStoreIndex
const index = await VectorStoreIndex.fromDocuments([document]);
// Query the index
const queryEngine = index.asQueryEngine();
const { message, sourceNodes } = await queryEngine.query({
query: "What did the author do in college?",
});
// Return response with sources
return message.content;
});
});
```
The full example can be found [here](https://github.com/run-llama/LlamaIndexTS/tree/main/examples/local-settings).
@@ -7,7 +7,6 @@
"workflows",
"local_llm",
"chatbot",
"structured_data_extraction",
"custom_model_per_request"
"structured_data_extraction"
]
}
@@ -46,31 +46,3 @@ You should expect output something like:
]
}
```
## Using the `exec` method
Many LLMs do not natively support structured output, and often rely exclusively on prompt or context engineering.
In this sense, we proved you with an alternative for structured data extraction, using the `exec` method with `responseFormat`.
For example, you can, in a new folder, install our Anthropic integration and `zod` v3:
```package-install
npm init
npm i -D typescript @types/node
npm i @llamaindex/anthropic zod@3.25.76
```
And then try extracting data with this code:
<include cwd>../../examples/agents/tools/response-format-exec.ts</include>
The output should look like this:
```json
{
"title": "La Divina Commedia",
"author": "Dante Alighieri",
"year": 1321
}
```
@@ -1,24 +1,5 @@
# @llamaindex/cloudflare-worker-agent-test
## 0.0.190
### Patch Changes
- Updated dependencies [8929dcf]
- llamaindex@0.11.29
## 0.0.189
### Patch Changes
- llamaindex@0.11.28
## 0.0.188
### Patch Changes
- llamaindex@0.11.27
## 0.0.187
### Patch Changes
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/cloudflare-worker-agent-test",
"version": "0.0.190",
"version": "0.0.187",
"type": "module",
"private": true,
"scripts": {
@@ -1,17 +1,5 @@
# @llamaindex/llama-parse-browser-test
## 0.0.87
### Patch Changes
- @llamaindex/cloud@4.1.3
## 0.0.86
### Patch Changes
- @llamaindex/cloud@4.1.2
## 0.0.85
### Patch Changes
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/llama-parse-browser-test",
"private": true,
"version": "0.0.87",
"version": "0.0.85",
"type": "module",
"scripts": {
"dev": "vite",
@@ -10,7 +10,7 @@
},
"devDependencies": {
"typescript": "^5.8.3",
"vite": "^6.3.6",
"vite": "^6.3.3",
"vite-plugin-wasm": "^3.4.1"
},
"dependencies": {
-19
View File
@@ -1,24 +1,5 @@
# @llamaindex/next-agent-test
## 0.1.190
### Patch Changes
- Updated dependencies [8929dcf]
- llamaindex@0.11.29
## 0.1.189
### Patch Changes
- llamaindex@0.11.28
## 0.1.188
### Patch Changes
- llamaindex@0.11.27
## 0.1.187
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/next-agent-test",
"version": "0.1.190",
"version": "0.1.187",
"private": true,
"scripts": {
"dev": "next dev",
@@ -1,24 +1,5 @@
# test-edge-runtime
## 0.1.189
### Patch Changes
- Updated dependencies [8929dcf]
- llamaindex@0.11.29
## 0.1.188
### Patch Changes
- llamaindex@0.11.28
## 0.1.187
### Patch Changes
- llamaindex@0.11.27
## 0.1.186
### Patch Changes
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/nextjs-edge-runtime-test",
"version": "0.1.189",
"version": "0.1.186",
"private": true,
"scripts": {
"dev": "next dev",
@@ -1,29 +1,5 @@
# @llamaindex/next-node-runtime
## 0.1.61
### Patch Changes
- Updated dependencies [8929dcf]
- llamaindex@0.11.29
- @llamaindex/huggingface@0.1.29
- @llamaindex/readers@3.1.20
## 0.1.60
### Patch Changes
- llamaindex@0.11.28
- @llamaindex/huggingface@0.1.28
## 0.1.59
### Patch Changes
- llamaindex@0.11.27
- @llamaindex/huggingface@0.1.27
- @llamaindex/readers@3.1.19
## 0.1.58
### Patch Changes
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/next-node-runtime-test",
"version": "0.1.61",
"version": "0.1.58",
"private": true,
"scripts": {
"dev": "next dev",
@@ -1,24 +1,5 @@
# vite-import-llamaindex
## 0.0.56
### Patch Changes
- Updated dependencies [8929dcf]
- llamaindex@0.11.29
## 0.0.55
### Patch Changes
- llamaindex@0.11.28
## 0.0.54
### Patch Changes
- llamaindex@0.11.27
## 0.0.53
### Patch Changes
@@ -1,12 +1,11 @@
{
"name": "vite-import-llamaindex",
"private": true,
"version": "0.0.56",
"version": "0.0.53",
"type": "module",
"scripts": {
"build": "vite build",
"size-limit": "size-limit",
"ci-build": "pnpm -C ../../../ build && vite build"
"size-limit": "size-limit"
},
"size-limit": [
{
@@ -17,7 +16,7 @@
"@size-limit/preset-big-lib": "^11.1.6",
"size-limit": "^11.1.6",
"typescript": "^5.8.3",
"vite": "^6.3.6"
"vite": "^6.3.3"
},
"dependencies": {
"llamaindex": "workspace:*"
@@ -1 +1 @@
{"root":["./src/main.ts","./vite.config.ts"],"version":"5.7.3"}
{"root":["./src/main.ts","./vite.config.ts"],"version":"5.8.3"}
@@ -1,24 +1,5 @@
# @llamaindex/waku-query-engine-test
## 0.0.190
### Patch Changes
- Updated dependencies [8929dcf]
- llamaindex@0.11.29
## 0.0.189
### Patch Changes
- llamaindex@0.11.28
## 0.0.188
### Patch Changes
- llamaindex@0.11.27
## 0.0.187
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/waku-query-engine-test",
"version": "0.0.190",
"version": "0.0.187",
"type": "module",
"private": true,
"scripts": {
+6 -14
View File
@@ -1,5 +1,5 @@
import { FunctionTool } from "llamaindex";
import { z } from "zod";
import * as z from "zod/v4";
function sumNumbers({ a, b }: { a: number; b: number }) {
return `${a + b}`;
@@ -13,12 +13,8 @@ export const sumNumbersTool = FunctionTool.from(sumNumbers, {
name: "sumNumbers",
description: "Use this function to sum two numbers",
parameters: z.object({
a: z.number({
description: "The first number",
}),
b: z.number({
description: "The second number",
}),
a: z.number({}).describe("The first number"),
b: z.number({}).describe("The second number"),
}),
});
@@ -26,12 +22,8 @@ export const divideNumbersTool = FunctionTool.from(divideNumbers, {
name: "divideNumbers",
description: "Use this function to divide two numbers",
parameters: z.object({
a: z.number({
description: "The first number",
}),
b: z.number({
description: "The second number",
}),
a: z.number({}).describe("The first number"),
b: z.number({}).describe("The second number"),
}),
});
@@ -44,7 +36,7 @@ export const getWeatherTool = FunctionTool.from(
name: "getWeather",
description: "Get the weather for a city",
parameters: z.object({
city: z.string().describe("The city to get the weather for"),
city: z.string({}).describe("The city to get the weather for"),
}),
},
);
+1 -1
View File
@@ -3,7 +3,7 @@ import { agent } from "@llamaindex/workflow";
import { Settings, tool } from "llamaindex";
import { ok } from "node:assert";
import { test } from "node:test";
import { z } from "zod";
import * as z from "zod/v4";
Settings.llm = new OpenAI({ model: "gpt-4-0613" });
-130
View File
@@ -1,135 +1,5 @@
# examples
## 0.3.41
### Patch Changes
- Updated dependencies [8929dcf]
- Updated dependencies [5da1cda]
- Updated dependencies [5d5cd44]
- Updated dependencies [c40adaf]
- llamaindex@0.11.29
- @llamaindex/core@0.6.21
- @llamaindex/tools@0.1.11
- @llamaindex/workflow@1.1.23
- @llamaindex/ollama@0.1.22
- @llamaindex/openai@0.4.19
- @llamaindex/vercel@0.1.21
- @llamaindex/anthropic@0.3.24
- @llamaindex/google@0.3.21
- @llamaindex/cloud@4.1.3
- @llamaindex/node-parser@2.0.21
- @llamaindex/assemblyai@0.1.20
- @llamaindex/clip@0.0.75
- @llamaindex/cohere@0.0.35
- @llamaindex/deepinfra@0.0.75
- @llamaindex/discord@0.1.20
- @llamaindex/huggingface@0.1.29
- @llamaindex/jinaai@0.0.35
- @llamaindex/mistral@0.1.21
- @llamaindex/mixedbread@0.0.35
- @llamaindex/notion@0.1.20
- @llamaindex/perplexity@0.0.32
- @llamaindex/portkey-ai@0.0.63
- @llamaindex/replicate@0.0.63
- @llamaindex/bm25-retriever@0.0.10
- @llamaindex/astra@0.0.35
- @llamaindex/azure@0.1.36
- @llamaindex/chroma@0.0.35
- @llamaindex/elastic-search@0.1.21
- @llamaindex/firestore@1.0.28
- @llamaindex/milvus@0.1.30
- @llamaindex/mongodb@0.0.36
- @llamaindex/pinecone@0.1.21
- @llamaindex/postgres@0.0.64
- @llamaindex/qdrant@0.1.31
- @llamaindex/supabase@0.1.22
- @llamaindex/upstash@0.0.35
- @llamaindex/weaviate@0.0.36
- @llamaindex/voyage-ai@1.0.27
- @llamaindex/readers@3.1.20
- @llamaindex/deepseek@0.0.37
- @llamaindex/fireworks@0.0.35
- @llamaindex/groq@0.0.91
- @llamaindex/together@0.0.35
- @llamaindex/vllm@0.0.61
- @llamaindex/xai@0.0.22
## 0.3.40
### Patch Changes
- Updated dependencies [1995b38]
- Updated dependencies [001a515]
- Updated dependencies [9d7d205]
- @llamaindex/workflow@1.1.22
- @llamaindex/openai@0.4.18
- llamaindex@0.11.28
- @llamaindex/clip@0.0.74
- @llamaindex/deepinfra@0.0.74
- @llamaindex/deepseek@0.0.36
- @llamaindex/fireworks@0.0.34
- @llamaindex/groq@0.0.90
- @llamaindex/huggingface@0.1.28
- @llamaindex/jinaai@0.0.34
- @llamaindex/perplexity@0.0.31
- @llamaindex/azure@0.1.35
- @llamaindex/together@0.0.34
- @llamaindex/vllm@0.0.60
- @llamaindex/xai@0.0.21
## 0.3.39
### Patch Changes
- Updated dependencies [0267bb0]
- @llamaindex/core@0.6.20
- @llamaindex/cloud@4.1.2
- llamaindex@0.11.27
- @llamaindex/node-parser@2.0.20
- @llamaindex/anthropic@0.3.23
- @llamaindex/assemblyai@0.1.19
- @llamaindex/clip@0.0.73
- @llamaindex/cohere@0.0.34
- @llamaindex/deepinfra@0.0.73
- @llamaindex/discord@0.1.19
- @llamaindex/google@0.3.20
- @llamaindex/huggingface@0.1.27
- @llamaindex/jinaai@0.0.33
- @llamaindex/mistral@0.1.20
- @llamaindex/mixedbread@0.0.34
- @llamaindex/notion@0.1.19
- @llamaindex/ollama@0.1.21
- @llamaindex/openai@0.4.17
- @llamaindex/perplexity@0.0.30
- @llamaindex/portkey-ai@0.0.62
- @llamaindex/replicate@0.0.62
- @llamaindex/bm25-retriever@0.0.9
- @llamaindex/astra@0.0.34
- @llamaindex/azure@0.1.34
- @llamaindex/chroma@0.0.34
- @llamaindex/elastic-search@0.1.20
- @llamaindex/firestore@1.0.27
- @llamaindex/milvus@0.1.29
- @llamaindex/mongodb@0.0.35
- @llamaindex/pinecone@0.1.20
- @llamaindex/postgres@0.0.63
- @llamaindex/qdrant@0.1.30
- @llamaindex/supabase@0.1.21
- @llamaindex/upstash@0.0.34
- @llamaindex/weaviate@0.0.35
- @llamaindex/vercel@0.1.20
- @llamaindex/voyage-ai@1.0.26
- @llamaindex/readers@3.1.19
- @llamaindex/tools@0.1.10
- @llamaindex/workflow@1.1.21
- @llamaindex/deepseek@0.0.35
- @llamaindex/fireworks@0.0.33
- @llamaindex/groq@0.0.89
- @llamaindex/together@0.0.33
- @llamaindex/vllm@0.0.59
- @llamaindex/xai@0.0.20
## 0.3.38
### Patch Changes
+1 -1
View File
@@ -8,7 +8,7 @@ import {
import fs from "fs";
import { tool } from "llamaindex";
import os from "os";
import { z } from "zod";
import * as z from "zod/v4";
import { wiki } from "@llamaindex/tools";
const llm = openai({
+1 -1
View File
@@ -1,7 +1,7 @@
import { OpenAI } from "@llamaindex/openai";
import { agent } from "@llamaindex/workflow";
import { tool } from "llamaindex";
import { z } from "zod";
import * as z from "zod/v4";
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";
+1 -1
View File
@@ -15,7 +15,7 @@ import {
stopAgentEvent,
} from "@llamaindex/workflow";
import { tool } from "llamaindex";
import { z } from "zod";
import * as z from "zod/v4";
const llm = openai({
model: "gpt-4o-mini",
+1 -1
View File
@@ -1,7 +1,7 @@
import { openai } from "@llamaindex/openai";
import { agent } from "@llamaindex/workflow";
import { tool } from "llamaindex";
import { z } from "zod";
import * as z from "zod/v4";
const sumNumbers = tool({
name: "sumNumbers",
+1 -1
View File
@@ -6,7 +6,7 @@ import {
} from "@llamaindex/workflow";
import fs from "fs";
import { tool } from "llamaindex";
import { z } from "zod";
import * as z from "zod/v4";
import { anthropic } from "@llamaindex/anthropic";
+5 -2
View File
@@ -14,8 +14,11 @@ const writeJokeSchema = z.object({
.describe("The topic to write a joke or describe the joke to improve."),
writtenJoke: z.optional(z.string()).describe("The written joke."),
retriedTimes: z
.optional(z.number().default(0))
.describe("The retried times for writing the joke."),
.number()
.default(0)
.describe(
"The retried times for writing the joke. Always increase this from the input retriedTimes.",
),
});
const critiqueSchema = z.object({
+1 -1
View File
@@ -1,6 +1,6 @@
import { openai } from "@llamaindex/openai";
import { tool } from "llamaindex";
import z from "zod";
import * as z from "zod/v4";
import { ChatMessage } from "llamaindex";
+1 -1
View File
@@ -1,6 +1,6 @@
import { openai } from "@llamaindex/openai";
import { ChatMessage, tool } from "llamaindex";
import z from "zod";
import * as z from "zod/v4";
async function main() {
const llm = openai({ model: "gpt-4.1-mini" });
@@ -1,13 +1,13 @@
import { Anthropic } from "@llamaindex/anthropic";
import { ChatMessage, ToolCall } from "llamaindex";
import { z } from "zod";
import * as z from "zod/v4";
const llm = new Anthropic({ model: "claude-4-0-sonnet" });
const responseSchema = z.object({
title: z.string().describe("The title of the book"),
author: z.string().describe("The author of the book"),
year: z.number().describe("The publication year"),
title: z.string(),
author: z.string(),
year: z.number(),
});
async function main() {
@@ -27,7 +27,6 @@ async function main() {
],
responseFormat: responseSchema,
});
console.log(result.newMessages[0].content);
messages.push(...result.newMessages);
toolCalls = result.toolCalls;
} while (toolCalls.length == 0);
+1 -1
View File
@@ -1,5 +1,5 @@
import { tool } from "llamaindex";
import { z } from "zod";
import * as z from "zod/v4";
export const getCurrentIDTool = tool({
name: "get_user_id",
+4 -4
View File
@@ -22,7 +22,7 @@ const { withState, getContext } = createStatefulMiddleware(() => ({
const jokeFlow = withState(createWorkflow());
// Define handlers for each step
jokeFlow.handle([startEvent], async (context, event) => {
jokeFlow.handle([startEvent], async (event) => {
// Prompt the LLM to write a joke
const prompt = `Write your best joke about ${event.data}. Write the joke between <joke> and </joke> tags.`;
const response = await llm.complete({ prompt });
@@ -34,7 +34,7 @@ jokeFlow.handle([startEvent], async (context, event) => {
return jokeEvent.with({ joke: joke });
});
jokeFlow.handle([jokeEvent], async (context, event) => {
jokeFlow.handle([jokeEvent], async (event) => {
// Prompt the LLM to critique the joke
const prompt = `Give a thorough critique of the following joke. If the joke needs improvement, put "IMPROVE" somewhere in the critique: ${event.data.joke}`;
const response = await llm.complete({ prompt });
@@ -50,9 +50,9 @@ jokeFlow.handle([jokeEvent], async (context, event) => {
return resultEvent.with({ joke: event.data.joke, critique: response.text });
});
jokeFlow.handle([critiqueEvent], async (context, event) => {
jokeFlow.handle([critiqueEvent], async (event) => {
// Keep track of the number of iterations
const state = context.state;
const state = getContext().state;
state.numIterations++;
// Write a new joke based on the previous joke and critique
@@ -1,6 +1,6 @@
import { OpenAI } from "@llamaindex/openai";
import { FunctionTool, ToolCallOptions } from "llamaindex";
import { z } from "zod";
import * as z from "zod/v4";
(async () => {
// The tool call will generate a partial JSON for `gpt-4-turbo`
@@ -6,7 +6,7 @@ import {
NodeWithScore,
VectorStoreIndex,
} from "llamaindex";
import { z } from "zod";
import * as z from "zod/v4";
async function main() {
// Load the documents
@@ -1,6 +1,6 @@
import { OpenAIAgent } from "@llamaindex/openai";
import { FunctionTool } from "llamaindex";
import { z } from "zod";
import * as z from "zod/v4";
// Define a function to sum two numbers
function sumNumbers({ a, b }: { a: number; b: number }) {
-69
View File
@@ -1,69 +0,0 @@
import { OpenAI, OpenAIEmbedding } from "@llamaindex/openai";
import express, { Request, Response } from "express";
import fs from "fs/promises";
import { Document, Settings, VectorStoreIndex } from "llamaindex";
const app = express();
const port = 3000;
app.get("/default", async (req: Request, res: Response) => {
const embedModel = new OpenAIEmbedding({
apiKey: process.env.OPENAI_API_KEY,
});
const llm = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
const llmResponse = await Settings.withEmbedModel(embedModel, async () => {
return Settings.withLLM(llm, async () => {
const path = "node_modules/llamaindex/examples/abramov.txt";
const essay = await fs.readFile(path, "utf-8");
// Create Document object with essay
const document = new Document({ text: essay, id_: path });
// Split text and create embeddings. Store them in a VectorStoreIndex
const index = await VectorStoreIndex.fromDocuments([document]);
// Query the index
const queryEngine = index.asQueryEngine();
const { message, sourceNodes } = await queryEngine.query({
query: "What did the author do in college?",
});
// Return response with sources
return message.content;
});
});
// res.send(message.content)
res.send(llmResponse);
});
app.get("/custom", async (req: Request, res: Response) => {
const embedModel = new OpenAIEmbedding({
apiKey: process.env.OPENAI_API_KEY,
model: "text-embedding-3-small",
});
const llm = new OpenAI({
apiKey: process.env.OPENAI_API_KEY,
model: "gpt-3.5-turbo",
});
const llmResponse = await Settings.withEmbedModel(embedModel, async () => {
return Settings.withLLM(llm, async () => {
const path = "node_modules/llamaindex/examples/abramov.txt";
const essay = await fs.readFile(path, "utf-8");
// Create Document object with essay
const document = new Document({ text: essay, id_: path });
// Split text and create embeddings. Store them in a VectorStoreIndex
const index = await VectorStoreIndex.fromDocuments([document]);
// Query the index
const queryEngine = index.asQueryEngine();
const { message, sourceNodes } = await queryEngine.query({
query: "What did the author do in college?",
});
// Return response with sources
return message.content;
});
});
// res.send(message.content)
res.send(llmResponse);
});
app.listen(port, () => {
console.log(`Example app listening on port ${port}`);
});
-22
View File
@@ -1,22 +0,0 @@
{
"name": "local-settings",
"version": "1.0.0",
"main": "index.js",
"private": "true",
"scripts": {
"test": "echo \"No tests for example package\""
},
"keywords": [],
"author": "",
"license": "ISC",
"description": "",
"devDependencies": {
"@types/express": "^5.0.3",
"typescript": "^5.9.2"
},
"dependencies": {
"@llamaindex/openai": "^0.4.16",
"express": "^5.1.0",
"llamaindex": "^0.11.26"
}
}
-8
View File
@@ -1,8 +0,0 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"moduleResolution": "node",
"types": ["node", "express"]
},
"include": ["*.ts"]
}
+1 -1
View File
@@ -2,7 +2,7 @@ import { anthropic } from "@llamaindex/anthropic";
import { wiki } from "@llamaindex/tools";
import { agent } from "@llamaindex/workflow";
import { tool } from "llamaindex";
import { z } from "zod";
import * as z from "zod/v4";
const workflow = agent({
tools: [
+1 -2
View File
@@ -1,8 +1,7 @@
import { gemini, GEMINI_MODEL } from "@llamaindex/google";
import { agent } from "@llamaindex/workflow";
import { tool } from "llamaindex";
import { z } from "zod";
import * as z from "zod/v4";
const sumNumbers = tool({
name: "sumNumbers",
description: "Use this function to sum two numbers",
+1 -2
View File
@@ -1,8 +1,7 @@
import { gemini, GEMINI_MODEL } from "@llamaindex/google";
import fs from "fs";
import { tool } from "llamaindex";
import { z } from "zod";
import * as z from "zod/v4";
(async () => {
if (!process.env.GOOGLE_API_KEY) {
throw new Error("Please set the GOOGLE_API_KEY environment variable.");
+1 -1
View File
@@ -2,7 +2,7 @@ import { gemini, GEMINI_MODEL } from "@llamaindex/google";
import { ModalityType, tool } from "llamaindex";
import { liveEvents } from "llamaindex";
import { z } from "zod";
import * as z from "zod/v4";
const weatherTool = tool({
name: "weather",
+1 -1
View File
@@ -3,7 +3,7 @@ import { wiki } from "@llamaindex/tools";
import { agent } from "@llamaindex/workflow";
import { tool } from "llamaindex";
import { z } from "zod";
import * as z from "zod/v4";
const workflow = agent({
tools: [
+1 -1
View File
@@ -2,7 +2,7 @@ import { openaiResponses } from "@llamaindex/openai";
import { wiki } from "@llamaindex/tools";
import { agent } from "@llamaindex/workflow";
import { tool } from "llamaindex";
import { z } from "zod";
import * as z from "zod/v4";
const workflow = agent({
tools: [
@@ -1,7 +1,7 @@
import { openaiResponses } from "@llamaindex/openai";
import { tool } from "llamaindex";
import { z } from "zod";
import * as z from "zod/v4";
async function main() {
const weatherTool = tool({
name: "weather",
+2 -2
View File
@@ -1,6 +1,6 @@
import { openai } from "@ai-sdk/openai";
import { llamaindex } from "@llamaindex/vercel";
import { stepCountIs, streamText } from "ai";
import { streamText } from "ai";
import { Document, LlamaCloudIndex } from "llamaindex";
import fs from "node:fs/promises";
@@ -28,7 +28,7 @@ async function main() {
"get information from your knowledge base to answer questions.", // optional description
}),
},
stopWhen: stepCountIs(5),
maxSteps: 5,
});
for await (const textPart of result.textStream) {
+2 -2
View File
@@ -1,6 +1,6 @@
import { openai } from "@ai-sdk/openai";
import { llamaindex } from "@llamaindex/vercel";
import { stepCountIs, streamText } from "ai";
import { streamText } from "ai";
import { Document, VectorStoreIndex } from "llamaindex";
import fs from "node:fs/promises";
@@ -24,7 +24,7 @@ async function main() {
"get information from your knowledge base to answer questions.", // optional description
}),
},
stopWhen: stepCountIs(5),
maxSteps: 5,
});
for await (const textPart of result.textStream) {
+50 -51
View File
@@ -1,78 +1,77 @@
{
"name": "@llamaindex/examples",
"version": "0.3.41",
"version": "0.3.38",
"private": true,
"scripts": {
"lint": "eslint .",
"start": "echo 'To get started, run `npx tsx <path to example>`'"
},
"dependencies": {
"@ai-sdk/openai": "^2.0.27",
"@ai-sdk/openai": "^1.0.5",
"@azure/cosmos": "^4.1.1",
"@azure/identity": "^4.4.1",
"@azure/search-documents": "^12.1.0",
"@llamaindex/anthropic": "^0.3.24",
"@llamaindex/assemblyai": "^0.1.20",
"@llamaindex/astra": "^0.0.35",
"@llamaindex/azure": "^0.1.36",
"@llamaindex/bm25-retriever": "^0.0.10",
"@llamaindex/chroma": "^0.0.35",
"@llamaindex/clip": "^0.0.75",
"@llamaindex/cloud": "^4.1.3",
"@llamaindex/cohere": "^0.0.35",
"@llamaindex/core": "^0.6.21",
"@llamaindex/deepinfra": "^0.0.75",
"@llamaindex/deepseek": "^0.0.37",
"@llamaindex/discord": "^0.1.20",
"@llamaindex/elastic-search": "^0.1.21",
"@llamaindex/anthropic": "^0.3.22",
"@llamaindex/assemblyai": "^0.1.18",
"@llamaindex/astra": "^0.0.33",
"@llamaindex/azure": "^0.1.33",
"@llamaindex/bm25-retriever": "^0.0.8",
"@llamaindex/chroma": "^0.0.33",
"@llamaindex/clip": "^0.0.72",
"@llamaindex/cloud": "^4.1.1",
"@llamaindex/cohere": "^0.0.33",
"@llamaindex/core": "^0.6.19",
"@llamaindex/deepinfra": "^0.0.72",
"@llamaindex/deepseek": "^0.0.34",
"@llamaindex/discord": "^0.1.18",
"@llamaindex/elastic-search": "^0.1.19",
"@llamaindex/env": "^0.1.30",
"@llamaindex/firestore": "^1.0.28",
"@llamaindex/fireworks": "^0.0.35",
"@llamaindex/google": "^0.3.21",
"@llamaindex/groq": "^0.0.91",
"@llamaindex/huggingface": "^0.1.29",
"@llamaindex/jinaai": "^0.0.35",
"@llamaindex/milvus": "^0.1.30",
"@llamaindex/mistral": "^0.1.21",
"@llamaindex/mixedbread": "^0.0.35",
"@llamaindex/mongodb": "^0.0.36",
"@llamaindex/node-parser": "^2.0.21",
"@llamaindex/notion": "^0.1.20",
"@llamaindex/ollama": "^0.1.22",
"@llamaindex/openai": "^0.4.19",
"@llamaindex/perplexity": "^0.0.32",
"@llamaindex/pinecone": "^0.1.21",
"@llamaindex/portkey-ai": "^0.0.63",
"@llamaindex/postgres": "^0.0.64",
"@llamaindex/qdrant": "^0.1.31",
"@llamaindex/readers": "^3.1.20",
"@llamaindex/replicate": "^0.0.63",
"@llamaindex/supabase": "^0.1.22",
"@llamaindex/together": "^0.0.35",
"@llamaindex/tools": "^0.1.11",
"@llamaindex/upstash": "^0.0.35",
"@llamaindex/vercel": "^0.1.21",
"@llamaindex/vllm": "^0.0.61",
"@llamaindex/voyage-ai": "^1.0.27",
"@llamaindex/weaviate": "^0.0.36",
"@llamaindex/workflow": "^1.1.23",
"@llamaindex/xai": "^0.0.22",
"@llamaindex/firestore": "^1.0.26",
"@llamaindex/fireworks": "^0.0.32",
"@llamaindex/google": "^0.3.18",
"@llamaindex/groq": "^0.0.88",
"@llamaindex/huggingface": "^0.1.26",
"@llamaindex/jinaai": "^0.0.32",
"@llamaindex/milvus": "^0.1.28",
"@llamaindex/mistral": "^0.1.19",
"@llamaindex/mixedbread": "^0.0.33",
"@llamaindex/mongodb": "^0.0.34",
"@llamaindex/node-parser": "^2.0.19",
"@llamaindex/notion": "^0.1.18",
"@llamaindex/ollama": "^0.1.20",
"@llamaindex/openai": "^0.4.16",
"@llamaindex/perplexity": "^0.0.29",
"@llamaindex/pinecone": "^0.1.19",
"@llamaindex/portkey-ai": "^0.0.61",
"@llamaindex/postgres": "^0.0.62",
"@llamaindex/qdrant": "^0.1.29",
"@llamaindex/readers": "^3.1.18",
"@llamaindex/replicate": "^0.0.61",
"@llamaindex/supabase": "^0.1.20",
"@llamaindex/together": "^0.0.32",
"@llamaindex/tools": "^0.1.9",
"@llamaindex/upstash": "^0.0.33",
"@llamaindex/vercel": "^0.1.19",
"@llamaindex/vllm": "^0.0.58",
"@llamaindex/voyage-ai": "^1.0.25",
"@llamaindex/weaviate": "^0.0.34",
"@llamaindex/workflow": "^1.1.20",
"@llamaindex/xai": "^0.0.19",
"@notionhq/client": "^4.0.0",
"@pinecone-database/pinecone": "^4.0.0",
"@vercel/postgres": "^0.10.0",
"ai": "^5.0.39",
"ai": "^4.3.17",
"ajv": "^8.17.1",
"commander": "^12.1.0",
"dotenv": "^17.2.0",
"js-tiktoken": "^1.0.14",
"llamaindex": "^0.11.29",
"llamaindex": "^0.11.26",
"mongodb": "6.7.0",
"postgres": "^3.4.4",
"wikipedia": "^2.1.2",
"zod": "^4.1.5"
"zod": "^3.25.76"
},
"devDependencies": {
"@types/express": "^5.0.3",
"@types/node": "^24.0.13",
"tsx": "^4.20.3",
"typescript": "^5.8.3"
-19
View File
@@ -1,24 +1,5 @@
# @llamaindex/autotool
## 8.0.29
### Patch Changes
- Updated dependencies [8929dcf]
- llamaindex@0.11.29
## 8.0.28
### Patch Changes
- llamaindex@0.11.28
## 8.0.27
### Patch Changes
- llamaindex@0.11.27
## 8.0.26
### Patch Changes
@@ -1,27 +1,5 @@
# @llamaindex/autotool-01-node-example
## 0.0.137
### Patch Changes
- Updated dependencies [8929dcf]
- llamaindex@0.11.29
- @llamaindex/autotool@8.0.29
## 0.0.136
### Patch Changes
- llamaindex@0.11.28
- @llamaindex/autotool@8.0.28
## 0.0.135
### Patch Changes
- llamaindex@0.11.27
- @llamaindex/autotool@8.0.27
## 0.0.134
### Patch Changes
@@ -13,5 +13,5 @@
"scripts": {
"start": "node --import tsx --import @llamaindex/autotool/node ./src/index.ts"
},
"version": "0.0.137"
"version": "0.0.134"
}
+1 -1
View File
@@ -6,7 +6,7 @@
"url": "git+https://github.com/run-llama/LlamaIndexTS.git",
"directory": "packages/autotool"
},
"version": "8.0.29",
"version": "8.0.26",
"description": "auto transpile your JS function to LLM Agent compatible",
"files": [
"dist",
-14
View File
@@ -1,19 +1,5 @@
# @llamaindex/cloud
## 4.1.3
### Patch Changes
- Updated dependencies [5da1cda]
- @llamaindex/core@0.6.21
## 4.1.2
### Patch Changes
- Updated dependencies [0267bb0]
- @llamaindex/core@0.6.20
## 4.1.1
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/cloud",
"version": "4.1.3",
"version": "4.1.1",
"type": "module",
"license": "MIT",
"scripts": {
-15
View File
@@ -1,20 +1,5 @@
# @llamaindex/community
## 0.0.103
### Patch Changes
- Updated dependencies [5da1cda]
- @llamaindex/core@0.6.21
## 0.0.102
### Patch Changes
- 6ebd7c2: fix: invoke complete command using the actual modelId
- Updated dependencies [0267bb0]
- @llamaindex/core@0.6.20
## 0.0.101
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/community",
"description": "Community package for LlamaIndexTS",
"version": "0.0.103",
"version": "0.0.101",
"type": "module",
"types": "dist/type/index.d.ts",
"main": "dist/cjs/index.js",
@@ -493,8 +493,6 @@ export class Bedrock extends ToolCallLLM<BedrockAdditionalChatOptions> {
if (params.stream) {
const command = new InvokeModelWithResponseStreamCommand(input);
command.input.modelId = this.actualModel;
const response = await this.client.send(command);
if (response.body)
return streamConverter(response.body, (response) => {
@@ -506,8 +504,6 @@ export class Bedrock extends ToolCallLLM<BedrockAdditionalChatOptions> {
}
const command = new InvokeModelCommand(input);
command.input.modelId = this.actualModel;
const response = await this.client.send(command);
return {
text: this.provider.getTextFromResponse(response),
-12
View File
@@ -1,17 +1,5 @@
# @llamaindex/core
## 0.6.21
### Patch Changes
- 5da1cda: feat: support zod v4 & v3
## 0.6.20
### Patch Changes
- 0267bb0: Added responseFormat to llm.exec
## 0.6.19
### Patch Changes
+4 -16
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/core",
"type": "module",
"version": "0.6.21",
"version": "0.6.19",
"description": "LlamaIndex Core Module",
"exports": {
"./agent": {
@@ -278,17 +278,6 @@
"default": "./postprocessor/dist/index.js"
},
"default": "./postprocessor/dist/index.js"
},
"./zod": {
"require": {
"types": "./zod/dist/index.d.cts",
"default": "./zod/dist/index.cjs"
},
"import": {
"types": "./zod/dist/index.d.ts",
"default": "./zod/dist/index.js"
},
"default": "./zod/dist/index.js"
}
},
"files": [
@@ -313,8 +302,7 @@
"./vector-store",
"./tools",
"./data-structs",
"./postprocessor",
"./zod"
"./postprocessor"
],
"scripts": {
"dev": "bunchee --watch",
@@ -333,9 +321,9 @@
},
"dependencies": {
"@llamaindex/env": "workspace:*",
"@finom/zod-to-json-schema": "3.24.11",
"@types/node": "^24.0.13",
"magic-bytes.js": "^1.10.0",
"zod": "^4.1.5"
"zod": "^3.25.76",
"zod-to-json-schema": "^3.24.6"
}
}
+3 -2
View File
@@ -1,4 +1,5 @@
import type { Logger } from "@llamaindex/env";
import { z } from "zod";
import { type JSONObject, type JSONValue, Settings } from "../global";
import type {
BaseTool,
@@ -12,7 +13,7 @@ import type {
ToolCallLLMMessageOptions,
ToolOutput,
} from "../llms";
import { agentParamsSchema } from "../schema";
import { baseToolWithCallSchema } from "../schema";
import {
assertIsJSONValue,
isAsyncIterable,
@@ -304,7 +305,7 @@ export function validateAgentParams<AI extends LLM>(
params: AgentParamsBase<AI>,
) {
if ("tools" in params) {
agentParamsSchema.parse(params.tools);
z.array(baseToolWithCallSchema).parse(params.tools);
} else {
// todo: check `params.toolRetriever` when migrate to @llamaindex/core
}
+3 -3
View File
@@ -3,7 +3,6 @@ import type { JSONObject } from "../global";
import { tool } from "../tools/";
import { extractText } from "../utils/llms";
import { streamConverter } from "../utils/stream";
import { isZodSchema, safeParseSchema } from "../zod";
import { callToolToMessage, getToolCallsFromResponse } from "./tool-call";
import type {
ChatMessage,
@@ -21,6 +20,7 @@ import type {
PartialToolCall,
ToolCallLLMMessageOptions,
} from "./type";
import { isZodSchema } from "./utils";
export abstract class BaseLLM<
AdditionalChatOptions extends object = object,
@@ -101,13 +101,13 @@ export abstract class BaseLLM<
| ExecStreamResponse<AdditionalMessageOptions>
> {
const responseFormat = params.responseFormat;
if (typeof responseFormat != "undefined" && isZodSchema(responseFormat)) {
if (responseFormat && isZodSchema(responseFormat)) {
const structuredTool = tool({
name: "format_output",
description: "Respond with a JSON object",
parameters: responseFormat,
execute: (args) => {
const result = safeParseSchema(responseFormat, args);
const result = responseFormat.safeParse(args);
if (!result.success) {
console.error("Invalid input from LLM:", result.error);
return JSON.stringify({
+3 -4
View File
@@ -1,10 +1,9 @@
import type { Logger } from "@llamaindex/env";
import type { Tokenizers } from "@llamaindex/env/tokenizers";
import type { JSONSchemaType } from "ajv";
import { z } from "zod";
import type { JSONObject, JSONValue } from "../global";
import type { ModalityType } from "../schema";
import type { ZodSchema } from "../zod";
/**
* @internal
*/
@@ -140,7 +139,7 @@ export interface LLMChatParamsBase<
messages: ChatMessage<AdditionalMessageOptions>[];
additionalChatOptions?: AdditionalChatOptions | undefined;
tools?: BaseTool[] | undefined;
responseFormat?: ZodSchema | object | undefined;
responseFormat?: z.ZodType | object | undefined;
logger?: Logger | undefined;
}
@@ -160,7 +159,7 @@ export interface LLMChatParamsNonStreaming<
export interface LLMCompletionParamsBase {
prompt: MessageContent;
responseFormat?: ZodSchema | object;
responseFormat?: z.ZodType | object;
}
export interface LLMCompletionParamsStreaming extends LLMCompletionParamsBase {
+13
View File
@@ -1,3 +1,4 @@
import * as z from "zod/v4";
import type {
ChatMessage,
MessageContentImageDataDetail,
@@ -26,3 +27,15 @@ export function addContentPart<AdditionalMessageOptions extends object>(
}
}
}
export function isZodSchema(obj: unknown): obj is z.ZodType {
return (
obj !== null &&
typeof obj === "object" &&
"parse" in obj &&
typeof (obj as { parse: unknown }).parse === "function" &&
"safeParse" in obj &&
typeof (obj as { safeParse: unknown }).safeParse === "function" &&
"_def" in obj
);
}
@@ -1,9 +1,10 @@
import { consoleLogger, type Logger } from "@llamaindex/env";
import type { Tokenizer } from "@llamaindex/env/tokenizers";
import { z } from "zod";
import { Settings } from "../global";
import { sentenceSplitterSchema, type SentenceSplitterParams } from "../schema";
import { sentenceSplitterSchema } from "../schema";
import { MetadataAwareTextSplitter } from "./base";
import type { PartialWithUndefined, SplitterParams } from "./type";
import type { SplitterParams } from "./type";
import {
splitByChar,
splitByRegex,
@@ -51,7 +52,7 @@ export class SentenceSplitter extends MetadataAwareTextSplitter {
#logger: Logger;
constructor(
params?: PartialWithUndefined<SentenceSplitterParams> &
params?: z.input<typeof sentenceSplitterSchema> &
SplitterParams & { logger?: Logger },
) {
super();
@@ -1,13 +1,12 @@
import { randomUUID } from "@llamaindex/env";
import { z } from "zod";
import {
buildNodeFromSplits,
Document,
sentenceWindowNodeParserSchema,
TextNode,
type SentenceWindowNodeParserParams,
} from "../schema";
import { NodeParser } from "./base";
import type { PartialWithUndefined } from "./type";
import { splitBySentenceTokenizer, type TextSplitterFn } from "./utils";
export class SentenceWindowNodeParser extends NodeParser<TextNode[]> {
@@ -21,7 +20,7 @@ export class SentenceWindowNodeParser extends NodeParser<TextNode[]> {
sentenceSplitter: TextSplitterFn = splitBySentenceTokenizer([], true);
idGenerator: () => string = () => randomUUID();
constructor(params?: PartialWithUndefined<SentenceWindowNodeParserParams>) {
constructor(params?: z.input<typeof sentenceWindowNodeParserSchema>) {
super();
if (params) {
const parsedParams = sentenceWindowNodeParserSchema.parse(params);
@@ -1,16 +1,20 @@
import { consoleLogger, type Logger } from "@llamaindex/env";
import type { Tokenizer } from "@llamaindex/env/tokenizers";
import { z } from "zod";
import { DEFAULT_CHUNK_OVERLAP, DEFAULT_CHUNK_SIZE, Settings } from "../global";
import {
tokenTextSplitterSchema,
type TokenTextSplitterParams,
} from "../schema";
import { MetadataAwareTextSplitter } from "./base";
import type { PartialWithUndefined, SplitterParams } from "./type";
import type { SplitterParams } from "./type";
import { splitByChar, splitBySep } from "./utils";
const DEFAULT_METADATA_FORMAT_LEN = 2;
const tokenTextSplitterSchema = z.object({
chunkSize: z.number().positive().default(DEFAULT_CHUNK_SIZE),
chunkOverlap: z.number().nonnegative().default(DEFAULT_CHUNK_OVERLAP),
separator: z.string().default(" "),
backupSeparators: z.array(z.string()).default(["\n"]),
});
export class TokenTextSplitter extends MetadataAwareTextSplitter {
chunkSize: number = DEFAULT_CHUNK_SIZE;
chunkOverlap: number = DEFAULT_CHUNK_OVERLAP;
@@ -22,7 +26,7 @@ export class TokenTextSplitter extends MetadataAwareTextSplitter {
constructor(
params?: SplitterParams &
PartialWithUndefined<TokenTextSplitterParams> & { logger?: Logger },
Partial<z.infer<typeof tokenTextSplitterSchema>> & { logger?: Logger },
) {
super();
-4
View File
@@ -3,7 +3,3 @@ import type { Tokenizer } from "@llamaindex/env/tokenizers";
export type SplitterParams = {
tokenizer?: Tokenizer;
};
export type PartialWithUndefined<T> = {
[P in keyof T]?: T[P] | undefined;
};
+2 -17
View File
@@ -1,5 +1,5 @@
import { z } from "zod/v3"; // use zod v3 to keep schemas as it is
import { DEFAULT_CHUNK_OVERLAP, DEFAULT_CHUNK_SIZE, Settings } from "../global";
import { z } from "zod";
import { Settings } from "../global";
export const anyFunctionSchema = z.function(z.tuple([]).rest(z.any()), z.any());
@@ -18,8 +18,6 @@ export const baseToolWithCallSchema = baseToolSchema.extend({
call: z.function(),
});
export const agentParamsSchema = z.array(baseToolWithCallSchema);
export const sentenceSplitterSchema = z
.object({
chunkSize: z
@@ -85,16 +83,3 @@ export const sentenceWindowNodeParserSchema = z.object({
})
.default("originalText"),
});
export const tokenTextSplitterSchema = z.object({
chunkSize: z.number().positive().default(DEFAULT_CHUNK_SIZE),
chunkOverlap: z.number().nonnegative().default(DEFAULT_CHUNK_OVERLAP),
separator: z.string().default(" "),
backupSeparators: z.array(z.string()).default(["\n"]),
});
export type SentenceSplitterParams = z.infer<typeof sentenceSplitterSchema>;
export type TokenTextSplitterParams = z.infer<typeof tokenTextSplitterSchema>;
export type SentenceWindowNodeParserParams = z.infer<
typeof sentenceWindowNodeParserSchema
>;
+37 -66
View File
@@ -1,15 +1,8 @@
import { consoleLogger, type Logger } from "@llamaindex/env";
import type { JSONSchemaType } from "ajv";
import type * as z3 from "zod/v3";
import type * as z4 from "zod/v4/core";
import * as z from "zod/v4";
import type { JSONValue } from "../global";
import type { BaseTool, ToolMetadata } from "../llms";
import {
isZodSchema,
safeParseSchema,
type ZodSchema,
zodToJsonSchema,
} from "../zod";
export class FunctionTool<
T,
@@ -20,13 +13,12 @@ export class FunctionTool<
#fn: (input: T, additionalArg?: AdditionalToolArgument) => R;
#additionalArg: AdditionalToolArgument | undefined;
readonly #metadata: ToolMetadata<JSONSchemaType<T>>;
readonly #zodType: ZodSchema<T> | null = null;
readonly #zodType: z.ZodType<T> | null = null;
readonly #logger: Logger;
constructor(
fn: (input: T, additionalArg?: AdditionalToolArgument) => R,
metadata: ToolMetadata<JSONSchemaType<T>>,
zodType?: ZodSchema<T>,
zodType?: z.ZodType<T>,
additionalArg?: AdditionalToolArgument,
logger?: Logger,
) {
@@ -39,9 +31,6 @@ export class FunctionTool<
this.#logger = logger ?? consoleLogger;
}
// ----------------- OVERLOAD -----------------
// Plain JSON schema
static from<T, AdditionalToolArgument extends object = object>(
fn: (
input: T,
@@ -49,74 +38,54 @@ export class FunctionTool<
) => JSONValue | Promise<JSONValue>,
schema: ToolMetadata<JSONSchemaType<T>>,
): FunctionTool<T, JSONValue | Promise<JSONValue>, AdditionalToolArgument>;
// Function + Object configs + Zod v3 schema
static from<R, AdditionalToolArgument extends object = object>(
static from<
R extends z.ZodType,
AdditionalToolArgument extends object = object,
>(
fn: (
// @ts-expect-error <R> should extend z3.ZodTypeAny
// but we remove that to fix type instantiation is excessively deep and possibly infinite
input: z3.infer<R>,
input: z.infer<R>,
additionalArg?: AdditionalToolArgument,
) => JSONValue | Promise<JSONValue>,
schema: Omit<ToolMetadata, "parameters"> & { parameters: R },
schema: Omit<ToolMetadata, "parameters"> & {
parameters: R;
},
): FunctionTool<
// @ts-expect-error <R> should extend z3.ZodTypeAny
// but we remove that to fix type instantiation is excessively deep and possibly infinite
z3.infer<R>,
z.infer<R>,
JSONValue | Promise<JSONValue>,
AdditionalToolArgument
>;
// Function + Object configs + Zod v4 schema
static from<R, AdditionalToolArgument extends object = object>(
static from<
T,
R extends z.ZodType<T>,
AdditionalToolArgument extends object = object,
>(
fn: (
input: z4.infer<R>,
input: T,
additionalArg?: AdditionalToolArgument,
) => JSONValue | Promise<JSONValue>,
schema: Omit<ToolMetadata, "parameters"> & { parameters: R },
): FunctionTool<
z4.infer<R>,
JSONValue | Promise<JSONValue>,
AdditionalToolArgument
>;
// Object configs + Zod v3 schema
static from<R, AdditionalToolArgument extends object = object>(
schema: Omit<ToolMetadata, "parameters"> & {
parameters: R;
},
): FunctionTool<T, JSONValue, AdditionalToolArgument>;
static from<
R extends z.ZodType,
AdditionalToolArgument extends object = object,
>(
config: Omit<ToolMetadata, "parameters"> & {
parameters: R;
execute: (
// @ts-expect-error <R> should extend z3.ZodTypeAny
// but we remove that to fix type instantiation is excessively deep and possibly infinite
input: z3.infer<R>,
input: z.infer<R>,
additionalArg?: AdditionalToolArgument,
) => JSONValue | Promise<JSONValue>;
},
): FunctionTool<
// @ts-expect-error <R> should extend z3.ZodTypeAny
// but we remove that to fix type instantiation is excessively deep and possibly infinite
z3.infer<R>,
z.infer<R>,
JSONValue | Promise<JSONValue>,
AdditionalToolArgument
>;
// Object configs + Zod v4 schema
static from<R, AdditionalToolArgument extends object = object>(
config: Omit<ToolMetadata, "parameters"> & {
parameters: R;
execute: (
input: z4.infer<R>,
additionalArg?: AdditionalToolArgument,
) => JSONValue | Promise<JSONValue>;
},
): FunctionTool<
z4.infer<R>,
JSONValue | Promise<JSONValue>,
AdditionalToolArgument
>;
// ----------------- IMPLEMENTATION -----------------
// eslint-disable-next-line @typescript-eslint/no-explicit-any
static from(fnOrConfig: any, schema?: any): any {
// Handle the case where an object with execute function is passed
if (
typeof schema === "undefined" &&
typeof fnOrConfig === "object" &&
@@ -124,8 +93,8 @@ export class FunctionTool<
) {
const { execute, parameters, ...restConfig } = fnOrConfig;
if (isZodSchema(parameters)) {
const jsonSchema = zodToJsonSchema(parameters);
if (parameters instanceof z.ZodType) {
const jsonSchema = z.toJSONSchema(parameters);
return new FunctionTool(
execute,
{
@@ -135,11 +104,13 @@ export class FunctionTool<
parameters,
);
}
return new FunctionTool(execute, fnOrConfig);
}
if (schema && isZodSchema(schema.parameters)) {
const jsonSchema = zodToJsonSchema(schema.parameters);
// Handle the original cases
if (schema && schema.parameters instanceof z.ZodType) {
const jsonSchema = z.toJSONSchema(schema.parameters);
return new FunctionTool(
fnOrConfig,
{
@@ -168,11 +139,11 @@ export class FunctionTool<
call = (input: T) => {
let params = input;
if (this.#zodType) {
const result = safeParseSchema(this.#zodType, input);
const result = this.#zodType.safeParse(input);
if (result.success) {
params = result.data;
} else {
this.#logger.warn(result.error);
this.#logger.warn(result.error.errors);
}
}
return this.#fn.call(null, params, this.#additionalArg);
-71
View File
@@ -1,71 +0,0 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { zodToJsonSchema as zodToJsonSchemaV3 } from "@finom/zod-to-json-schema";
import * as z from "zod";
import * as z3 from "zod/v3";
import * as z4 from "zod/v4/core";
export type ZodSchema<T = any> = z3.ZodType<T> | z4.$ZodType<T>;
export type ZodInfer<T extends ZodSchema> =
T extends z3.ZodType<any>
? z3.infer<T>
: T extends z4.$ZodType<any>
? z4.infer<T>
: never;
// support parsing both Zod 3 schemas and Zod 4 schemas
export function parseSchema<T>(schema: ZodSchema<T>, data: unknown): T {
if ("_zod" in schema) {
// Zod 4 schema
return z4.parse(schema as z4.$ZodType<T>, data);
} else {
// Zod 3 schema
return (schema as z3.ZodType<T>).parse(data);
}
}
// safe parse schema
export function safeParseSchema<T>(schema: ZodSchema<T>, data: unknown) {
if ("_zod" in schema) {
// Zod 4 schema
return z4.safeParse(schema as z4.$ZodType<T>, data);
} else {
// Zod 3 schema
return (schema as z3.ZodType<T>).safeParse(data);
}
}
export function isZodSchema(obj: unknown): obj is ZodSchema {
return (
obj !== null &&
typeof obj === "object" &&
"parse" in obj &&
typeof (obj as { parse: unknown }).parse === "function" &&
"safeParse" in obj &&
typeof (obj as { safeParse: unknown }).safeParse === "function"
);
}
// zod 3 schema does not have _zod property
export function isZodV3Schema(obj: unknown): obj is z3.ZodTypeAny {
return isZodSchema(obj) && !("_zod" in obj);
}
// zod 4 schema has _zod property
export function isZodV4Schema(obj: unknown): obj is z4.$ZodType {
return isZodSchema(obj) && "_zod" in obj;
}
export function zodToJsonSchema(obj: ZodSchema) {
if (isZodV4Schema(obj)) {
// if schema is created from zod v4, use native toJSONSchema
return z4.toJSONSchema(obj);
}
// otherwise, use zod-to-json-schema
return zodToJsonSchemaV3(obj as any); // FIXME: use any to avoid type instantiation excessively
}
// re-export zod
export { z, z3, z4 };
+1 -1
View File
@@ -1,7 +1,7 @@
import { LLMAgent, validateAgentParams } from "@llamaindex/core/agent";
import { MockLLM } from "@llamaindex/core/llms/mock";
import { expect, test } from "vitest";
import { ZodError } from "zod/v3";
import { ZodError } from "zod";
test("validate agent params", () => {
validateAgentParams({
+1 -2
View File
@@ -7,7 +7,6 @@
},
"devDependencies": {
"@llamaindex/core": "workspace:*",
"vitest": "^2.1.5",
"zod": "^4.1.5"
"vitest": "^2.1.5"
}
}
+2 -68
View File
@@ -1,7 +1,6 @@
import { FunctionTool, tool } from "@llamaindex/core/tools";
import { describe, expect, test, vi } from "vitest";
import { z } from "zod/v3";
import { z as z4 } from "zod/v4";
import * as z from "zod/v4";
describe("FunctionTool", () => {
test("type system", () => {
@@ -38,9 +37,7 @@ describe("FunctionTool", () => {
name: "saveFile",
description: "Save the content into a file",
parameters: z.object({
content: z.string({
description: "The content to save into a file",
}),
content: z.string({}).describe("The content to save into a file"),
}),
execute: mockExecute,
};
@@ -96,67 +93,4 @@ describe("FunctionTool", () => {
expect(hello).to.toHaveBeenCalledOnce();
expect(hello).to.toHaveBeenCalledWith("Bob", additionalArg);
});
test("works with Zod v4 schema", async () => {
const mockFn = vi.fn().mockImplementation(({ age }: { age: number }) => {
return `Age is ${age}`;
});
const schema = z4.object({
age: z4.number().int().min(0),
});
const toolV4 = FunctionTool.from(mockFn, {
name: "checkAge",
description: "Checks age",
parameters: schema,
});
const result = await toolV4.call({ age: 25 });
expect(result).toBe("Age is 25");
expect(mockFn).toHaveBeenCalledWith({ age: 25 }, undefined);
});
test("validates input with safeParseSchema (valid + invalid)", async () => {
const mockFn = vi.fn().mockImplementation(({ num }: { num: number }) => {
return num * 2;
});
const schema = z.object({
num: z.number(),
});
const toolWithValidation = FunctionTool.from(mockFn, {
name: "double",
description: "Doubles a number",
parameters: schema,
});
// valid input
const result = await toolWithValidation.call({ num: 10 });
expect(result).toBe(20);
// invalid input (string instead of number)
// eslint-disable-next-line @typescript-eslint/no-explicit-any
await toolWithValidation.call({ num: "oops" } as any);
});
test("works with plain JSON schema", async () => {
const mockFn = vi.fn().mockImplementation(({ msg }: { msg: string }) => {
return msg.toUpperCase();
});
const toolWithJson = FunctionTool.from(mockFn, {
name: "shout",
description: "Shouts the message",
parameters: {
type: "object",
properties: { msg: { type: "string" } },
required: ["msg"],
},
});
const result = await toolWithJson.call({ msg: "hi" });
expect(result).toBe("HI");
});
});
-160
View File
@@ -1,160 +0,0 @@
import {
isZodSchema,
isZodV3Schema,
isZodV4Schema,
parseSchema,
safeParseSchema,
zodToJsonSchema,
} from "@llamaindex/core/zod";
import { describe, expect, it } from "vitest";
import { z as z3 } from "zod/v3";
import { z as z4 } from "zod/v4";
describe("Zod schema utils", () => {
describe("parseSchema / safeParseSchema", () => {
it("parses valid data with Zod v3 schema", () => {
const schema = z3.object({ name: z3.string() });
const result = parseSchema(schema, { name: "Alice" });
expect(result).toEqual({ name: "Alice" });
});
it("parses valid data with Zod v4 schema", () => {
const schema = z4.object({ age: z4.number() });
const result = parseSchema(schema, { age: 42 });
expect(result).toEqual({ age: 42 });
});
it("safeParse works with invalid data (v3)", () => {
const schema = z3.object({ name: z3.string() });
const res = safeParseSchema(schema, { name: 123 });
expect(res.success).toBe(false);
});
it("safeParse works with invalid data (v4)", () => {
const schema = z4.object({ age: z4.number() });
const res = safeParseSchema(schema, { age: "oops" });
expect(res.success).toBe(false);
});
});
describe("isZodV3Schema / isZodV4Schema / isZodSchema", () => {
it("detects a v3 schema", () => {
const schema = z3.string();
expect(isZodV3Schema(schema)).toBe(true);
expect(isZodSchema(schema)).toBe(true);
expect(isZodV4Schema(schema)).toBe(false);
});
it("detects a v4 schema", () => {
const schema = z4.string();
expect(isZodV4Schema(schema)).toBe(true);
expect(isZodSchema(schema)).toBe(true);
expect(isZodV3Schema(schema)).toBe(false);
});
it("returns false for non-schemas", () => {
expect(isZodSchema(123)).toBe(false);
expect(isZodSchema({})).toBe(false);
});
});
describe("zodToJsonSchema", () => {
it("converts v3 string schema", () => {
const schema = z3.string().min(2).max(5).describe("A short string");
const json = zodToJsonSchema(schema);
expect(json).toMatchObject({
type: "string",
minLength: 2,
maxLength: 5,
description: "A short string",
});
});
it("converts v3 object schema", () => {
const schema = z3.object({
id: z3.number(),
name: z3.string().optional(),
});
const json = zodToJsonSchema(schema);
expect(json).toMatchObject({
type: "object",
properties: {
id: { type: "number" },
name: { type: "string" },
},
required: ["id"],
});
});
it("converts v4 array schema", () => {
const schema = z4.array(z4.boolean());
const json = zodToJsonSchema(schema);
expect(json).toMatchObject({
type: "array",
items: { type: "boolean" },
});
});
it("converts v4 enum schema", () => {
const schema = z4.enum(["red", "green", "blue"]);
const json = zodToJsonSchema(schema);
expect(json).toMatchObject({
type: "string",
enum: ["red", "green", "blue"],
});
});
it("handles nested v3 objects", () => {
const schema = z3.object({
user: z3.object({
id: z3.number(),
tags: z3.array(z3.string()),
}),
});
const json = zodToJsonSchema(schema);
expect(json).toMatchObject({
type: "object",
properties: {
user: {
type: "object",
properties: {
id: { type: "number" },
tags: {
type: "array",
items: { type: "string" },
},
},
required: ["id", "tags"],
},
},
required: ["user"],
});
});
it("handles nested v4 objects", () => {
const schema = z4.object({
profile: z4.object({
email: z4.string(),
active: z4.boolean(),
}),
});
const json = zodToJsonSchema(schema);
expect(json).toMatchObject({
type: "object",
properties: {
profile: {
type: "object",
properties: {
email: { type: "string" },
active: { type: "boolean" },
},
required: ["email", "active"],
additionalProperties: false,
},
},
required: ["profile"],
additionalProperties: false,
});
});
});
});
-8
View File
@@ -1,8 +0,0 @@
{
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": "./dist/index.js",
"private": true
}
-19
View File
@@ -1,24 +1,5 @@
# @llamaindex/experimental
## 0.0.206
### Patch Changes
- Updated dependencies [8929dcf]
- llamaindex@0.11.29
## 0.0.205
### Patch Changes
- llamaindex@0.11.28
## 0.0.204
### Patch Changes
- llamaindex@0.11.27
## 0.0.203
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/experimental",
"description": "Experimental package for LlamaIndexTS",
"version": "0.0.206",
"version": "0.0.203",
"type": "module",
"types": "dist/type/index.d.ts",
"main": "dist/cjs/index.js",
-28
View File
@@ -1,33 +1,5 @@
# llamaindex
## 0.11.29
### Patch Changes
- 8929dcf: feat: vectorStoreIndex has new option progressCallback
- Updated dependencies [5da1cda]
- @llamaindex/core@0.6.21
- @llamaindex/workflow@1.1.23
- @llamaindex/cloud@4.1.3
- @llamaindex/node-parser@2.0.21
## 0.11.28
### Patch Changes
- Updated dependencies [1995b38]
- @llamaindex/workflow@1.1.22
## 0.11.27
### Patch Changes
- Updated dependencies [0267bb0]
- @llamaindex/core@0.6.20
- @llamaindex/cloud@4.1.2
- @llamaindex/node-parser@2.0.20
- @llamaindex/workflow@1.1.21
## 0.11.26
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "llamaindex",
"version": "0.11.29",
"version": "0.11.26",
"license": "MIT",
"type": "module",
"keywords": [
@@ -54,7 +54,6 @@ export interface VectorIndexOptions extends IndexStructOptions {
storageContext?: StorageContext | undefined;
vectorStores?: VectorStoreByType | undefined;
logProgress?: boolean | undefined;
progressCallback?: ((progress: number, total: number) => void) | undefined;
}
export interface VectorIndexConstructorProps extends BaseIndexInit<IndexDict> {
@@ -122,7 +121,6 @@ export class VectorStoreIndex extends BaseIndex<IndexDict> {
// If nodes are passed in, then we need to update the index
await index.buildIndexFromNodes(options.nodes, {
logProgress: options.logProgress,
progressCallback: options.progressCallback,
});
}
return index;
@@ -172,12 +170,7 @@ export class VectorStoreIndex extends BaseIndex<IndexDict> {
*/
async getNodeEmbeddingResults(
nodes: BaseNode[],
options?: {
logProgress?: boolean | undefined;
progressCallback?:
| ((progress: number, total: number) => void)
| undefined;
},
options?: { logProgress?: boolean | undefined },
): Promise<BaseNode[]> {
const nodeMap = splitNodesByType(nodes);
for (const type in nodeMap) {
@@ -187,7 +180,6 @@ export class VectorStoreIndex extends BaseIndex<IndexDict> {
if (embedModel && nodes) {
await embedModel(nodes, {
logProgress: options?.logProgress,
progressCallback: options?.progressCallback,
});
}
}
@@ -201,12 +193,7 @@ export class VectorStoreIndex extends BaseIndex<IndexDict> {
*/
async buildIndexFromNodes(
nodes: BaseNode[],
options?: {
logProgress?: boolean | undefined;
progressCallback?:
| ((progress: number, total: number) => void)
| undefined;
},
options?: { logProgress?: boolean | undefined },
) {
await this.insertNodes(nodes, options);
}
@@ -374,12 +361,7 @@ export class VectorStoreIndex extends BaseIndex<IndexDict> {
async insertNodes(
nodes: BaseNode[],
options?: {
logProgress?: boolean | undefined;
progressCallback?:
| ((progress: number, total: number) => void)
| undefined;
},
options?: { logProgress?: boolean | undefined },
): Promise<void> {
if (!nodes || nodes.length === 0) {
return;
-22
View File
@@ -1,27 +1,5 @@
# @llamaindex/core-test
## 0.1.20
### Patch Changes
- 8929dcf: feat: vectorStoreIndex has new option progressCallback
- Updated dependencies [5da1cda]
- @llamaindex/openai@0.4.19
## 0.1.19
### Patch Changes
- Updated dependencies [001a515]
- Updated dependencies [9d7d205]
- @llamaindex/openai@0.4.18
## 0.1.18
### Patch Changes
- @llamaindex/openai@0.4.17
## 0.1.17
### Patch Changes
@@ -89,42 +89,4 @@ describe("[VectorStoreIndex] use embedding model", () => {
expect(customSpy).toHaveBeenCalled();
expect(settingsSpy).not.toHaveBeenCalled();
});
describe("[VectorStoreIndex] call progressCallback", () => {
it("should call progressCallback with correct values", async () => {
const documents = Array.from(
{ length: 20 },
(_, i) => new Document({ text: `This is document ${i + 1}` }),
);
const progressCalls: Array<{ current: number; total: number }> = [];
const progressCallback = (current: number, total: number) => {
progressCalls.push({ current, total });
};
const embedModel = new OpenAIEmbedding();
mockEmbeddingModel(embedModel);
const embedSpy = vi.spyOn(embedModel, "getTextEmbeddingsBatch");
Settings.embedModel = embedModel;
const storageContext = await mockStorageContext(testDir, embedModel);
await VectorStoreIndex.fromDocuments(documents, {
storageContext,
logProgress: true,
progressCallback,
});
// Expect the embedding model to be called
expect(embedSpy).toHaveBeenCalled();
// Verify that progressCallback was called with correct values
expect(progressCalls.length).toBeGreaterThan(0);
expect(progressCalls[0]).toEqual({ current: 10, total: 20 });
expect(progressCalls[progressCalls.length - 1]).toEqual({
current: 20,
total: 20,
});
});
});
});
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/llamaindex-test",
"private": true,
"version": "0.1.20",
"version": "0.1.17",
"type": "module",
"scripts": {
"test": "vitest run"
-14
View File
@@ -1,19 +1,5 @@
# @llamaindex/node-parser
## 2.0.21
### Patch Changes
- Updated dependencies [5da1cda]
- @llamaindex/core@0.6.21
## 2.0.20
### Patch Changes
- Updated dependencies [0267bb0]
- @llamaindex/core@0.6.20
## 2.0.19
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/node-parser",
"version": "2.0.21",
"version": "2.0.19",
"description": "Node parser for LlamaIndex",
"type": "module",
"exports": {
-15
View File
@@ -1,20 +1,5 @@
# @llamaindex/anthropic
## 0.3.24
### Patch Changes
- 5d5cd44: fix: anthropic temperature parameter not respecting value 0
- Updated dependencies [5da1cda]
- @llamaindex/core@0.6.21
## 0.3.23
### Patch Changes
- Updated dependencies [0267bb0]
- @llamaindex/core@0.6.20
## 0.3.22
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/anthropic",
"description": "Anthropic Adapter for LlamaIndex",
"version": "0.3.24",
"version": "0.3.22",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
+1 -1
View File
@@ -179,7 +179,7 @@ export class Anthropic extends ToolCallLLM<
constructor(init?: Partial<Anthropic>) {
super();
this.model = init?.model ?? "claude-3-opus";
this.temperature = init?.temperature != null ? init.temperature : 1; // default in anthropic is 1
this.temperature = init?.temperature ?? 1; // default in anthropic is 1
this.topP = init?.topP;
this.maxTokens = init?.maxTokens ?? undefined;
@@ -1,19 +1,5 @@
# @llamaindex/assemblyai
## 0.1.20
### Patch Changes
- Updated dependencies [5da1cda]
- @llamaindex/core@0.6.21
## 0.1.19
### Patch Changes
- Updated dependencies [0267bb0]
- @llamaindex/core@0.6.20
## 0.1.18
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/assemblyai",
"description": "AssemblyAI Reader for LlamaIndex",
"version": "0.1.20",
"version": "0.1.18",
"type": "module",
"types": "dist/index.d.ts",
"main": "dist/index.cjs",
-15
View File
@@ -1,20 +1,5 @@
# @llamaindex/community
## 0.0.117
### Patch Changes
- ed37c64: Addition of APAC_ANTHROPIC_CLAUDE_4_SONNET type/record in @llamaindex/aws for APAC support for claude 4 sonnet per issue 2184.
- Updated dependencies [5da1cda]
- @llamaindex/core@0.6.21
## 0.0.116
### Patch Changes
- Updated dependencies [0267bb0]
- @llamaindex/core@0.6.20
## 0.0.115
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/aws",
"description": "AWS package for LlamaIndexTS",
"version": "0.0.117",
"version": "0.0.115",
"type": "module",
"types": "dist/type/index.d.ts",
"main": "dist/cjs/index.js",
@@ -134,14 +134,13 @@ export const INFERENCE_BEDROCK_MODELS = {
EU_AMAZON_NOVA_PRO_1: "eu.amazon.nova-pro-v1:0",
EU_AMAZON_NOVA_LITE_1: "eu.amazon.nova-lite-v1:0",
EU_AMAZON_NOVA_MICRO_1: "eu.amazon.nova-micro-v1:0",
APAC_ANTHROPIC_CLAUDE_3_5_SONNET:
"apac.anthropic.claude-3-5-sonnet-20240620-v1:0",
APAC_ANTHROPIC_CLAUDE_3_5_SONNET_V2:
"apac.anthropic.claude-3-5-sonnet-20241022-v2:0",
APAC_ANTHROPIC_CLAUDE_3_7_SONNET:
"apac.anthropic.claude-3-7-sonnet-20250219-v1:0",
APAC_ANTHROPIC_CLAUDE_4_SONNET:
"apac.anthropic.claude-sonnet-4-20250514-v1:0q",
APAC_ANTHROPIC_CLAUDE_3_HAIKU: "apac.anthropic.claude-3-haiku-20240307-v1:0",
APAC_ANTHROPIC_CLAUDE_3_SONNET:
"apac.anthropic.claude-3-sonnet-20240229-v1:0",
@@ -227,8 +226,6 @@ export const INFERENCE_TO_BEDROCK_MAP: Record<
BEDROCK_MODELS.ANTHROPIC_CLAUDE_3_5_SONNET_V2,
[INFERENCE_BEDROCK_MODELS.APAC_ANTHROPIC_CLAUDE_3_7_SONNET]:
BEDROCK_MODELS.ANTHROPIC_CLAUDE_3_7_SONNET,
[INFERENCE_BEDROCK_MODELS.APAC_ANTHROPIC_CLAUDE_4_SONNET]:
BEDROCK_MODELS.ANTHROPIC_CLAUDE_4_SONNET,
[INFERENCE_BEDROCK_MODELS.APAC_ANTHROPIC_CLAUDE_3_HAIKU]:
BEDROCK_MODELS.ANTHROPIC_CLAUDE_3_HAIKU,
[INFERENCE_BEDROCK_MODELS.APAC_ANTHROPIC_CLAUDE_3_SONNET]:
@@ -549,8 +546,6 @@ export class Bedrock extends ToolCallLLM<BedrockAdditionalChatOptions> {
if (params.stream) {
const command = new InvokeModelWithResponseStreamCommand(input);
command.input.modelId = this.actualModel;
const response = await this.client.send(command);
if (response.body)
return streamConverter(response.body, (response) => {
@@ -562,8 +557,6 @@ export class Bedrock extends ToolCallLLM<BedrockAdditionalChatOptions> {
}
const command = new InvokeModelCommand(input);
command.input.modelId = this.actualModel;
const response = await this.client.send(command);
return {
text: this.provider.getTextFromResponse(response),
-24
View File
@@ -1,29 +1,5 @@
# @llamaindex/clip
## 0.0.75
### Patch Changes
- Updated dependencies [5da1cda]
- @llamaindex/core@0.6.21
- @llamaindex/openai@0.4.19
## 0.0.74
### Patch Changes
- Updated dependencies [001a515]
- Updated dependencies [9d7d205]
- @llamaindex/openai@0.4.18
## 0.0.73
### Patch Changes
- Updated dependencies [0267bb0]
- @llamaindex/core@0.6.20
- @llamaindex/openai@0.4.17
## 0.0.72
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/clip",
"description": "Clip Embedding Adapter for LlamaIndex",
"version": "0.0.75",
"version": "0.0.72",
"type": "module",
"types": "dist/index.d.ts",
"main": "dist/index.cjs",

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