Compare commits

...

4 Commits

Author SHA1 Message Date
github-actions[bot] cb73f77bb8 Release 0.9.9 (#1713)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: marcusschiesser <17126+marcusschiesser@users.noreply.github.com>
2025-03-07 16:28:36 +07:00
Huu Le 8bf1ca1701 Support chat stream with tools for Anthropic LLM (#1710)
Co-authored-by: thucpn <thucsh2@gmail.com>
Co-authored-by: Thuc Pham <51660321+thucpn@users.noreply.github.com>
2025-03-07 15:41:15 +07:00
Alexander Tigselema 58b3ee52e0 Add Gemini 2.0 Flas Lite, Fix tools error with LLM Agent (#1712) 2025-03-07 11:15:51 +07:00
Thomas Vanier 4bac71d6a2 feat: additional tool argument (#1693) 2025-03-07 11:15:10 +07:00
113 changed files with 881 additions and 173 deletions
+14
View File
@@ -1,5 +1,19 @@
# @llamaindex/doc
## 0.1.9
### Patch Changes
- 4bac71d: Support binding additional argument to function tool
- Updated dependencies [4bac71d]
- @llamaindex/core@0.5.7
- @llamaindex/cloud@3.0.8
- llamaindex@0.9.9
- @llamaindex/node-parser@1.0.7
- @llamaindex/openai@0.1.59
- @llamaindex/readers@2.0.7
- @llamaindex/workflow@0.0.15
## 0.1.8
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/doc",
"version": "0.1.8",
"version": "0.1.9",
"private": true,
"scripts": {
"build": "pnpm run build:docs && next build",
@@ -0,0 +1,60 @@
---
title: Tools
---
A "tool" is a utility that can be called by an agent on behalf of an LLM.
A tool can be called to perform custom actions, or retrieve extra information based on the LLM-generated input.
A result from a tool call can be used by subsequent steps in a workflow, or to compute a final answer.
For example, a "weather tool" could fetch some live weather information from a geographical location.
## Function tool
Function tools are implemented with the `FunctionTool` class.
A `FunctionTool` is constructed from a function with signature
```ts
(input: T, additionalArg?: AdditionalToolArgument) => R
```
where
- `input` is generated by the LLM, `T` is the type defined by the tool `parameters`
- `additionalArg` is an optional extra argument, see "Binding" below
- `R` is the return type
### Binding
An additional argument can be bound to a tool, each tool call will be passed
- the input provided by the LLM
- the additional argument (extends object)
Note: calling the `bind` method will return a new `FunctionTool` instance, without modifying the tool which `bind` is called on.
Example to pass a `userToken` as additional argument:
```ts
// first arg is LLM input, second is bound arg
const queryKnowledgeBase = async ({ question }, { userToken }) => {
const response = await fetch(`https://knowledge-base.com?token=${userToken}&query=${question}`);
// ...
};
// define tool as usual
const kbTool = FunctionTool.from(queryKnowledgeBase, {
name: 'queryKnowledgeBase',
description: 'Query knowledge base',
parameters: {
type: 'object',
properties: {
question: {
type: 'string',
description: 'The user question',
},
},
required: ['question'],
},
});
// create an agent
const additionalArg = { userToken: 'abcd1234' };
const kbAgent = new LLMAgent({
tools: [kbTool.bind(additionalArg)],
// llm, systemPrompt etc
})
```
@@ -1,5 +1,11 @@
# @llamaindex/cloudflare-worker-agent-test
## 0.0.143
### Patch Changes
- llamaindex@0.9.9
## 0.0.142
### Patch Changes
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/cloudflare-worker-agent-test",
"version": "0.0.142",
"version": "0.0.143",
"type": "module",
"private": true,
"scripts": {
@@ -1,5 +1,11 @@
# @llamaindex/llama-parse-browser-test
## 0.0.53
### Patch Changes
- @llamaindex/cloud@3.0.8
## 0.0.52
### Patch Changes
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/llama-parse-browser-test",
"private": true,
"version": "0.0.52",
"version": "0.0.53",
"type": "module",
"scripts": {
"dev": "vite",
+6
View File
@@ -1,5 +1,11 @@
# @llamaindex/next-agent-test
## 0.1.143
### Patch Changes
- llamaindex@0.9.9
## 0.1.142
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/next-agent-test",
"version": "0.1.142",
"version": "0.1.143",
"private": true,
"scripts": {
"dev": "next dev",
@@ -1,5 +1,11 @@
# test-edge-runtime
## 0.1.142
### Patch Changes
- llamaindex@0.9.9
## 0.1.141
### Patch Changes
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/nextjs-edge-runtime-test",
"version": "0.1.141",
"version": "0.1.142",
"private": true,
"scripts": {
"dev": "next dev",
@@ -1,5 +1,13 @@
# @llamaindex/next-node-runtime
## 0.1.9
### Patch Changes
- llamaindex@0.9.9
- @llamaindex/huggingface@0.0.43
- @llamaindex/readers@2.0.7
## 0.1.8
### Patch Changes
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/next-node-runtime-test",
"version": "0.1.8",
"version": "0.1.9",
"private": true,
"scripts": {
"dev": "next dev",
@@ -1,5 +1,11 @@
# vite-import-llamaindex
## 0.0.9
### Patch Changes
- llamaindex@0.9.9
## 0.0.8
### Patch Changes
@@ -1,7 +1,7 @@
{
"name": "vite-import-llamaindex",
"private": true,
"version": "0.0.8",
"version": "0.0.9",
"type": "module",
"scripts": {
"build": "vite build",
@@ -1,5 +1,11 @@
# @llamaindex/waku-query-engine-test
## 0.0.143
### Patch Changes
- llamaindex@0.9.9
## 0.0.142
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/waku-query-engine-test",
"version": "0.0.142",
"version": "0.0.143",
"type": "module",
"private": true,
"scripts": {
+45
View File
@@ -1,5 +1,50 @@
# examples
## 0.2.8
### Patch Changes
- Updated dependencies [58b3ee5]
- Updated dependencies [4bac71d]
- Updated dependencies [8bf1ca1]
- @llamaindex/google@0.1.0
- @llamaindex/core@0.5.7
- @llamaindex/anthropic@0.2.5
- @llamaindex/cloud@3.0.8
- llamaindex@0.9.9
- @llamaindex/node-parser@1.0.7
- @llamaindex/clip@0.0.43
- @llamaindex/cohere@0.0.12
- @llamaindex/deepinfra@0.0.43
- @llamaindex/huggingface@0.0.43
- @llamaindex/jinaai@0.0.3
- @llamaindex/mistral@0.0.12
- @llamaindex/mixedbread@0.0.12
- @llamaindex/ollama@0.0.47
- @llamaindex/openai@0.1.59
- @llamaindex/portkey-ai@0.0.40
- @llamaindex/replicate@0.0.40
- @llamaindex/astra@0.0.12
- @llamaindex/azure@0.1.7
- @llamaindex/chroma@0.0.12
- @llamaindex/firestore@1.0.5
- @llamaindex/milvus@0.1.7
- @llamaindex/mongodb@0.0.12
- @llamaindex/pinecone@0.0.12
- @llamaindex/postgres@0.0.40
- @llamaindex/qdrant@0.1.7
- @llamaindex/upstash@0.0.12
- @llamaindex/weaviate@0.0.12
- @llamaindex/vercel@0.0.18
- @llamaindex/voyage-ai@1.0.4
- @llamaindex/readers@2.0.7
- @llamaindex/workflow@0.0.15
- @llamaindex/deepseek@0.0.3
- @llamaindex/fireworks@0.0.3
- @llamaindex/groq@0.0.58
- @llamaindex/together@0.0.3
- @llamaindex/vllm@0.0.29
## 0.2.7
### Patch Changes
+114
View File
@@ -0,0 +1,114 @@
import fs from "fs";
import {
AgentToolCall,
AgentToolCallResult,
AgentWorkflow,
FunctionAgent,
FunctionTool,
} from "llamaindex";
import { z } from "zod";
import { Anthropic } from "@llamaindex/anthropic";
const llm = new Anthropic({
model: "claude-3-5-sonnet",
});
const weatherTool = FunctionTool.from(
(query: { location: string }) => {
return `The weather in ${query.location} is sunny`;
},
{
name: "weather",
description: "Get the weather",
parameters: z.object({
location: z.string({
description: "The location to get the weather for",
}),
}),
},
);
const inflationTool = FunctionTool.from(
(query: { location: string }) => {
return `The inflation in ${query.location} is 2%`;
},
{
name: "inflation",
description: "Get the inflation",
parameters: z.object({
location: z.string({
description: "The location to get the inflation for",
}),
}),
},
);
const saveFileTool = FunctionTool.from(
({ content }: { content: string }) => {
const filePath = "./report.md";
fs.writeFileSync(filePath, content);
return `File saved successfully at ${filePath}`;
},
{
name: "saveFile",
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",
}),
}),
},
);
async function main() {
const reportAgent = new FunctionAgent({
name: "ReportAgent",
description:
"Responsible for creating concise reports about weather and inflation data",
systemPrompt: `You are a professional writer. Your task is to create a clear and concise report summarizing the weather and inflation data provided. Once complete, save the report to a file using the saveFile tool.`,
tools: [saveFileTool],
llm,
});
const researchAgent = new FunctionAgent({
name: "ResearchAgent",
description:
"Responsible for gathering relevant information from the internet",
systemPrompt: `You are a research agent. Your role is to gather information about the inflation and weather in the location provided.`,
tools: [inflationTool, weatherTool],
canHandoffTo: [reportAgent],
llm,
});
const workflow = new AgentWorkflow({
agents: [researchAgent, reportAgent],
rootAgent: researchAgent,
});
const context = workflow.run(
"Write a report about New York weather and inflation",
);
let finalResult;
for await (const event of context) {
if (event instanceof AgentToolCall) {
console.log(
`[Agent ${event.displayName}] executing tool ${event.data.toolName} with parameters ${JSON.stringify(
event.data.toolKwargs,
)}`,
);
} else if (event instanceof AgentToolCallResult) {
console.log(
`[Agent ${event.displayName}] executed tool ${event.data.toolName} with result ${event.data.toolOutput.result}`,
);
}
finalResult = event;
}
console.log("Final result:", finalResult?.data);
}
main().catch((error) => {
console.error("Error:", error);
});
+38 -38
View File
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/examples",
"version": "0.2.7",
"version": "0.2.8",
"private": true,
"scripts": {
"lint": "eslint .",
@@ -11,43 +11,43 @@
"@azure/cosmos": "^4.1.1",
"@azure/identity": "^4.4.1",
"@azure/search-documents": "^12.1.0",
"@llamaindex/anthropic": "^0.2.4",
"@llamaindex/astra": "^0.0.11",
"@llamaindex/azure": "^0.1.6",
"@llamaindex/chroma": "^0.0.11",
"@llamaindex/clip": "^0.0.42",
"@llamaindex/cloud": "^3.0.7",
"@llamaindex/cohere": "^0.0.11",
"@llamaindex/core": "^0.5.6",
"@llamaindex/deepinfra": "^0.0.42",
"@llamaindex/anthropic": "^0.2.5",
"@llamaindex/astra": "^0.0.12",
"@llamaindex/azure": "^0.1.7",
"@llamaindex/chroma": "^0.0.12",
"@llamaindex/clip": "^0.0.43",
"@llamaindex/cloud": "^3.0.8",
"@llamaindex/cohere": "^0.0.12",
"@llamaindex/core": "^0.5.7",
"@llamaindex/deepinfra": "^0.0.43",
"@llamaindex/env": "^0.1.29",
"@llamaindex/firestore": "^1.0.4",
"@llamaindex/google": "^0.0.14",
"@llamaindex/groq": "^0.0.57",
"@llamaindex/huggingface": "^0.0.42",
"@llamaindex/milvus": "^0.1.6",
"@llamaindex/mistral": "^0.0.11",
"@llamaindex/mixedbread": "^0.0.11",
"@llamaindex/mongodb": "^0.0.11",
"@llamaindex/node-parser": "^1.0.6",
"@llamaindex/ollama": "^0.0.46",
"@llamaindex/openai": "^0.1.58",
"@llamaindex/pinecone": "^0.0.11",
"@llamaindex/portkey-ai": "^0.0.39",
"@llamaindex/postgres": "^0.0.39",
"@llamaindex/qdrant": "^0.1.6",
"@llamaindex/readers": "^2.0.6",
"@llamaindex/replicate": "^0.0.39",
"@llamaindex/upstash": "^0.0.11",
"@llamaindex/vercel": "^0.0.17",
"@llamaindex/vllm": "^0.0.28",
"@llamaindex/voyage-ai": "^1.0.3",
"@llamaindex/weaviate": "^0.0.11",
"@llamaindex/workflow": "^0.0.14",
"@llamaindex/deepseek": "^0.0.2",
"@llamaindex/fireworks": "^0.0.2",
"@llamaindex/together": "^0.0.2",
"@llamaindex/jinaai": "^0.0.2",
"@llamaindex/firestore": "^1.0.5",
"@llamaindex/google": "^0.1.0",
"@llamaindex/groq": "^0.0.58",
"@llamaindex/huggingface": "^0.0.43",
"@llamaindex/milvus": "^0.1.7",
"@llamaindex/mistral": "^0.0.12",
"@llamaindex/mixedbread": "^0.0.12",
"@llamaindex/mongodb": "^0.0.12",
"@llamaindex/node-parser": "^1.0.7",
"@llamaindex/ollama": "^0.0.47",
"@llamaindex/openai": "^0.1.59",
"@llamaindex/pinecone": "^0.0.12",
"@llamaindex/portkey-ai": "^0.0.40",
"@llamaindex/postgres": "^0.0.40",
"@llamaindex/qdrant": "^0.1.7",
"@llamaindex/readers": "^2.0.7",
"@llamaindex/replicate": "^0.0.40",
"@llamaindex/upstash": "^0.0.12",
"@llamaindex/vercel": "^0.0.18",
"@llamaindex/vllm": "^0.0.29",
"@llamaindex/voyage-ai": "^1.0.4",
"@llamaindex/weaviate": "^0.0.12",
"@llamaindex/workflow": "^0.0.15",
"@llamaindex/deepseek": "^0.0.3",
"@llamaindex/fireworks": "^0.0.3",
"@llamaindex/together": "^0.0.3",
"@llamaindex/jinaai": "^0.0.3",
"@notionhq/client": "^2.2.15",
"@pinecone-database/pinecone": "^4.0.0",
"@vercel/postgres": "^0.10.0",
@@ -56,7 +56,7 @@
"commander": "^12.1.0",
"dotenv": "^16.4.5",
"js-tiktoken": "^1.0.14",
"llamaindex": "^0.9.8",
"llamaindex": "^0.9.9",
"mongodb": "6.7.0",
"postgres": "^3.4.4",
"wikipedia": "^2.1.2",
+6
View File
@@ -1,5 +1,11 @@
# @llamaindex/autotool
## 6.0.9
### Patch Changes
- llamaindex@0.9.9
## 6.0.8
### Patch Changes
@@ -1,5 +1,12 @@
# @llamaindex/autotool-01-node-example
## 0.0.90
### Patch Changes
- llamaindex@0.9.9
- @llamaindex/autotool@6.0.9
## 0.0.89
### Patch Changes
@@ -13,5 +13,5 @@
"scripts": {
"start": "node --import tsx --import @llamaindex/autotool/node ./src/index.ts"
},
"version": "0.0.89"
"version": "0.0.90"
}
@@ -1,5 +1,12 @@
# @llamaindex/autotool-02-next-example
## 0.1.134
### Patch Changes
- llamaindex@0.9.9
- @llamaindex/autotool@6.0.9
## 0.1.133
### Patch Changes
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/autotool-02-next-example",
"private": true,
"version": "0.1.133",
"version": "0.1.134",
"scripts": {
"dev": "next dev",
"build": "next build",
+1 -1
View File
@@ -6,7 +6,7 @@
"url": "git+https://github.com/run-llama/LlamaIndexTS.git",
"directory": "packages/autotool"
},
"version": "6.0.8",
"version": "6.0.9",
"description": "auto transpile your JS function to LLM Agent compatible",
"files": [
"dist",
+7
View File
@@ -1,5 +1,12 @@
# @llamaindex/cloud
## 3.0.8
### Patch Changes
- Updated dependencies [4bac71d]
- @llamaindex/core@0.5.7
## 3.0.7
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/cloud",
"version": "3.0.7",
"version": "3.0.8",
"type": "module",
"license": "MIT",
"scripts": {
+7
View File
@@ -1,5 +1,12 @@
# @llamaindex/community
## 0.0.89
### Patch Changes
- Updated dependencies [4bac71d]
- @llamaindex/core@0.5.7
## 0.0.88
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/community",
"description": "Community package for LlamaIndexTS",
"version": "0.0.88",
"version": "0.0.89",
"type": "module",
"types": "dist/type/index.d.ts",
"main": "dist/cjs/index.js",
+6
View File
@@ -1,5 +1,11 @@
# @llamaindex/core
## 0.5.7
### Patch Changes
- 4bac71d: Support binding additional argument to function tool
## 0.5.6
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/core",
"type": "module",
"version": "0.5.6",
"version": "0.5.7",
"description": "LlamaIndex Core Module",
"exports": {
"./agent": {
+4 -2
View File
@@ -224,8 +224,10 @@ export type ToolMetadata<
/**
* Simple Tool interface. Likely to change.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export interface BaseTool<Input = any> {
export interface BaseTool<
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Input = any,
> {
/**
* This could be undefined if the implementation is not provided,
* which might be the case when communicating with a llm.
+55 -17
View File
@@ -4,40 +4,66 @@ import { zodToJsonSchema } from "zod-to-json-schema";
import type { JSONValue } from "../global";
import type { BaseTool, ToolMetadata } from "../llms";
export class FunctionTool<T, R extends JSONValue | Promise<JSONValue>>
implements BaseTool<T>
export class FunctionTool<
T,
R extends JSONValue | Promise<JSONValue>,
AdditionalToolArgument extends object = object,
> implements BaseTool<T>
{
#fn: (input: T) => R;
#fn: (input: T, additionalArg?: AdditionalToolArgument) => R;
#additionalArg: AdditionalToolArgument | undefined;
readonly #metadata: ToolMetadata<JSONSchemaType<T>>;
readonly #zodType: z.ZodType<T> | null = null;
constructor(
fn: (input: T) => R,
fn: (input: T, additionalArg?: AdditionalToolArgument) => R,
metadata: ToolMetadata<JSONSchemaType<T>>,
zodType?: z.ZodType<T>,
additionalArg?: AdditionalToolArgument,
) {
this.#fn = fn;
this.#metadata = metadata;
if (zodType) {
this.#zodType = zodType;
}
this.#additionalArg = additionalArg;
}
static from<T>(
fn: (input: T) => JSONValue | Promise<JSONValue>,
static from<T, AdditionalToolArgument extends object = object>(
fn: (
input: T,
additionalArg?: AdditionalToolArgument,
) => JSONValue | Promise<JSONValue>,
schema: ToolMetadata<JSONSchemaType<T>>,
): FunctionTool<T, JSONValue | Promise<JSONValue>>;
static from<R extends z.ZodType>(
fn: (input: z.infer<R>) => JSONValue | Promise<JSONValue>,
): FunctionTool<T, JSONValue | Promise<JSONValue>, AdditionalToolArgument>;
static from<
R extends z.ZodType,
AdditionalToolArgument extends object = object,
>(
fn: (
input: z.infer<R>,
additionalArg?: AdditionalToolArgument,
) => JSONValue | Promise<JSONValue>,
schema: Omit<ToolMetadata, "parameters"> & {
parameters: R;
},
): FunctionTool<z.infer<R>, JSONValue | Promise<JSONValue>>;
static from<T, R extends z.ZodType<T>>(
fn: (input: T) => JSONValue | Promise<JSONValue>,
): FunctionTool<
z.infer<R>,
JSONValue | Promise<JSONValue>,
AdditionalToolArgument
>;
static from<
T,
R extends z.ZodType<T>,
AdditionalToolArgument extends object = object,
>(
fn: (
input: T,
additionalArg?: AdditionalToolArgument,
) => JSONValue | Promise<JSONValue>,
schema: Omit<ToolMetadata, "parameters"> & {
parameters: R;
},
): FunctionTool<T, JSONValue>;
): FunctionTool<T, JSONValue, AdditionalToolArgument>;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
static from(fn: any, schema: any): any {
if (schema.parameters instanceof z.ZodSchema) {
@@ -58,6 +84,15 @@ export class FunctionTool<T, R extends JSONValue | Promise<JSONValue>>
return this.#metadata as BaseTool<T>["metadata"];
}
bind = (additionalArg: AdditionalToolArgument) => {
return new FunctionTool(
this.#fn,
this.#metadata,
this.#zodType ?? undefined,
additionalArg,
);
};
call = (input: T) => {
if (this.#metadata.requireContext) {
const inputWithContext = input as Record<string, unknown>;
@@ -72,15 +107,18 @@ export class FunctionTool<T, R extends JSONValue | Promise<JSONValue>>
if (result.success) {
if (this.#metadata.requireContext) {
const { context } = input as Record<string, unknown>;
return this.#fn.call(null, { context, ...result.data });
return this.#fn.call(
null,
{ context, ...result.data },
this.#additionalArg,
);
} else {
return this.#fn.call(null, result.data);
return this.#fn.call(null, result.data, this.#additionalArg);
}
} else {
console.warn(result.error.errors);
}
}
return this.#fn.call(null, input);
return this.#fn.call(null, input, this.#additionalArg);
};
}
+35 -1
View File
@@ -1,5 +1,5 @@
import { FunctionTool } from "@llamaindex/core/tools";
import { describe, test } from "vitest";
import { describe, expect, test, vi } from "vitest";
import { z } from "zod";
describe("FunctionTool", () => {
@@ -32,4 +32,38 @@ describe("FunctionTool", () => {
parameters: inputSchema,
});
});
test("bind additional argument", () => {
type AdditionalHelloArgument = {
question?: string;
};
const hello = vi
.fn()
.mockImplementation((name: string, arg?: AdditionalHelloArgument) => {
return `Hello ${name}. ${arg?.question ?? ""}`;
});
const helloTool = FunctionTool.from<string, AdditionalHelloArgument>(
hello,
{
name: "hello",
description: "Says hello",
},
);
helloTool.call("Alice");
expect(hello).to.toHaveBeenCalledOnce();
expect(hello).to.toHaveBeenCalledWith("Alice", undefined);
hello.mockReset();
const additionalArg = {
question: "How is it going?",
};
const helloBoundTool = helloTool.bind(additionalArg);
helloBoundTool.call("Bob");
expect(hello).to.toHaveBeenCalledOnce();
expect(hello).to.toHaveBeenCalledWith("Bob", additionalArg);
});
});
+6
View File
@@ -1,5 +1,11 @@
# @llamaindex/experimental
## 0.0.159
### Patch Changes
- llamaindex@0.9.9
## 0.0.158
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/experimental",
"description": "Experimental package for LlamaIndexTS",
"version": "0.0.158",
"version": "0.0.159",
"type": "module",
"types": "dist/type/index.d.ts",
"main": "dist/cjs/index.js",
+11
View File
@@ -1,5 +1,16 @@
# llamaindex
## 0.9.9
### Patch Changes
- Updated dependencies [4bac71d]
- @llamaindex/core@0.5.7
- @llamaindex/cloud@3.0.8
- @llamaindex/node-parser@1.0.7
- @llamaindex/openai@0.1.59
- @llamaindex/workflow@0.0.15
## 0.9.8
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "llamaindex",
"version": "0.9.8",
"version": "0.9.9",
"license": "MIT",
"type": "module",
"keywords": [
+7
View File
@@ -1,5 +1,12 @@
# @llamaindex/node-parser
## 1.0.7
### Patch Changes
- Updated dependencies [4bac71d]
- @llamaindex/core@0.5.7
## 1.0.6
### Patch Changes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@llamaindex/node-parser",
"version": "1.0.6",
"version": "1.0.7",
"description": "Node parser for LlamaIndex",
"type": "module",
"exports": {
@@ -1,5 +1,13 @@
# @llamaindex/anthropic
## 0.2.5
### Patch Changes
- 8bf1ca1: Support chat stream with tools for Anthropic LLM
- Updated dependencies [4bac71d]
- @llamaindex/core@0.5.7
## 0.2.4
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/anthropic",
"description": "Anthropic Adapter for LlamaIndex",
"version": "0.2.4",
"version": "0.2.5",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
+51 -10
View File
@@ -13,7 +13,7 @@ import type {
Tool,
ToolUseBlock,
} from "@anthropic-ai/sdk/resources/messages";
import { wrapLLMEvent } from "@llamaindex/core/decorator";
import { wrapEventCaller, wrapLLMEvent } from "@llamaindex/core/decorator";
import type { JSONObject } from "@llamaindex/core/global";
import type {
BaseTool,
@@ -22,6 +22,7 @@ import type {
ChatResponseChunk,
LLMChatParamsNonStreaming,
LLMChatParamsStreaming,
PartialToolCall,
ToolCallLLMMessageOptions,
} from "@llamaindex/core/llms";
import { ToolCallLLM } from "@llamaindex/core/llms";
@@ -378,6 +379,7 @@ export class Anthropic extends ToolCallLLM<
AnthropicToolCallLLMMessageOptions
>,
): Promise<ChatResponse<AnthropicToolCallLLMMessageOptions>>;
@wrapEventCaller
@wrapLLMEvent
async chat(
params:
@@ -445,19 +447,16 @@ export class Anthropic extends ToolCallLLM<
),
};
if (stream) {
if (tools) {
console.error("Tools are not supported in streaming mode");
}
return this.streamChat(anthropic, apiParams);
}
if (tools?.length) {
Object.assign(apiParams, {
tools: this.prepareToolsForAPI(tools),
});
}
if (stream) {
return this.streamChat(anthropic, apiParams);
}
const response = await anthropic.messages.create(apiParams);
const toolUseBlock = response.content.filter(
@@ -494,6 +493,7 @@ export class Anthropic extends ToolCallLLM<
};
}
@wrapEventCaller
protected async *streamChat(
anthropic: SDKAnthropic,
params: MessageCreateParams,
@@ -503,7 +503,9 @@ export class Anthropic extends ToolCallLLM<
stream: true,
});
let idx_counter: number = 0;
let currentToolCall: PartialToolCall | null = null;
let accumulatedToolInput = "";
for await (const part of stream) {
const textContent =
part.type === "content_block_delta" && part.delta.type === "text_delta"
@@ -516,9 +518,48 @@ export class Anthropic extends ToolCallLLM<
? part.delta.thinking
: undefined;
if (
part.type === "content_block_start" &&
part.content_block.type === "tool_use"
) {
currentToolCall = {
id: part.content_block.id,
name: part.content_block.name,
input: "",
};
accumulatedToolInput = "";
continue;
}
if (
part.type === "content_block_delta" &&
part.delta.type === "input_json_delta" &&
currentToolCall
) {
accumulatedToolInput += part.delta.partial_json;
continue;
}
if (part.type === "content_block_stop" && currentToolCall) {
yield {
raw: part,
delta: "",
options: {
toolCall: [
{
id: currentToolCall.id,
name: currentToolCall.name,
input: accumulatedToolInput,
},
],
},
};
currentToolCall = null;
continue;
}
if (!textContent && !thinking) continue;
idx_counter++;
yield {
raw: part,
delta: textContent ?? "",
+8
View File
@@ -1,5 +1,13 @@
# @llamaindex/clip
## 0.0.43
### Patch Changes
- Updated dependencies [4bac71d]
- @llamaindex/core@0.5.7
- @llamaindex/openai@0.1.59
## 0.0.42
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/clip",
"description": "Clip Embedding Adapter for LlamaIndex",
"version": "0.0.42",
"version": "0.0.43",
"type": "module",
"types": "dist/index.d.ts",
"main": "dist/index.cjs",
+7
View File
@@ -1,5 +1,12 @@
# @llamaindex/cohere
## 0.0.12
### Patch Changes
- Updated dependencies [4bac71d]
- @llamaindex/core@0.5.7
## 0.0.11
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/cohere",
"description": "Cohere Adapter for LlamaIndex",
"version": "0.0.11",
"version": "0.0.12",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
@@ -1,5 +1,13 @@
# @llamaindex/deepinfra
## 0.0.43
### Patch Changes
- Updated dependencies [4bac71d]
- @llamaindex/core@0.5.7
- @llamaindex/openai@0.1.59
## 0.0.42
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/deepinfra",
"description": "Deepinfra Adapter for LlamaIndex",
"version": "0.0.42",
"version": "0.0.43",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
+6
View File
@@ -1,5 +1,11 @@
# @llamaindex/deepseek
## 0.0.3
### Patch Changes
- @llamaindex/openai@0.1.59
## 0.0.2
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/deepseek",
"description": "DeepSeek Adapter for LlamaIndex",
"version": "0.0.2",
"version": "0.0.3",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
@@ -1,5 +1,11 @@
# @llamaindex/fireworks
## 0.0.3
### Patch Changes
- @llamaindex/openai@0.1.59
## 0.0.2
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/fireworks",
"description": "Fireworks Adapter for LlamaIndex",
"version": "0.0.2",
"version": "0.0.3",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
+11
View File
@@ -1,5 +1,16 @@
# @llamaindex/google
## 0.1.0
### Minor Changes
- 58b3ee5: google vertex ai don't support empty functionDeclarations array. You must pass an empty array to LLMAgent if you don't have tools so Gemini was no able to use it in agent mode. Also Gemini 2.0 flash lite was added to model list.
### Patch Changes
- Updated dependencies [4bac71d]
- @llamaindex/core@0.5.7
## 0.0.14
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/google",
"description": "Google Adapter for LlamaIndex",
"version": "0.0.14",
"version": "0.1.0",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
+20 -17
View File
@@ -56,6 +56,7 @@ export const GEMINI_MODEL_INFO_MAP: Record<GEMINI_MODEL, GeminiModelInfo> = {
[GEMINI_MODEL.GEMINI_2_0_FLASH_EXPERIMENTAL]: { contextWindow: 10 ** 6 },
[GEMINI_MODEL.GEMINI_2_0_FLASH]: { contextWindow: 10 ** 6 },
[GEMINI_MODEL.GEMINI_2_0_FLASH_LITE_PREVIEW]: { contextWindow: 10 ** 6 },
[GEMINI_MODEL.GEMINI_2_0_FLASH_LITE]: { contextWindow: 10 ** 6 },
[GEMINI_MODEL.GEMINI_2_0_FLASH_THINKING_EXP]: { contextWindow: 32768 },
[GEMINI_MODEL.GEMINI_2_0_PRO_EXPERIMENTAL]: { contextWindow: 2 * 10 ** 6 },
};
@@ -278,24 +279,26 @@ export class Gemini extends ToolCallLLM<GeminiAdditionalChatOptions> {
): GeminiChatStreamResponse {
const context = getChatContext(params);
const client = this.session.getGenerativeModel(this.metadata);
const chat = client.startChat(
params.tools
? {
history: context.history,
tools: [
{
functionDeclarations: params.tools.map(
mapBaseToolToGeminiFunctionDeclaration,
),
},
],
safetySettings: DEFAULT_SAFETY_SETTINGS,
}
: {
history: context.history,
safetySettings: DEFAULT_SAFETY_SETTINGS,
const tools = params.tools?.length
? [
{
functionDeclarations: params.tools.map(
mapBaseToolToGeminiFunctionDeclaration,
),
},
);
]
: [];
const startChatParams = params.tools
? {
history: context.history,
tools,
safetySettings: DEFAULT_SAFETY_SETTINGS,
}
: {
history: context.history,
safetySettings: DEFAULT_SAFETY_SETTINGS,
};
const chat = client.startChat(startChatParams);
const result = await chat.sendMessageStream(context.message);
yield* this.session.getChatStream(result);
}
+1
View File
@@ -66,6 +66,7 @@ export enum GEMINI_MODEL {
GEMINI_PRO_1_5_FLASH_LATEST = "gemini-1.5-flash-002",
GEMINI_2_0_FLASH_EXPERIMENTAL = "gemini-2.0-flash-exp",
GEMINI_2_0_FLASH = "gemini-2.0-flash-001",
GEMINI_2_0_FLASH_LITE = "gemini-2.0-flash-lite-001",
GEMINI_2_0_FLASH_LITE_PREVIEW = "gemini-2.0-flash-lite-preview-02-05",
GEMINI_2_0_FLASH_THINKING_EXP = "gemini-2.0-flash-thinking-exp-01-21",
GEMINI_2_0_PRO_EXPERIMENTAL = "gemini-2.0-pro-exp-02-05",
+6
View File
@@ -1,5 +1,11 @@
# @llamaindex/groq
## 0.0.58
### Patch Changes
- @llamaindex/openai@0.1.59
## 0.0.57
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/groq",
"description": "Groq Adapter for LlamaIndex",
"version": "0.0.57",
"version": "0.0.58",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
@@ -1,5 +1,13 @@
# @llamaindex/huggingface
## 0.0.43
### Patch Changes
- Updated dependencies [4bac71d]
- @llamaindex/core@0.5.7
- @llamaindex/openai@0.1.59
## 0.0.42
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/huggingface",
"description": "Huggingface Adapter for LlamaIndex",
"version": "0.0.42",
"version": "0.0.43",
"type": "module",
"types": "dist/index.d.ts",
"main": "dist/index.cjs",
+8
View File
@@ -1,5 +1,13 @@
# @llamaindex/jinaai
## 0.0.3
### Patch Changes
- Updated dependencies [4bac71d]
- @llamaindex/core@0.5.7
- @llamaindex/openai@0.1.59
## 0.0.2
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/jinaai",
"description": "JinaAI Adapter for LlamaIndex",
"version": "0.0.2",
"version": "0.0.3",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
+7
View File
@@ -1,5 +1,12 @@
# @llamaindex/mistral
## 0.0.12
### Patch Changes
- Updated dependencies [4bac71d]
- @llamaindex/core@0.5.7
## 0.0.11
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/mistral",
"description": "Mistral Adapter for LlamaIndex",
"version": "0.0.11",
"version": "0.0.12",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
@@ -1,5 +1,12 @@
# @llamaindex/mixedbread
## 0.0.12
### Patch Changes
- Updated dependencies [4bac71d]
- @llamaindex/core@0.5.7
## 0.0.11
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/mixedbread",
"description": "Mixedbread Adapter for LlamaIndex",
"version": "0.0.11",
"version": "0.0.12",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
+7
View File
@@ -1,5 +1,12 @@
# @llamaindex/ollama
## 0.0.47
### Patch Changes
- Updated dependencies [4bac71d]
- @llamaindex/core@0.5.7
## 0.0.46
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/ollama",
"description": "Ollama Adapter for LlamaIndex",
"version": "0.0.46",
"version": "0.0.47",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
+7
View File
@@ -1,5 +1,12 @@
# @llamaindex/openai
## 0.1.59
### Patch Changes
- Updated dependencies [4bac71d]
- @llamaindex/core@0.5.7
## 0.1.58
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/openai",
"description": "OpenAI Adapter for LlamaIndex",
"version": "0.1.58",
"version": "0.1.59",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
@@ -1,5 +1,12 @@
# @llamaindex/portkey-ai
## 0.0.40
### Patch Changes
- Updated dependencies [4bac71d]
- @llamaindex/core@0.5.7
## 0.0.39
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/portkey-ai",
"description": "Portkey Adapter for LlamaIndex",
"version": "0.0.39",
"version": "0.0.40",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
@@ -1,5 +1,12 @@
# @llamaindex/replicate
## 0.0.40
### Patch Changes
- Updated dependencies [4bac71d]
- @llamaindex/core@0.5.7
## 0.0.39
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/replicate",
"description": "Replicate Adapter for LlamaIndex",
"version": "0.0.39",
"version": "0.0.40",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
@@ -1,5 +1,12 @@
# @llamaindex/astra
## 0.0.12
### Patch Changes
- Updated dependencies [4bac71d]
- @llamaindex/core@0.5.7
## 0.0.11
### Patch Changes
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/astra",
"description": "Astra Storage for LlamaIndex",
"version": "0.0.11",
"version": "0.0.12",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
@@ -1,5 +1,12 @@
# @llamaindex/azure
## 0.1.7
### Patch Changes
- Updated dependencies [4bac71d]
- @llamaindex/core@0.5.7
## 0.1.6
### Patch Changes
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/azure",
"description": "Azure Storage for LlamaIndex",
"version": "0.1.6",
"version": "0.1.7",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
@@ -1,5 +1,12 @@
# @llamaindex/chroma
## 0.0.12
### Patch Changes
- Updated dependencies [4bac71d]
- @llamaindex/core@0.5.7
## 0.0.11
### Patch Changes
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/chroma",
"description": "Chroma Storage for LlamaIndex",
"version": "0.0.11",
"version": "0.0.12",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
@@ -1,5 +1,12 @@
# @llamaindex/firestore
## 1.0.5
### Patch Changes
- Updated dependencies [4bac71d]
- @llamaindex/core@0.5.7
## 1.0.4
### Patch Changes
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/firestore",
"description": "Firestore Storage for LlamaIndex",
"version": "1.0.4",
"version": "1.0.5",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
@@ -1,5 +1,12 @@
# @llamaindex/milvus
## 0.1.7
### Patch Changes
- Updated dependencies [4bac71d]
- @llamaindex/core@0.5.7
## 0.1.6
### Patch Changes
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/milvus",
"description": "Milvus Storage for LlamaIndex",
"version": "0.1.6",
"version": "0.1.7",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
@@ -1,5 +1,12 @@
# @llamaindex/mongodb
## 0.0.12
### Patch Changes
- Updated dependencies [4bac71d]
- @llamaindex/core@0.5.7
## 0.0.11
### Patch Changes
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/mongodb",
"description": "MongoDB Storage for LlamaIndex",
"version": "0.0.11",
"version": "0.0.12",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
@@ -1,5 +1,12 @@
# @llamaindex/pinecone
## 0.0.12
### Patch Changes
- Updated dependencies [4bac71d]
- @llamaindex/core@0.5.7
## 0.0.11
### Patch Changes
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/pinecone",
"description": "Pinecone Storage for LlamaIndex",
"version": "0.0.11",
"version": "0.0.12",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
@@ -1,5 +1,12 @@
# @llamaindex/postgres
## 0.0.40
### Patch Changes
- Updated dependencies [4bac71d]
- @llamaindex/core@0.5.7
## 0.0.39
### Patch Changes
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/postgres",
"description": "PostgreSQL Storage for LlamaIndex",
"version": "0.0.39",
"version": "0.0.40",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
@@ -1,5 +1,12 @@
# @llamaindex/qdrant
## 0.1.7
### Patch Changes
- Updated dependencies [4bac71d]
- @llamaindex/core@0.5.7
## 0.1.6
### Patch Changes
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/qdrant",
"description": "Qdrant Storage for LlamaIndex",
"version": "0.1.6",
"version": "0.1.7",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
@@ -1,5 +1,12 @@
# @llamaindex/upstash
## 0.0.12
### Patch Changes
- Updated dependencies [4bac71d]
- @llamaindex/core@0.5.7
## 0.0.11
### Patch Changes
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/upstash",
"description": "Upstash Storage for LlamaIndex",
"version": "0.0.11",
"version": "0.0.12",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
@@ -1,5 +1,12 @@
# @llamaindex/weaviate
## 0.0.12
### Patch Changes
- Updated dependencies [4bac71d]
- @llamaindex/core@0.5.7
## 0.0.11
### Patch Changes
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/weaviate",
"description": "Weaviate Storage for LlamaIndex",
"version": "0.0.11",
"version": "0.0.12",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
+6
View File
@@ -1,5 +1,11 @@
# @llamaindex/together
## 0.0.3
### Patch Changes
- @llamaindex/openai@0.1.59
## 0.0.2
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/together",
"description": "Together Adapter for LlamaIndex",
"version": "0.0.2",
"version": "0.0.3",
"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