mirror of
https://github.com/run-llama/LlamaIndexTS.git
synced 2026-07-15 14:55:41 -04:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| df71df48c0 | |||
| d4b6fe6156 | |||
| 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,29 +1,5 @@
|
||||
# @llamaindex/doc
|
||||
|
||||
## 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@llamaindex/doc",
|
||||
"version": "0.2.53",
|
||||
"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:*",
|
||||
|
||||
@@ -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,17 +1,5 @@
|
||||
# @llamaindex/cloudflare-worker-agent-test
|
||||
|
||||
## 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.189",
|
||||
"version": "0.0.187",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
# @llamaindex/llama-parse-browser-test
|
||||
|
||||
## 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.86",
|
||||
"version": "0.0.85",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
@@ -1,17 +1,5 @@
|
||||
# @llamaindex/next-agent-test
|
||||
|
||||
## 0.1.189
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.11.28
|
||||
|
||||
## 0.1.188
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.11.27
|
||||
|
||||
## 0.1.187
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@llamaindex/next-agent-test",
|
||||
"version": "0.1.189",
|
||||
"version": "0.1.187",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
||||
@@ -1,17 +1,5 @@
|
||||
# test-edge-runtime
|
||||
|
||||
## 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.188",
|
||||
"version": "0.1.186",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
||||
@@ -1,20 +1,5 @@
|
||||
# @llamaindex/next-node-runtime
|
||||
|
||||
## 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.60",
|
||||
"version": "0.1.58",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
||||
@@ -1,17 +1,5 @@
|
||||
# vite-import-llamaindex
|
||||
|
||||
## 0.0.55
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.11.28
|
||||
|
||||
## 0.0.54
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.11.27
|
||||
|
||||
## 0.0.53
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "vite-import-llamaindex",
|
||||
"private": true,
|
||||
"version": "0.0.55",
|
||||
"version": "0.0.53",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "vite build",
|
||||
|
||||
@@ -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,17 +1,5 @@
|
||||
# @llamaindex/waku-query-engine-test
|
||||
|
||||
## 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/waku-query-engine-test",
|
||||
"version": "0.0.189",
|
||||
"version": "0.0.187",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
|
||||
@@ -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,80 +1,5 @@
|
||||
# examples
|
||||
|
||||
## 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
|
||||
|
||||
@@ -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" });
|
||||
|
||||
+4
-5
@@ -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,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",
|
||||
|
||||
@@ -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`
|
||||
@@ -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 }) {
|
||||
|
||||
@@ -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}`);
|
||||
});
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"moduleResolution": "node",
|
||||
"types": ["node", "express"]
|
||||
},
|
||||
"include": ["*.ts"]
|
||||
}
|
||||
@@ -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`;
|
||||
|
||||
+47
-48
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@llamaindex/examples",
|
||||
"version": "0.3.40",
|
||||
"version": "0.3.38",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
@@ -11,52 +11,52 @@
|
||||
"@azure/cosmos": "^4.1.1",
|
||||
"@azure/identity": "^4.4.1",
|
||||
"@azure/search-documents": "^12.1.0",
|
||||
"@llamaindex/anthropic": "^0.3.23",
|
||||
"@llamaindex/assemblyai": "^0.1.19",
|
||||
"@llamaindex/astra": "^0.0.34",
|
||||
"@llamaindex/azure": "^0.1.35",
|
||||
"@llamaindex/bm25-retriever": "^0.0.9",
|
||||
"@llamaindex/chroma": "^0.0.34",
|
||||
"@llamaindex/clip": "^0.0.74",
|
||||
"@llamaindex/cloud": "^4.1.2",
|
||||
"@llamaindex/cohere": "^0.0.34",
|
||||
"@llamaindex/core": "^0.6.20",
|
||||
"@llamaindex/deepinfra": "^0.0.74",
|
||||
"@llamaindex/deepseek": "^0.0.36",
|
||||
"@llamaindex/discord": "^0.1.19",
|
||||
"@llamaindex/elastic-search": "^0.1.20",
|
||||
"@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.27",
|
||||
"@llamaindex/fireworks": "^0.0.34",
|
||||
"@llamaindex/google": "^0.3.20",
|
||||
"@llamaindex/groq": "^0.0.90",
|
||||
"@llamaindex/huggingface": "^0.1.28",
|
||||
"@llamaindex/jinaai": "^0.0.34",
|
||||
"@llamaindex/milvus": "^0.1.29",
|
||||
"@llamaindex/mistral": "^0.1.20",
|
||||
"@llamaindex/mixedbread": "^0.0.34",
|
||||
"@llamaindex/mongodb": "^0.0.35",
|
||||
"@llamaindex/node-parser": "^2.0.20",
|
||||
"@llamaindex/notion": "^0.1.19",
|
||||
"@llamaindex/ollama": "^0.1.21",
|
||||
"@llamaindex/openai": "^0.4.18",
|
||||
"@llamaindex/perplexity": "^0.0.31",
|
||||
"@llamaindex/pinecone": "^0.1.20",
|
||||
"@llamaindex/portkey-ai": "^0.0.62",
|
||||
"@llamaindex/postgres": "^0.0.63",
|
||||
"@llamaindex/qdrant": "^0.1.30",
|
||||
"@llamaindex/readers": "^3.1.19",
|
||||
"@llamaindex/replicate": "^0.0.62",
|
||||
"@llamaindex/supabase": "^0.1.21",
|
||||
"@llamaindex/together": "^0.0.34",
|
||||
"@llamaindex/tools": "^0.1.10",
|
||||
"@llamaindex/upstash": "^0.0.34",
|
||||
"@llamaindex/vercel": "^0.1.20",
|
||||
"@llamaindex/vllm": "^0.0.60",
|
||||
"@llamaindex/voyage-ai": "^1.0.26",
|
||||
"@llamaindex/weaviate": "^0.0.35",
|
||||
"@llamaindex/workflow": "^1.1.22",
|
||||
"@llamaindex/xai": "^0.0.21",
|
||||
"@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",
|
||||
@@ -65,14 +65,13 @@
|
||||
"commander": "^12.1.0",
|
||||
"dotenv": "^17.2.0",
|
||||
"js-tiktoken": "^1.0.14",
|
||||
"llamaindex": "^0.11.28",
|
||||
"llamaindex": "^0.11.26",
|
||||
"mongodb": "6.7.0",
|
||||
"postgres": "^3.4.4",
|
||||
"wikipedia": "^2.1.2",
|
||||
"zod": "^3.25.76"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/express": "^5.0.3",
|
||||
"@types/node": "^24.0.13",
|
||||
"tsx": "^4.20.3",
|
||||
"typescript": "^5.8.3"
|
||||
|
||||
@@ -1,17 +1,5 @@
|
||||
# @llamaindex/autotool
|
||||
|
||||
## 8.0.28
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.11.28
|
||||
|
||||
## 8.0.27
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.11.27
|
||||
|
||||
## 8.0.26
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,19 +1,5 @@
|
||||
# @llamaindex/autotool-01-node-example
|
||||
|
||||
## 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.136"
|
||||
"version": "0.0.134"
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"url": "git+https://github.com/run-llama/LlamaIndexTS.git",
|
||||
"directory": "packages/autotool"
|
||||
},
|
||||
"version": "8.0.28",
|
||||
"version": "8.0.26",
|
||||
"description": "auto transpile your JS function to LLM Agent compatible",
|
||||
"files": [
|
||||
"dist",
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
# @llamaindex/cloud
|
||||
|
||||
## 4.1.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [0267bb0]
|
||||
- @llamaindex/core@0.6.20
|
||||
|
||||
## 4.1.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@llamaindex/cloud",
|
||||
"version": "4.1.2",
|
||||
"version": "4.1.1",
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
# @llamaindex/community
|
||||
|
||||
## 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,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/community",
|
||||
"description": "Community package for LlamaIndexTS",
|
||||
"version": "0.0.102",
|
||||
"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),
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
# @llamaindex/core
|
||||
|
||||
## 0.6.20
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 0267bb0: Added responseFormat to llm.exec
|
||||
|
||||
## 0.6.19
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/core",
|
||||
"type": "module",
|
||||
"version": "0.6.20",
|
||||
"version": "0.6.19",
|
||||
"description": "LlamaIndex Core Module",
|
||||
"exports": {
|
||||
"./agent": {
|
||||
|
||||
@@ -101,7 +101,7 @@ 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",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { z } from "zod";
|
||||
import * as z from "zod/v4";
|
||||
import type {
|
||||
ChatMessage,
|
||||
MessageContentImageDataDetail,
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
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";
|
||||
import { isZodSchema } from "../llms/utils";
|
||||
|
||||
export class FunctionTool<
|
||||
T,
|
||||
@@ -95,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,
|
||||
{
|
||||
@@ -106,12 +104,13 @@ export class FunctionTool<
|
||||
parameters,
|
||||
);
|
||||
}
|
||||
|
||||
return new FunctionTool(execute, fnOrConfig);
|
||||
}
|
||||
|
||||
// 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,17 +1,5 @@
|
||||
# @llamaindex/experimental
|
||||
|
||||
## 0.0.205
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.11.28
|
||||
|
||||
## 0.0.204
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.11.27
|
||||
|
||||
## 0.0.203
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/experimental",
|
||||
"description": "Experimental package for LlamaIndexTS",
|
||||
"version": "0.0.205",
|
||||
"version": "0.0.203",
|
||||
"type": "module",
|
||||
"types": "dist/type/index.d.ts",
|
||||
"main": "dist/cjs/index.js",
|
||||
|
||||
@@ -1,22 +1,5 @@
|
||||
# llamaindex
|
||||
|
||||
## 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,6 +1,6 @@
|
||||
{
|
||||
"name": "llamaindex",
|
||||
"version": "0.11.28",
|
||||
"version": "0.11.26",
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
"keywords": [
|
||||
|
||||
@@ -1,19 +1,5 @@
|
||||
# @llamaindex/core-test
|
||||
|
||||
## 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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/llamaindex-test",
|
||||
"private": true,
|
||||
"version": "0.1.19",
|
||||
"version": "0.1.17",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"test": "vitest run"
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
# @llamaindex/node-parser
|
||||
|
||||
## 2.0.20
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [0267bb0]
|
||||
- @llamaindex/core@0.6.20
|
||||
|
||||
## 2.0.19
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@llamaindex/node-parser",
|
||||
"version": "2.0.20",
|
||||
"version": "2.0.19",
|
||||
"description": "Node parser for LlamaIndex",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
# @llamaindex/anthropic
|
||||
|
||||
## 0.3.23
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [0267bb0]
|
||||
- @llamaindex/core@0.6.20
|
||||
|
||||
## 0.3.22
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/anthropic",
|
||||
"description": "Anthropic Adapter for LlamaIndex",
|
||||
"version": "0.3.23",
|
||||
"version": "0.3.22",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
# @llamaindex/assemblyai
|
||||
|
||||
## 0.1.19
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [0267bb0]
|
||||
- @llamaindex/core@0.6.20
|
||||
|
||||
## 0.1.18
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/assemblyai",
|
||||
"description": "AssemblyAI Reader for LlamaIndex",
|
||||
"version": "0.1.19",
|
||||
"version": "0.1.18",
|
||||
"type": "module",
|
||||
"types": "dist/index.d.ts",
|
||||
"main": "dist/index.cjs",
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
# @llamaindex/community
|
||||
|
||||
## 0.0.116
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [0267bb0]
|
||||
- @llamaindex/core@0.6.20
|
||||
|
||||
## 0.0.115
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/aws",
|
||||
"description": "AWS package for LlamaIndexTS",
|
||||
"version": "0.0.116",
|
||||
"version": "0.0.115",
|
||||
"type": "module",
|
||||
"types": "dist/type/index.d.ts",
|
||||
"main": "dist/cjs/index.js",
|
||||
|
||||
@@ -546,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) => {
|
||||
@@ -559,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),
|
||||
|
||||
@@ -1,21 +1,5 @@
|
||||
# @llamaindex/clip
|
||||
|
||||
## 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,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/clip",
|
||||
"description": "Clip Embedding Adapter for LlamaIndex",
|
||||
"version": "0.0.74",
|
||||
"version": "0.0.72",
|
||||
"type": "module",
|
||||
"types": "dist/index.d.ts",
|
||||
"main": "dist/index.cjs",
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
# @llamaindex/cohere
|
||||
|
||||
## 0.0.34
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [0267bb0]
|
||||
- @llamaindex/core@0.6.20
|
||||
|
||||
## 0.0.33
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/cohere",
|
||||
"description": "Cohere Adapter for LlamaIndex",
|
||||
"version": "0.0.34",
|
||||
"version": "0.0.33",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
@@ -1,21 +1,5 @@
|
||||
# @llamaindex/deepinfra
|
||||
|
||||
## 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,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/deepinfra",
|
||||
"description": "Deepinfra Adapter for LlamaIndex",
|
||||
"version": "0.0.74",
|
||||
"version": "0.0.72",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
@@ -1,19 +1,5 @@
|
||||
# @llamaindex/deepseek
|
||||
|
||||
## 0.0.36
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [001a515]
|
||||
- Updated dependencies [9d7d205]
|
||||
- @llamaindex/openai@0.4.18
|
||||
|
||||
## 0.0.35
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @llamaindex/openai@0.4.17
|
||||
|
||||
## 0.0.34
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/deepseek",
|
||||
"description": "DeepSeek Adapter for LlamaIndex",
|
||||
"version": "0.0.36",
|
||||
"version": "0.0.34",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
# @llamaindex/discord
|
||||
|
||||
## 0.1.19
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [0267bb0]
|
||||
- @llamaindex/core@0.6.20
|
||||
|
||||
## 0.1.18
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/discord",
|
||||
"description": "Discord Reader for LlamaIndex",
|
||||
"version": "0.1.19",
|
||||
"version": "0.1.18",
|
||||
"type": "module",
|
||||
"types": "dist/index.d.ts",
|
||||
"main": "dist/index.cjs",
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
# @llamaindex/excel
|
||||
|
||||
## 0.1.20
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [0267bb0]
|
||||
- @llamaindex/core@0.6.20
|
||||
|
||||
## 0.1.19
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/excel",
|
||||
"description": "Excel Reader for LlamaIndex",
|
||||
"version": "0.1.20",
|
||||
"version": "0.1.19",
|
||||
"type": "module",
|
||||
"types": "dist/index.d.ts",
|
||||
"main": "dist/index.cjs",
|
||||
|
||||
@@ -1,19 +1,5 @@
|
||||
# @llamaindex/fireworks
|
||||
|
||||
## 0.0.34
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [001a515]
|
||||
- Updated dependencies [9d7d205]
|
||||
- @llamaindex/openai@0.4.18
|
||||
|
||||
## 0.0.33
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @llamaindex/openai@0.4.17
|
||||
|
||||
## 0.0.32
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/fireworks",
|
||||
"description": "Fireworks Adapter for LlamaIndex",
|
||||
"version": "0.0.34",
|
||||
"version": "0.0.32",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
# @llamaindex/google
|
||||
|
||||
## 0.3.20
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [0267bb0]
|
||||
- @llamaindex/core@0.6.20
|
||||
|
||||
## 0.3.19
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/google",
|
||||
"description": "Google Adapter for LlamaIndex",
|
||||
"version": "0.3.20",
|
||||
"version": "0.3.19",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
@@ -1,19 +1,5 @@
|
||||
# @llamaindex/groq
|
||||
|
||||
## 0.0.90
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [001a515]
|
||||
- Updated dependencies [9d7d205]
|
||||
- @llamaindex/openai@0.4.18
|
||||
|
||||
## 0.0.89
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- @llamaindex/openai@0.4.17
|
||||
|
||||
## 0.0.88
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/groq",
|
||||
"description": "Groq Adapter for LlamaIndex",
|
||||
"version": "0.0.90",
|
||||
"version": "0.0.88",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
@@ -1,21 +1,5 @@
|
||||
# @llamaindex/huggingface
|
||||
|
||||
## 0.1.28
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [001a515]
|
||||
- Updated dependencies [9d7d205]
|
||||
- @llamaindex/openai@0.4.18
|
||||
|
||||
## 0.1.27
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [0267bb0]
|
||||
- @llamaindex/core@0.6.20
|
||||
- @llamaindex/openai@0.4.17
|
||||
|
||||
## 0.1.26
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/huggingface",
|
||||
"description": "Huggingface Adapter for LlamaIndex",
|
||||
"version": "0.1.28",
|
||||
"version": "0.1.26",
|
||||
"type": "module",
|
||||
"types": "dist/index.d.ts",
|
||||
"main": "dist/index.cjs",
|
||||
|
||||
@@ -1,21 +1,5 @@
|
||||
# @llamaindex/jinaai
|
||||
|
||||
## 0.0.34
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [001a515]
|
||||
- Updated dependencies [9d7d205]
|
||||
- @llamaindex/openai@0.4.18
|
||||
|
||||
## 0.0.33
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [0267bb0]
|
||||
- @llamaindex/core@0.6.20
|
||||
- @llamaindex/openai@0.4.17
|
||||
|
||||
## 0.0.32
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/jinaai",
|
||||
"description": "JinaAI Adapter for LlamaIndex",
|
||||
"version": "0.0.34",
|
||||
"version": "0.0.32",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user