mirror of
https://github.com/run-llama/LlamaIndexTS.git
synced 2026-07-15 06:52:45 -04:00
Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| df71df48c0 | |||
| d4b6fe6156 | |||
| e3405fca44 | |||
| f3bc2b61e7 | |||
| 4c703767b7 | |||
| a27648200d | |||
| c93bb02002 | |||
| 6a426305da | |||
| 56924edded | |||
| b0985d1b8c | |||
| 72d681be47 | |||
| da751b28fe | |||
| 3109f6640f | |||
| 1214b5f3ef | |||
| 53a8cb9b4a | |||
| d647786e67 |
@@ -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
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/doc
|
||||
|
||||
## 0.2.51
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [4c70376]
|
||||
- @llamaindex/openai@0.4.16
|
||||
|
||||
## 0.2.50
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@llamaindex/doc",
|
||||
"version": "0.2.50",
|
||||
"version": "0.2.51",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"postinstall": "fumadocs-mdx",
|
||||
|
||||
@@ -93,4 +93,4 @@ async function main() {
|
||||
main().catch(console.error);
|
||||
```
|
||||
|
||||
You can see the [full example file](https://github.com/run-llama/LlamaIndexTS/blob/main/examples/vectorIndexLocal.ts).
|
||||
You can see the [full example file](https://github.com/run-llama/LlamaIndexTS/blob/main/examples/index/vectorIndexLocal.ts).
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @llamaindex/next-node-runtime
|
||||
|
||||
## 0.1.58
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @llamaindex/huggingface@0.1.26
|
||||
|
||||
## 0.1.57
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@llamaindex/next-node-runtime-test",
|
||||
"version": "0.1.57",
|
||||
"version": "0.1.58",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
||||
@@ -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,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,9 +36,7 @@ export const getWeatherTool = FunctionTool.from(
|
||||
name: "getWeather",
|
||||
description: "Get the weather for a city",
|
||||
parameters: z.object({
|
||||
city: z.string({
|
||||
description: "The city to get the weather for",
|
||||
}),
|
||||
city: z.string({}).describe("The city to get the weather for"),
|
||||
}),
|
||||
},
|
||||
);
|
||||
|
||||
@@ -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" });
|
||||
|
||||
|
||||
@@ -1,5 +1,24 @@
|
||||
# examples
|
||||
|
||||
## 0.3.38
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [4c70376]
|
||||
- @llamaindex/openai@0.4.16
|
||||
- @llamaindex/clip@0.0.72
|
||||
- @llamaindex/deepinfra@0.0.72
|
||||
- @llamaindex/deepseek@0.0.34
|
||||
- @llamaindex/fireworks@0.0.32
|
||||
- @llamaindex/groq@0.0.88
|
||||
- @llamaindex/huggingface@0.1.26
|
||||
- @llamaindex/jinaai@0.0.32
|
||||
- @llamaindex/perplexity@0.0.29
|
||||
- @llamaindex/azure@0.1.33
|
||||
- @llamaindex/together@0.0.32
|
||||
- @llamaindex/vllm@0.0.58
|
||||
- @llamaindex/xai@0.0.19
|
||||
|
||||
## 0.3.37
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -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({
|
||||
@@ -20,9 +20,7 @@ const saveFileTool = tool({
|
||||
description:
|
||||
"Save the written content into a file that can be downloaded by the user",
|
||||
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: ({ content }: { content: string }) => {
|
||||
const filePath = os.tmpdir() + "/report.md";
|
||||
|
||||
@@ -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";
|
||||
@@ -17,9 +17,7 @@ const userQuestion = "which are the best comedies after 2010?";
|
||||
description:
|
||||
"Execute python code in a Jupyter notebook cell and return any result, stdout, stderr, display_data, and error.",
|
||||
parameters: z.object({
|
||||
code: z.string({
|
||||
description: "The python code to execute in a single cell.",
|
||||
}),
|
||||
code: z.string().describe("The python code to execute in a single cell."),
|
||||
}),
|
||||
execute: ({ code }) => {
|
||||
console.log(
|
||||
|
||||
@@ -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",
|
||||
@@ -26,9 +26,7 @@ const temperatureConverterTool = tool({
|
||||
description: "Convert a temperature from Fahrenheit to Celsius",
|
||||
name: "fahrenheitToCelsius",
|
||||
parameters: z.object({
|
||||
temperature: z.number({
|
||||
description: "The temperature in Fahrenheit",
|
||||
}),
|
||||
temperature: z.number().describe("The temperature in Fahrenheit"),
|
||||
}),
|
||||
execute: ({ temperature }) => {
|
||||
return ((temperature - 32) * 5) / 9;
|
||||
@@ -39,9 +37,7 @@ const temperatureFetcherTool = tool({
|
||||
description: "Fetch the temperature (in Fahrenheit) for a city",
|
||||
name: "fetchTemperature",
|
||||
parameters: z.object({
|
||||
city: z.string({
|
||||
description: "The city to fetch the temperature for",
|
||||
}),
|
||||
city: z.string().describe("The city to fetch the temperature for"),
|
||||
}),
|
||||
execute: ({ city }) => {
|
||||
const temperature = Math.floor(Math.random() * 58) + 32;
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -14,9 +14,7 @@ const weatherTool = tool({
|
||||
name: "weather",
|
||||
description: "Get the weather",
|
||||
parameters: z.object({
|
||||
location: z.string({
|
||||
description: "The location to get the weather for",
|
||||
}),
|
||||
location: z.string().describe("The location to get the weather for"),
|
||||
}),
|
||||
execute: ({ location }) => {
|
||||
return `The weather in ${location} is sunny`;
|
||||
@@ -27,9 +25,7 @@ const inflationTool = tool({
|
||||
name: "inflation",
|
||||
description: "Get the inflation",
|
||||
parameters: z.object({
|
||||
location: z.string({
|
||||
description: "The location to get the inflation for",
|
||||
}),
|
||||
location: z.string().describe("The location to get the inflation for"),
|
||||
}),
|
||||
execute: ({ location }) => {
|
||||
return `The inflation in ${location} is 2%`;
|
||||
@@ -41,9 +37,7 @@ const saveFileTool = tool({
|
||||
description:
|
||||
"Save the written content into a file that can be downloaded by the user",
|
||||
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: ({ content }) => {
|
||||
const filePath = "./report.md";
|
||||
|
||||
@@ -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,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" });
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import { Anthropic } from "@llamaindex/anthropic";
|
||||
import { ChatMessage, ToolCall } from "llamaindex";
|
||||
import * as z from "zod/v4";
|
||||
|
||||
const llm = new Anthropic({ model: "claude-4-0-sonnet" });
|
||||
|
||||
const responseSchema = z.object({
|
||||
title: z.string(),
|
||||
author: z.string(),
|
||||
year: z.number(),
|
||||
});
|
||||
|
||||
async function main() {
|
||||
const messages: ChatMessage[] = [];
|
||||
let toolCalls: ToolCall[] = [];
|
||||
do {
|
||||
const result = await llm.exec({
|
||||
messages: [
|
||||
{
|
||||
role: "system",
|
||||
content: `You are a book expert. Your task is, given a user message, extract the title, author and publication year of the book and output them in JSON format.`,
|
||||
},
|
||||
{
|
||||
role: "user",
|
||||
content: `I have been reading La Divina Commedia by Dante Alighieri, published in 1321, which tells the story of a guy who goes through Hell, Purgatory and Heaven just to meet his beloved ex-girlfriend.`,
|
||||
},
|
||||
],
|
||||
responseFormat: responseSchema,
|
||||
});
|
||||
messages.push(...result.newMessages);
|
||||
toolCalls = result.toolCalls;
|
||||
} while (toolCalls.length == 0);
|
||||
|
||||
console.log(messages[1].content);
|
||||
console.log(toolCalls);
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
@@ -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",
|
||||
|
||||
@@ -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`
|
||||
@@ -29,9 +29,9 @@ async function callLLM(init: { model: string }) {
|
||||
description:
|
||||
"Execute python code in a Jupyter notebook cell and return any result, stdout, stderr, display_data, and error.",
|
||||
parameters: z.object({
|
||||
code: z.string({
|
||||
description: "The python code to execute in a single cell.",
|
||||
}),
|
||||
code: z
|
||||
.string()
|
||||
.describe("The python code to execute in a single cell."),
|
||||
}),
|
||||
},
|
||||
);
|
||||
|
||||
@@ -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 }) {
|
||||
|
||||
@@ -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,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,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.");
|
||||
|
||||
@@ -2,15 +2,13 @@ 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",
|
||||
description: "Get the weather",
|
||||
parameters: z.object({
|
||||
location: z.string({
|
||||
description: "The location to get the weather for",
|
||||
}),
|
||||
location: z.string().describe("The location to get the weather for"),
|
||||
}),
|
||||
execute: ({ location }) => {
|
||||
return `The weather in ${location} is rainy`;
|
||||
|
||||
@@ -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: [
|
||||
|
||||
@@ -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,15 +1,13 @@
|
||||
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",
|
||||
description: "Get the weather",
|
||||
parameters: z.object({
|
||||
location: z.string({
|
||||
description: "The location to get the weather for",
|
||||
}),
|
||||
location: z.string().describe("The location to get the weather for"),
|
||||
}),
|
||||
execute: ({ location }) => {
|
||||
return `The weather in ${location} is sunny`;
|
||||
|
||||
+14
-14
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@llamaindex/examples",
|
||||
"version": "0.3.37",
|
||||
"version": "0.3.38",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
@@ -14,24 +14,24 @@
|
||||
"@llamaindex/anthropic": "^0.3.22",
|
||||
"@llamaindex/assemblyai": "^0.1.18",
|
||||
"@llamaindex/astra": "^0.0.33",
|
||||
"@llamaindex/azure": "^0.1.32",
|
||||
"@llamaindex/azure": "^0.1.33",
|
||||
"@llamaindex/bm25-retriever": "^0.0.8",
|
||||
"@llamaindex/chroma": "^0.0.33",
|
||||
"@llamaindex/clip": "^0.0.71",
|
||||
"@llamaindex/clip": "^0.0.72",
|
||||
"@llamaindex/cloud": "^4.1.1",
|
||||
"@llamaindex/cohere": "^0.0.33",
|
||||
"@llamaindex/core": "^0.6.19",
|
||||
"@llamaindex/deepinfra": "^0.0.71",
|
||||
"@llamaindex/deepseek": "^0.0.33",
|
||||
"@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.26",
|
||||
"@llamaindex/fireworks": "^0.0.31",
|
||||
"@llamaindex/fireworks": "^0.0.32",
|
||||
"@llamaindex/google": "^0.3.18",
|
||||
"@llamaindex/groq": "^0.0.87",
|
||||
"@llamaindex/huggingface": "^0.1.25",
|
||||
"@llamaindex/jinaai": "^0.0.31",
|
||||
"@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",
|
||||
@@ -39,8 +39,8 @@
|
||||
"@llamaindex/node-parser": "^2.0.19",
|
||||
"@llamaindex/notion": "^0.1.18",
|
||||
"@llamaindex/ollama": "^0.1.20",
|
||||
"@llamaindex/openai": "^0.4.15",
|
||||
"@llamaindex/perplexity": "^0.0.28",
|
||||
"@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",
|
||||
@@ -48,15 +48,15 @@
|
||||
"@llamaindex/readers": "^3.1.18",
|
||||
"@llamaindex/replicate": "^0.0.61",
|
||||
"@llamaindex/supabase": "^0.1.20",
|
||||
"@llamaindex/together": "^0.0.31",
|
||||
"@llamaindex/together": "^0.0.32",
|
||||
"@llamaindex/tools": "^0.1.9",
|
||||
"@llamaindex/upstash": "^0.0.33",
|
||||
"@llamaindex/vercel": "^0.1.19",
|
||||
"@llamaindex/vllm": "^0.0.57",
|
||||
"@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.18",
|
||||
"@llamaindex/xai": "^0.0.19",
|
||||
"@notionhq/client": "^4.0.0",
|
||||
"@pinecone-database/pinecone": "^4.0.0",
|
||||
"@vercel/postgres": "^0.10.0",
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { emptyLogger } from "@llamaindex/env";
|
||||
import type { JSONObject } from "../global";
|
||||
import { tool } from "../tools/";
|
||||
import { extractText } from "../utils/llms";
|
||||
import { streamConverter } from "../utils/stream";
|
||||
import { callToolToMessage, getToolCallsFromResponse } from "./tool-call";
|
||||
@@ -18,6 +20,7 @@ import type {
|
||||
PartialToolCall,
|
||||
ToolCallLLMMessageOptions,
|
||||
} from "./type";
|
||||
import { isZodSchema } from "./utils";
|
||||
|
||||
export abstract class BaseLLM<
|
||||
AdditionalChatOptions extends object = object,
|
||||
@@ -97,6 +100,31 @@ export abstract class BaseLLM<
|
||||
| ExecResponse<AdditionalMessageOptions>
|
||||
| ExecStreamResponse<AdditionalMessageOptions>
|
||||
> {
|
||||
const responseFormat = params.responseFormat;
|
||||
if (responseFormat && isZodSchema(responseFormat)) {
|
||||
const structuredTool = tool({
|
||||
name: "format_output",
|
||||
description: "Respond with a JSON object",
|
||||
parameters: responseFormat,
|
||||
execute: (args) => {
|
||||
const result = responseFormat.safeParse(args);
|
||||
if (!result.success) {
|
||||
console.error("Invalid input from LLM:", result.error);
|
||||
return JSON.stringify({
|
||||
error: "Invalid schema",
|
||||
details: result.error,
|
||||
});
|
||||
}
|
||||
return result.data as JSONObject;
|
||||
},
|
||||
});
|
||||
if (Array.isArray(params.tools)) {
|
||||
params.tools.push(structuredTool);
|
||||
} else {
|
||||
params.tools = [structuredTool];
|
||||
}
|
||||
params.responseFormat = undefined;
|
||||
}
|
||||
if (params.stream) {
|
||||
return this.streamExec(params);
|
||||
}
|
||||
|
||||
@@ -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,7 +1,6 @@
|
||||
import { consoleLogger, type Logger } from "@llamaindex/env";
|
||||
import type { JSONSchemaType } from "ajv";
|
||||
import { z } from "zod";
|
||||
import { zodToJsonSchema } from "zod-to-json-schema";
|
||||
import * as z from "zod/v4";
|
||||
import type { JSONValue } from "../global";
|
||||
import type { BaseTool, ToolMetadata } from "../llms";
|
||||
|
||||
@@ -94,8 +93,8 @@ export class FunctionTool<
|
||||
) {
|
||||
const { execute, parameters, ...restConfig } = fnOrConfig;
|
||||
|
||||
if (parameters instanceof z.ZodSchema) {
|
||||
const jsonSchema = zodToJsonSchema(parameters);
|
||||
if (parameters instanceof z.ZodType) {
|
||||
const jsonSchema = z.toJSONSchema(parameters);
|
||||
return new FunctionTool(
|
||||
execute,
|
||||
{
|
||||
@@ -110,8 +109,8 @@ export class FunctionTool<
|
||||
}
|
||||
|
||||
// Handle the original cases
|
||||
if (schema && schema.parameters instanceof z.ZodSchema) {
|
||||
const jsonSchema = zodToJsonSchema(schema.parameters);
|
||||
if (schema && schema.parameters instanceof z.ZodType) {
|
||||
const jsonSchema = z.toJSONSchema(schema.parameters);
|
||||
return new FunctionTool(
|
||||
fnOrConfig,
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { FunctionTool, tool } from "@llamaindex/core/tools";
|
||||
import { describe, expect, test, vi } from "vitest";
|
||||
import { z } from "zod";
|
||||
import * as z from "zod/v4";
|
||||
|
||||
describe("FunctionTool", () => {
|
||||
test("type system", () => {
|
||||
@@ -37,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,
|
||||
};
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/core-test
|
||||
|
||||
## 0.1.17
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [4c70376]
|
||||
- @llamaindex/openai@0.4.16
|
||||
|
||||
## 0.1.16
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/llamaindex-test",
|
||||
"private": true,
|
||||
"version": "0.1.16",
|
||||
"version": "0.1.17",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"test": "vitest run"
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/clip
|
||||
|
||||
## 0.0.72
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [4c70376]
|
||||
- @llamaindex/openai@0.4.16
|
||||
|
||||
## 0.0.71
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/clip",
|
||||
"description": "Clip Embedding Adapter for LlamaIndex",
|
||||
"version": "0.0.71",
|
||||
"version": "0.0.72",
|
||||
"type": "module",
|
||||
"types": "dist/index.d.ts",
|
||||
"main": "dist/index.cjs",
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/deepinfra
|
||||
|
||||
## 0.0.72
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [4c70376]
|
||||
- @llamaindex/openai@0.4.16
|
||||
|
||||
## 0.0.71
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/deepinfra",
|
||||
"description": "Deepinfra Adapter for LlamaIndex",
|
||||
"version": "0.0.71",
|
||||
"version": "0.0.72",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/deepseek
|
||||
|
||||
## 0.0.34
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [4c70376]
|
||||
- @llamaindex/openai@0.4.16
|
||||
|
||||
## 0.0.33
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/deepseek",
|
||||
"description": "DeepSeek Adapter for LlamaIndex",
|
||||
"version": "0.0.33",
|
||||
"version": "0.0.34",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/fireworks
|
||||
|
||||
## 0.0.32
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [4c70376]
|
||||
- @llamaindex/openai@0.4.16
|
||||
|
||||
## 0.0.31
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/fireworks",
|
||||
"description": "Fireworks Adapter for LlamaIndex",
|
||||
"version": "0.0.31",
|
||||
"version": "0.0.32",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @llamaindex/google
|
||||
|
||||
## 0.3.19
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- c93bb02: chore: remove streaming logs
|
||||
|
||||
## 0.3.18
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/google",
|
||||
"description": "Google Adapter for LlamaIndex",
|
||||
"version": "0.3.18",
|
||||
"version": "0.3.19",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
@@ -226,9 +226,6 @@ export class Gemini extends ToolCallLLM<GeminiAdditionalChatOptions> {
|
||||
const config = this.prepareChatConfig(params);
|
||||
const { message, history } = await this.prepareChatContext(params.messages);
|
||||
|
||||
console.log("history", JSON.stringify(history, null, 2));
|
||||
console.log("message", JSON.stringify(message, null, 2));
|
||||
|
||||
const chat = this.client.chats.create({
|
||||
model: this.model,
|
||||
config,
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/groq
|
||||
|
||||
## 0.0.88
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [4c70376]
|
||||
- @llamaindex/openai@0.4.16
|
||||
|
||||
## 0.0.87
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/groq",
|
||||
"description": "Groq Adapter for LlamaIndex",
|
||||
"version": "0.0.87",
|
||||
"version": "0.0.88",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/huggingface
|
||||
|
||||
## 0.1.26
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [4c70376]
|
||||
- @llamaindex/openai@0.4.16
|
||||
|
||||
## 0.1.25
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/huggingface",
|
||||
"description": "Huggingface Adapter for LlamaIndex",
|
||||
"version": "0.1.25",
|
||||
"version": "0.1.26",
|
||||
"type": "module",
|
||||
"types": "dist/index.d.ts",
|
||||
"main": "dist/index.cjs",
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/jinaai
|
||||
|
||||
## 0.0.32
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [4c70376]
|
||||
- @llamaindex/openai@0.4.16
|
||||
|
||||
## 0.0.31
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/jinaai",
|
||||
"description": "JinaAI Adapter for LlamaIndex",
|
||||
"version": "0.0.31",
|
||||
"version": "0.0.32",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @llamaindex/openai
|
||||
|
||||
## 0.4.16
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 4c70376: Add gpt-5 support
|
||||
|
||||
## 0.4.15
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/openai",
|
||||
"description": "OpenAI Adapter for LlamaIndex",
|
||||
"version": "0.4.15",
|
||||
"version": "0.4.16",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
@@ -131,6 +131,27 @@ export const O4_MODELS = {
|
||||
},
|
||||
};
|
||||
|
||||
export const GPT5_MODELS = {
|
||||
"gpt-5": {
|
||||
contextWindow: 400000,
|
||||
},
|
||||
"gpt-5-2025-08-07": {
|
||||
contextWindow: 400000,
|
||||
},
|
||||
"gpt-5-mini": {
|
||||
contextWindow: 400000,
|
||||
},
|
||||
"gpt-5-mini-2025-08-07": {
|
||||
contextWindow: 400000,
|
||||
},
|
||||
"gpt-5-nano": {
|
||||
contextWindow: 400000,
|
||||
},
|
||||
"gpt-5-nano-2025-08-07": {
|
||||
contextWindow: 400000,
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* We currently support GPT-3.5 and GPT-4 models
|
||||
*/
|
||||
@@ -140,6 +161,7 @@ export const ALL_AVAILABLE_OPENAI_MODELS = {
|
||||
...O1_MODELS,
|
||||
...O3_MODELS,
|
||||
...O4_MODELS,
|
||||
...GPT5_MODELS,
|
||||
"codex-mini-latest": { contextWindow: 200000 },
|
||||
} satisfies Record<ChatModel, { contextWindow: number }>;
|
||||
|
||||
@@ -161,7 +183,8 @@ export function isReasoningModel(model: ChatModel | string): boolean {
|
||||
const isO1 = model.startsWith("o1");
|
||||
const isO3 = model.startsWith("o3");
|
||||
const isO4 = model.startsWith("o4");
|
||||
return isO1 || isO3 || isO4;
|
||||
const isGPT5 = model.startsWith("gpt-5");
|
||||
return isO1 || isO3 || isO4 || isGPT5;
|
||||
}
|
||||
|
||||
export function isTemperatureSupported(model: ChatModel | string): boolean {
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/perplexity
|
||||
|
||||
## 0.0.29
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [4c70376]
|
||||
- @llamaindex/openai@0.4.16
|
||||
|
||||
## 0.0.28
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/perplexity",
|
||||
"description": "Perplexity Adapter for LlamaIndex",
|
||||
"version": "0.0.28",
|
||||
"version": "0.0.29",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/azure
|
||||
|
||||
## 0.1.33
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [4c70376]
|
||||
- @llamaindex/openai@0.4.16
|
||||
|
||||
## 0.1.32
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/azure",
|
||||
"description": "Azure Storage for LlamaIndex",
|
||||
"version": "0.1.32",
|
||||
"version": "0.1.33",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/together
|
||||
|
||||
## 0.0.32
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [4c70376]
|
||||
- @llamaindex/openai@0.4.16
|
||||
|
||||
## 0.0.31
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/together",
|
||||
"description": "Together Adapter for LlamaIndex",
|
||||
"version": "0.0.31",
|
||||
"version": "0.0.32",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/vllm
|
||||
|
||||
## 0.0.58
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [4c70376]
|
||||
- @llamaindex/openai@0.4.16
|
||||
|
||||
## 0.0.57
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/vllm",
|
||||
"description": "vLLM Adapter for LlamaIndex",
|
||||
"version": "0.0.57",
|
||||
"version": "0.0.58",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/xai
|
||||
|
||||
## 0.0.19
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [4c70376]
|
||||
- @llamaindex/openai@0.4.16
|
||||
|
||||
## 0.0.18
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/xai",
|
||||
"description": "XAI Adapter for LlamaIndex",
|
||||
"version": "0.0.18",
|
||||
"version": "0.0.19",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Settings, type JSONValue } from "@llamaindex/core/global";
|
||||
import type { ChatMessage, LLM } from "@llamaindex/core/llms";
|
||||
import { tool } from "@llamaindex/core/tools";
|
||||
import { z } from "zod";
|
||||
import * as z from "zod/v4";
|
||||
|
||||
const CODE_ARTIFACT_GENERATION_PROMPT = `You are a highly skilled software engineer. Your task is to generate a code artifact based on the user's request.
|
||||
Follow these instructions exactly:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Settings, type JSONValue } from "@llamaindex/core/global";
|
||||
import type { ChatMessage } from "@llamaindex/core/llms";
|
||||
import { tool } from "@llamaindex/core/tools";
|
||||
import { z } from "zod";
|
||||
import * as z from "zod/v4";
|
||||
|
||||
// prompt based on https://github.com/e2b-dev/ai-artifacts
|
||||
const CODE_GENERATION_PROMPT = `You are a skilled software engineer. You do not make mistakes. Generate an artifact. You can install additional dependencies. You can use one of the following templates:\n
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Settings, type JSONValue } from "@llamaindex/core/global";
|
||||
import type { ChatMessage, LLM } from "@llamaindex/core/llms";
|
||||
import { tool } from "@llamaindex/core/tools";
|
||||
import { z } from "zod";
|
||||
import * as z from "zod/v4";
|
||||
|
||||
const DOCUMENT_ARTIFACT_GENERATION_PROMPT = `You are a highly skilled content creator. Your task is to generate a document artifact based on the user's request.
|
||||
Follow these instructions exactly:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { tool } from "@llamaindex/core/tools";
|
||||
import { marked } from "marked";
|
||||
import path from "node:path";
|
||||
import { z } from "zod";
|
||||
import * as z from "zod/v4";
|
||||
import { getFileUrl, saveDocument } from "../helper";
|
||||
|
||||
const COMMON_STYLES = `
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { tool } from "@llamaindex/core/tools";
|
||||
import { search } from "duck-duck-scrape";
|
||||
import { z } from "zod";
|
||||
import * as z from "zod/v4";
|
||||
|
||||
export type DuckDuckGoToolOutput = Array<{
|
||||
title: string;
|
||||
|
||||
@@ -3,7 +3,7 @@ import { tool } from "@llamaindex/core/tools";
|
||||
import fs from "fs";
|
||||
import Papa from "papaparse";
|
||||
import path from "path";
|
||||
import { z } from "zod";
|
||||
import * as z from "zod/v4";
|
||||
import { getFileUrl, saveDocument } from "../helper";
|
||||
|
||||
export type MissingCell = {
|
||||
|
||||
@@ -4,7 +4,7 @@ import { FormData } from "formdata-node";
|
||||
import got from "got";
|
||||
import path from "path";
|
||||
import { Readable } from "stream";
|
||||
import { z } from "zod";
|
||||
import * as z from "zod/v4";
|
||||
import { getFileUrl, saveDocument } from "../helper";
|
||||
|
||||
export type ImgGeneratorToolOutput = {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { tool } from "@llamaindex/core/tools";
|
||||
import { randomUUID } from "@llamaindex/env";
|
||||
import fs from "fs";
|
||||
import path from "node:path";
|
||||
import { z } from "zod";
|
||||
import * as z from "zod/v4";
|
||||
import { getFileUrl, saveDocument } from "../helper";
|
||||
|
||||
export type InterpreterExtraType =
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { tool } from "@llamaindex/core/tools";
|
||||
import { z } from "zod";
|
||||
import * as z from "zod/v4";
|
||||
|
||||
export type WeatherToolOutput = {
|
||||
latitude: number;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { tool } from "@llamaindex/core/tools";
|
||||
import { default as wikipedia } from "wikipedia";
|
||||
import { z } from "zod";
|
||||
import * as z from "zod/v4";
|
||||
|
||||
export type WikiToolOutput = {
|
||||
title: string;
|
||||
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
type WorkflowEventData,
|
||||
} from "@llamaindex/workflow-core";
|
||||
import { createStatefulMiddleware } from "@llamaindex/workflow-core/middleware/state";
|
||||
import { z } from "zod";
|
||||
import * as z from "zod/v4";
|
||||
import type { AgentWorkflowState, BaseWorkflowAgent } from "./base";
|
||||
import {
|
||||
agentInputEvent,
|
||||
@@ -680,12 +680,8 @@ export class AgentWorkflow implements Workflow {
|
||||
agent_info: JSON.stringify(agentInfo),
|
||||
}),
|
||||
parameters: z.object({
|
||||
toAgent: z.string({
|
||||
description: "The name of the agent to hand off to",
|
||||
}),
|
||||
reason: z.string({
|
||||
description: "The reason for handing off to the agent",
|
||||
}),
|
||||
toAgent: z.string({}).describe("The name of the agent to hand off to"),
|
||||
reason: z.string({}).describe("The content to save into a file"),
|
||||
}),
|
||||
execute: (
|
||||
{
|
||||
|
||||
@@ -11,8 +11,7 @@ import {
|
||||
type WorkflowContext,
|
||||
type WorkflowEvent,
|
||||
} from "@llamaindex/workflow-core";
|
||||
import { z } from "zod";
|
||||
import { zodToJsonSchema } from "zod-to-json-schema";
|
||||
import * as z from "zod/v4";
|
||||
import { AgentWorkflow } from "./agent-workflow";
|
||||
import { type AgentWorkflowState, type BaseWorkflowAgent } from "./base";
|
||||
import {
|
||||
@@ -416,7 +415,7 @@ const createEventEmitterTool = (
|
||||
event.schema.description ??
|
||||
"Use this tool to send the event to the workflow.") +
|
||||
`\n\nPlease provide the event data in the following JSON schema: ${JSON.stringify(
|
||||
zodToJsonSchema(z.object({ eventData: event.schema })),
|
||||
z.toJSONSchema(z.object({ eventData: event.schema })),
|
||||
)}`;
|
||||
return tool({
|
||||
name: name,
|
||||
|
||||
@@ -3,7 +3,7 @@ import { MockLLM } from "@llamaindex/core/llms/mock";
|
||||
import { FunctionTool } from "@llamaindex/core/tools";
|
||||
import { Logger } from "@llamaindex/env";
|
||||
import { describe, expect, test, vi } from "vitest";
|
||||
import { z } from "zod";
|
||||
import * as z from "zod/v4";
|
||||
import {
|
||||
AgentWorkflow,
|
||||
FunctionAgent,
|
||||
|
||||
@@ -4,7 +4,8 @@ import { tool } from "@llamaindex/core/tools";
|
||||
import { type WorkflowContext } from "@llamaindex/workflow-core";
|
||||
import { zodEvent } from "@llamaindex/workflow-core/util/zod";
|
||||
import { describe, expect, test, vi } from "vitest";
|
||||
import { z } from "zod";
|
||||
import { z as zod } from "zod";
|
||||
import * as z from "zod/v4";
|
||||
import { AgentToolCallResult, FunctionAgent } from "../src/agent";
|
||||
|
||||
const mockLLM = new MockLLM();
|
||||
@@ -81,8 +82,8 @@ describe("FunctionAgent", () => {
|
||||
|
||||
// Create a result event
|
||||
const resultEvent = zodEvent(
|
||||
z.object({
|
||||
value: z.string(),
|
||||
zod.object({
|
||||
value: zod.string(),
|
||||
}),
|
||||
{
|
||||
debugLabel: "my_result_event",
|
||||
@@ -91,8 +92,8 @@ describe("FunctionAgent", () => {
|
||||
|
||||
// Create an additional event
|
||||
const additionalEvent = zodEvent(
|
||||
z.object({
|
||||
value: z.number(),
|
||||
zod.object({
|
||||
value: zod.number(),
|
||||
}),
|
||||
{
|
||||
debugLabel: "additional_event",
|
||||
|
||||
Generated
+13
-13
@@ -624,7 +624,7 @@ importers:
|
||||
specifier: ^0.0.33
|
||||
version: link:../packages/providers/storage/astra
|
||||
'@llamaindex/azure':
|
||||
specifier: ^0.1.32
|
||||
specifier: ^0.1.33
|
||||
version: link:../packages/providers/storage/azure
|
||||
'@llamaindex/bm25-retriever':
|
||||
specifier: ^0.0.8
|
||||
@@ -633,7 +633,7 @@ importers:
|
||||
specifier: ^0.0.33
|
||||
version: link:../packages/providers/storage/chroma
|
||||
'@llamaindex/clip':
|
||||
specifier: ^0.0.71
|
||||
specifier: ^0.0.72
|
||||
version: link:../packages/providers/clip
|
||||
'@llamaindex/cloud':
|
||||
specifier: ^4.1.1
|
||||
@@ -645,10 +645,10 @@ importers:
|
||||
specifier: ^0.6.19
|
||||
version: link:../packages/core
|
||||
'@llamaindex/deepinfra':
|
||||
specifier: ^0.0.71
|
||||
specifier: ^0.0.72
|
||||
version: link:../packages/providers/deepinfra
|
||||
'@llamaindex/deepseek':
|
||||
specifier: ^0.0.33
|
||||
specifier: ^0.0.34
|
||||
version: link:../packages/providers/deepseek
|
||||
'@llamaindex/discord':
|
||||
specifier: ^0.1.18
|
||||
@@ -663,19 +663,19 @@ importers:
|
||||
specifier: ^1.0.26
|
||||
version: link:../packages/providers/storage/firestore
|
||||
'@llamaindex/fireworks':
|
||||
specifier: ^0.0.31
|
||||
specifier: ^0.0.32
|
||||
version: link:../packages/providers/fireworks
|
||||
'@llamaindex/google':
|
||||
specifier: ^0.3.18
|
||||
version: link:../packages/providers/google
|
||||
'@llamaindex/groq':
|
||||
specifier: ^0.0.87
|
||||
specifier: ^0.0.88
|
||||
version: link:../packages/providers/groq
|
||||
'@llamaindex/huggingface':
|
||||
specifier: ^0.1.25
|
||||
specifier: ^0.1.26
|
||||
version: link:../packages/providers/huggingface
|
||||
'@llamaindex/jinaai':
|
||||
specifier: ^0.0.31
|
||||
specifier: ^0.0.32
|
||||
version: link:../packages/providers/jinaai
|
||||
'@llamaindex/milvus':
|
||||
specifier: ^0.1.28
|
||||
@@ -699,10 +699,10 @@ importers:
|
||||
specifier: ^0.1.20
|
||||
version: link:../packages/providers/ollama
|
||||
'@llamaindex/openai':
|
||||
specifier: ^0.4.15
|
||||
specifier: ^0.4.16
|
||||
version: link:../packages/providers/openai
|
||||
'@llamaindex/perplexity':
|
||||
specifier: ^0.0.28
|
||||
specifier: ^0.0.29
|
||||
version: link:../packages/providers/perplexity
|
||||
'@llamaindex/pinecone':
|
||||
specifier: ^0.1.19
|
||||
@@ -726,7 +726,7 @@ importers:
|
||||
specifier: ^0.1.20
|
||||
version: link:../packages/providers/storage/supabase
|
||||
'@llamaindex/together':
|
||||
specifier: ^0.0.31
|
||||
specifier: ^0.0.32
|
||||
version: link:../packages/providers/together
|
||||
'@llamaindex/tools':
|
||||
specifier: ^0.1.9
|
||||
@@ -738,7 +738,7 @@ importers:
|
||||
specifier: ^0.1.19
|
||||
version: link:../packages/providers/vercel
|
||||
'@llamaindex/vllm':
|
||||
specifier: ^0.0.57
|
||||
specifier: ^0.0.58
|
||||
version: link:../packages/providers/vllm
|
||||
'@llamaindex/voyage-ai':
|
||||
specifier: ^1.0.25
|
||||
@@ -750,7 +750,7 @@ importers:
|
||||
specifier: ^1.1.20
|
||||
version: link:../packages/workflow
|
||||
'@llamaindex/xai':
|
||||
specifier: ^0.0.18
|
||||
specifier: ^0.0.19
|
||||
version: link:../packages/providers/xai
|
||||
'@notionhq/client':
|
||||
specifier: 4.0.0
|
||||
|
||||
@@ -2,7 +2,7 @@ import { agent } from "@llamaindex/workflow";
|
||||
import { Document, Settings, tool } from "llamaindex";
|
||||
import { ok } from "node:assert";
|
||||
import { test } from "node:test";
|
||||
import { z } from "zod";
|
||||
import * as z from "zod/v4";
|
||||
|
||||
import { openai } from "@llamaindex/openai";
|
||||
import { VectorStoreIndex } from "llamaindex";
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/unit-test
|
||||
|
||||
## 0.1.58
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [4c70376]
|
||||
- @llamaindex/openai@0.4.16
|
||||
|
||||
## 0.1.57
|
||||
|
||||
### Patch Changes
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/unit-test",
|
||||
"private": true,
|
||||
"version": "0.1.57",
|
||||
"version": "0.1.58",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"test": "vitest run"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { FunctionTool } from "@llamaindex/core/tools";
|
||||
import { describe, expect, test } from "vitest";
|
||||
import { z } from "zod";
|
||||
import * as z from "zod/v4";
|
||||
|
||||
describe("function-tool", () => {
|
||||
test("zod type check", () => {
|
||||
|
||||
Reference in New Issue
Block a user