mirror of
https://github.com/run-llama/LlamaIndexTS.git
synced 2026-07-01 22:14:03 -04:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e3f1b85846 | |||
| e38e474f86 | |||
| 2019a041f7 | |||
| 067a4894fe | |||
| 21769c8ad9 |
@@ -1,5 +1,13 @@
|
||||
# @llamaindex/doc
|
||||
|
||||
## 0.0.37
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [2019a04]
|
||||
- @llamaindex/openai@0.1.47
|
||||
- llamaindex@0.8.33
|
||||
|
||||
## 0.0.36
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@llamaindex/doc",
|
||||
"version": "0.0.36",
|
||||
"version": "0.0.37",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "pnpm run build:docs && next build",
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @llamaindex/cloudflare-worker-agent-test
|
||||
|
||||
## 0.0.129
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.8.33
|
||||
|
||||
## 0.0.128
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@llamaindex/cloudflare-worker-agent-test",
|
||||
"version": "0.0.128",
|
||||
"version": "0.0.129",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @llamaindex/next-agent-test
|
||||
|
||||
## 0.1.129
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.8.33
|
||||
|
||||
## 0.1.128
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@llamaindex/next-agent-test",
|
||||
"version": "0.1.128",
|
||||
"version": "0.1.129",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# test-edge-runtime
|
||||
|
||||
## 0.1.128
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.8.33
|
||||
|
||||
## 0.1.127
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@llamaindex/nextjs-edge-runtime-test",
|
||||
"version": "0.1.127",
|
||||
"version": "0.1.128",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @llamaindex/next-node-runtime
|
||||
|
||||
## 0.0.110
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.8.33
|
||||
|
||||
## 0.0.109
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@llamaindex/next-node-runtime-test",
|
||||
"version": "0.0.109",
|
||||
"version": "0.0.110",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @llamaindex/waku-query-engine-test
|
||||
|
||||
## 0.0.129
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.8.33
|
||||
|
||||
## 0.0.128
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@llamaindex/waku-query-engine-test",
|
||||
"version": "0.0.128",
|
||||
"version": "0.0.129",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
# examples
|
||||
|
||||
## 0.1.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 21769c8: Update deprecated response property of query engine to message.content propery
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.8.33
|
||||
|
||||
## 0.0.23
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -33,12 +33,12 @@ async function main() {
|
||||
});
|
||||
|
||||
// Chat with the agent
|
||||
const response = await agent.chat({
|
||||
const { message } = await agent.chat({
|
||||
message: "What was his first salary?",
|
||||
});
|
||||
|
||||
// Print the response
|
||||
console.log(response.response);
|
||||
console.log(message.content);
|
||||
}
|
||||
|
||||
void main().then(() => {
|
||||
|
||||
@@ -52,12 +52,12 @@ async function main() {
|
||||
});
|
||||
|
||||
// Chat with the agent
|
||||
const response = await agent.chat({
|
||||
const { message } = await agent.chat({
|
||||
message: "What was his first salary?",
|
||||
});
|
||||
|
||||
// Print the response
|
||||
console.log(response.response);
|
||||
console.log(message.content);
|
||||
}
|
||||
|
||||
void main().then(() => {
|
||||
|
||||
@@ -38,12 +38,12 @@ const agent = new AnthropicAgent({
|
||||
});
|
||||
|
||||
async function main() {
|
||||
const { response } = await agent.chat({
|
||||
const { message } = await agent.chat({
|
||||
message:
|
||||
"What is the weather in New York? What's the history of New York from Wikipedia in 3 sentences?",
|
||||
});
|
||||
|
||||
console.log(response);
|
||||
console.log(message.content);
|
||||
}
|
||||
|
||||
void main();
|
||||
|
||||
+2
-2
@@ -38,12 +38,12 @@ async function main() {
|
||||
const query = "What is the meaning of life?";
|
||||
|
||||
// Query
|
||||
const response = await queryEngine.query({
|
||||
const { message } = await queryEngine.query({
|
||||
query,
|
||||
});
|
||||
|
||||
// Log the response
|
||||
console.log(response.response);
|
||||
console.log(message.content);
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/examples",
|
||||
"private": true,
|
||||
"version": "0.0.23",
|
||||
"version": "0.1.0",
|
||||
"dependencies": {
|
||||
"@ai-sdk/openai": "^1.0.5",
|
||||
"@aws-crypto/sha256-js": "^5.2.0",
|
||||
@@ -22,7 +22,7 @@
|
||||
"commander": "^12.1.0",
|
||||
"dotenv": "^16.4.5",
|
||||
"js-tiktoken": "^1.0.14",
|
||||
"llamaindex": "^0.8.32",
|
||||
"llamaindex": "^0.8.33",
|
||||
"mongodb": "6.7.0",
|
||||
"pathe": "^1.1.2",
|
||||
"postgres": "^3.4.4",
|
||||
|
||||
@@ -33,19 +33,19 @@ async function main() {
|
||||
retriever,
|
||||
});
|
||||
|
||||
const response = await queryEngine.query({
|
||||
const { message } = await queryEngine.query({
|
||||
query: "What did the author do growing up?",
|
||||
});
|
||||
|
||||
// cohere response
|
||||
console.log(response.response);
|
||||
console.log(message.content);
|
||||
|
||||
const baseResponse = await baseQueryEngine.query({
|
||||
const { message: baseMessage } = await baseQueryEngine.query({
|
||||
query: "What did the author do growing up?",
|
||||
});
|
||||
|
||||
// response without cohere
|
||||
console.log(baseResponse.response);
|
||||
console.log(baseMessage.content);
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
|
||||
@@ -21,12 +21,12 @@ async function main() {
|
||||
|
||||
// Query the index
|
||||
const queryEngine = index.asQueryEngine();
|
||||
const { response, sourceNodes } = await queryEngine.query({
|
||||
const { message, sourceNodes } = await queryEngine.query({
|
||||
query: "What did the author do in college?",
|
||||
});
|
||||
|
||||
// Output response with sources
|
||||
console.log(response);
|
||||
console.log(message.content);
|
||||
|
||||
if (sourceNodes) {
|
||||
sourceNodes.forEach((source: NodeWithScore, index: number) => {
|
||||
|
||||
@@ -29,10 +29,10 @@ async function main() {
|
||||
nodePostprocessor,
|
||||
]);
|
||||
|
||||
const response = await queryEngine.query({
|
||||
const { message } = await queryEngine.query({
|
||||
query: "What did the author do growing up?",
|
||||
});
|
||||
console.log(response.response);
|
||||
console.log(message.content);
|
||||
}
|
||||
|
||||
main().catch(console.error);
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @llamaindex/autotool
|
||||
|
||||
## 5.0.33
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.8.33
|
||||
|
||||
## 5.0.32
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/autotool-01-node-example
|
||||
|
||||
## 0.0.76
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.8.33
|
||||
- @llamaindex/autotool@5.0.33
|
||||
|
||||
## 0.0.75
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -13,5 +13,5 @@
|
||||
"scripts": {
|
||||
"start": "node --import tsx --import @llamaindex/autotool/node ./src/index.ts"
|
||||
},
|
||||
"version": "0.0.75"
|
||||
"version": "0.0.76"
|
||||
}
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/autotool-02-next-example
|
||||
|
||||
## 0.1.120
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.8.33
|
||||
- @llamaindex/autotool@5.0.33
|
||||
|
||||
## 0.1.119
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/autotool-02-next-example",
|
||||
"private": true,
|
||||
"version": "0.1.119",
|
||||
"version": "0.1.120",
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"build": "next build",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/autotool",
|
||||
"type": "module",
|
||||
"version": "5.0.32",
|
||||
"version": "5.0.33",
|
||||
"description": "auto transpile your JS function to LLM Agent compatible",
|
||||
"files": [
|
||||
"dist",
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @llamaindex/experimental
|
||||
|
||||
## 0.0.145
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- llamaindex@0.8.33
|
||||
|
||||
## 0.0.144
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/experimental",
|
||||
"description": "Experimental package for LlamaIndexTS",
|
||||
"version": "0.0.144",
|
||||
"version": "0.0.145",
|
||||
"type": "module",
|
||||
"types": "dist/type/index.d.ts",
|
||||
"main": "dist/cjs/index.js",
|
||||
|
||||
@@ -1,5 +1,21 @@
|
||||
# llamaindex
|
||||
|
||||
## 0.8.33
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [2019a04]
|
||||
- Updated dependencies [e38e474]
|
||||
- Updated dependencies [067a489]
|
||||
- @llamaindex/openai@0.1.47
|
||||
- @llamaindex/google@0.0.3
|
||||
- @llamaindex/anthropic@0.0.31
|
||||
- @llamaindex/clip@0.0.31
|
||||
- @llamaindex/deepinfra@0.0.31
|
||||
- @llamaindex/groq@0.0.46
|
||||
- @llamaindex/huggingface@0.0.31
|
||||
- @llamaindex/vllm@0.0.17
|
||||
|
||||
## 0.8.32
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "llamaindex",
|
||||
"version": "0.8.32",
|
||||
"version": "0.8.33",
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
"keywords": [
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @llamaindex/core-test
|
||||
|
||||
## 0.0.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 067a489: fix: missing condition to stringify tool input
|
||||
|
||||
## 0.0.8
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import type { MessageParam } from "@anthropic-ai/sdk/resources/messages";
|
||||
import { setEnvs } from "@llamaindex/env";
|
||||
import { Anthropic, OpenAI, type ChatMessage } from "llamaindex";
|
||||
import { OpenAI, type ChatMessage } from "llamaindex";
|
||||
import { beforeAll, describe, expect, test } from "vitest";
|
||||
|
||||
beforeAll(() => {
|
||||
@@ -25,32 +24,6 @@ describe("Message Formatting", () => {
|
||||
expect(OpenAI.toOpenAIMessage(inputMessages)).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
test("Anthropic formats basic messages correctly", () => {
|
||||
const anthropic = new Anthropic();
|
||||
const inputMessages: ChatMessage[] = [
|
||||
{
|
||||
content: "You are a helpful assistant.",
|
||||
role: "assistant",
|
||||
},
|
||||
{
|
||||
content: "Hello?",
|
||||
role: "user",
|
||||
},
|
||||
];
|
||||
const expectedOutput: MessageParam[] = [
|
||||
{
|
||||
content: "You are a helpful assistant.",
|
||||
role: "assistant",
|
||||
},
|
||||
{
|
||||
content: "Hello?",
|
||||
role: "user",
|
||||
},
|
||||
];
|
||||
|
||||
expect(anthropic.formatMessages(inputMessages)).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
test("OpenAI handles system messages correctly", () => {
|
||||
const inputMessages: ChatMessage[] = [
|
||||
{ content: "You are a coding assistant", role: "system" },
|
||||
@@ -62,133 +35,6 @@ describe("Message Formatting", () => {
|
||||
];
|
||||
expect(OpenAI.toOpenAIMessage(inputMessages)).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
test("Anthropic handles multi-turn conversation correctly", () => {
|
||||
const anthropic = new Anthropic();
|
||||
const inputMessages: ChatMessage[] = [
|
||||
{ content: "Hi", role: "user" },
|
||||
{ content: "Hello! How can I help?", role: "assistant" },
|
||||
{ content: "What's the weather?", role: "user" },
|
||||
];
|
||||
const expectedOutput: MessageParam[] = [
|
||||
{ content: "Hi", role: "user" },
|
||||
{ content: "Hello! How can I help?", role: "assistant" },
|
||||
{ content: "What's the weather?", role: "user" },
|
||||
];
|
||||
expect(anthropic.formatMessages(inputMessages)).toEqual(expectedOutput);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Advanced Message Formatting", () => {
|
||||
test("Anthropic filters out system messages", () => {
|
||||
const anthropic = new Anthropic();
|
||||
const inputMessages: ChatMessage[] = [
|
||||
{
|
||||
content: "You are a helpful assistant.",
|
||||
role: "assistant",
|
||||
},
|
||||
{
|
||||
content: "Hello?",
|
||||
role: "user",
|
||||
},
|
||||
{
|
||||
content: "I am a system message.",
|
||||
role: "system",
|
||||
},
|
||||
{
|
||||
content: "What is your name?",
|
||||
role: "user",
|
||||
},
|
||||
];
|
||||
const expectedOutput: MessageParam[] = [
|
||||
{
|
||||
content: "You are a helpful assistant.",
|
||||
role: "assistant",
|
||||
},
|
||||
{
|
||||
content: "Hello?\nWhat is your name?",
|
||||
role: "user",
|
||||
},
|
||||
];
|
||||
|
||||
expect(anthropic.formatMessages(inputMessages)).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
test("Anthropic merges consecutive messages from the same role", () => {
|
||||
const anthropic = new Anthropic();
|
||||
const inputMessages: ChatMessage[] = [
|
||||
{
|
||||
content: "Hello?",
|
||||
role: "user",
|
||||
},
|
||||
{
|
||||
content: "How are you?",
|
||||
role: "user",
|
||||
},
|
||||
{
|
||||
content: "I am fine, thank you!",
|
||||
role: "assistant",
|
||||
},
|
||||
{
|
||||
content: "And you?",
|
||||
role: "assistant",
|
||||
},
|
||||
];
|
||||
const expectedOutput: MessageParam[] = [
|
||||
{
|
||||
content: "Hello?\nHow are you?",
|
||||
role: "user",
|
||||
},
|
||||
{
|
||||
content: "I am fine, thank you!\nAnd you?",
|
||||
role: "assistant",
|
||||
},
|
||||
];
|
||||
|
||||
expect(anthropic.formatMessages(inputMessages)).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
test("Anthropic handles image content", () => {
|
||||
const anthropic = new Anthropic();
|
||||
const inputMessages: ChatMessage[] = [
|
||||
{
|
||||
content: [
|
||||
{
|
||||
text: "What do you see in the image?",
|
||||
type: "text",
|
||||
},
|
||||
{
|
||||
type: "image_url",
|
||||
image_url: {
|
||||
url: `data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAQDAwQDAwQEAwQFBAQFBgoHBgYGBg0JCggKDw0QEA8NDw4RExgUERIXEg4PFRwVFxkZGxsbEBQdHx0aHxgaGxr/2wBDAQQFBQYFBgwHBwwaEQ8RGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhr/wAARCAAgACADASIAAhEBAxEB/8QAGAABAAMBAAAAAAAAAAAAAAAACAQHCQb/xAAvEAABAgUCBAUDBQEAAAAAAAACAQMEBQYHERIhAAgTYSIxMkJxI2KCFBVBUVKh/8QAGAEAAwEBAAAAAAAAAAAAAAAAAwQFAQL/xAAnEQABBAECAwkAAAAAAAAAAAACAQMEEQAFMiExYRITFCJBcXKBof/aAAwDAQACEQMRAD8Aufmb5mnbWREFRdvIMZ3cWcaBh2NHUGEFwtIKQp63CX0h+S7YQgRzGSq6kgqGAS8NQRc6fmkIMWwSxJEyP+m0bwggQr5iIom6KnnxXty61jK+uJUVUxzxm/M5g5EASr6G9WGwTsIIIp2FOHJfi0kyvzS9Cv0zGwEF+2whOAUY4a6mnm2lREURLPoTggNG5tS6xpmOT4GQptwNUZc6sbexzcZRVSTKTOgudMPEL0j7E2uQNOxIqcaYcqXNaxe2HKnauBiAraDZ6n0k0tTBpPNwE9pptqDP3DtlBC1Q8qNw5K4AwLEunYkWMwcYg6fnqoH/ADPHA2/qeZWquhJJ3pODmEhmg/qGl2XAloebL5HWK/K8dOMOM7xVPfJrMhmQiq0SFXOlyPc+jIq3lwakpeYNq27K491kfvbzls07ECiSdlThhWKvj1LLx0VVLWGqSBuFJ1jc3WBEUb8K4TUieHz3xni7ea3lSZvZDhUVImxAVtBso39VdLUe0nk2a+0030n+K7YUc95/J66tRIp3SVXUpGyUI7wvPxDBoJ/UaLIuIqtuInRwiiqp4z3XbBYr3cGp9P30zJXiSjk1HLsqdIvxvzV1q8ZtB3ppa5bkwZkDz7LsF09Qxgi0Roa6UUU1LnxYH5JP74D1LUjNrkXigabc6kZM5vPFZi3NPi3dVXnFT+EQUM17IvEi1tL1xUkcEHb+lo6duvRUO644wwSDpaPWgG7sAApIKqqqm4jvxo1yvcrjdoTiqtrQ2I+u5nr19ItbUA2a5IAX3GvuP8U2ypMS5pSwFC5peTtM0lnSkMWVVUJb48a+8//Z`,
|
||||
},
|
||||
},
|
||||
],
|
||||
role: "user",
|
||||
},
|
||||
];
|
||||
const expectedOutput: MessageParam[] = [
|
||||
{
|
||||
role: "user",
|
||||
content: [
|
||||
{
|
||||
type: "text",
|
||||
text: "What do you see in the image?",
|
||||
},
|
||||
{
|
||||
type: "image",
|
||||
source: {
|
||||
type: "base64",
|
||||
media_type: "image/jpeg",
|
||||
data: "/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAQDAwQDAwQEAwQFBAQFBgoHBgYGBg0JCggKDw0QEA8NDw4RExgUERIXEg4PFRwVFxkZGxsbEBQdHx0aHxgaGxr/2wBDAQQFBQYFBgwHBwwaEQ8RGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhr/wAARCAAgACADASIAAhEBAxEB/8QAGAABAAMBAAAAAAAAAAAAAAAACAQHCQb/xAAvEAABAgUCBAUDBQEAAAAAAAACAQMEBQYHERIhAAgTYSIxMkJxI2KCFBVBUVKh/8QAGAEAAwEBAAAAAAAAAAAAAAAAAwQFAQL/xAAnEQABBAECAwkAAAAAAAAAAAACAQMEEQAFMiExYRITFCJBcXKBof/aAAwDAQACEQMRAD8Aufmb5mnbWREFRdvIMZ3cWcaBh2NHUGEFwtIKQp63CX0h+S7YQgRzGSq6kgqGAS8NQRc6fmkIMWwSxJEyP+m0bwggQr5iIom6KnnxXty61jK+uJUVUxzxm/M5g5EASr6G9WGwTsIIIp2FOHJfi0kyvzS9Cv0zGwEF+2whOAUY4a6mnm2lREURLPoTggNG5tS6xpmOT4GQptwNUZc6sbexzcZRVSTKTOgudMPEL0j7E2uQNOxIqcaYcqXNaxe2HKnauBiAraDZ6n0k0tTBpPNwE9pptqDP3DtlBC1Q8qNw5K4AwLEunYkWMwcYg6fnqoH/ADPHA2/qeZWquhJJ3pODmEhmg/qGl2XAloebL5HWK/K8dOMOM7xVPfJrMhmQiq0SFXOlyPc+jIq3lwakpeYNq27K491kfvbzls07ECiSdlThhWKvj1LLx0VVLWGqSBuFJ1jc3WBEUb8K4TUieHz3xni7ea3lSZvZDhUVImxAVtBso39VdLUe0nk2a+0030n+K7YUc95/J66tRIp3SVXUpGyUI7wvPxDBoJ/UaLIuIqtuInRwiiqp4z3XbBYr3cGp9P30zJXiSjk1HLsqdIvxvzV1q8ZtB3ppa5bkwZkDz7LsF09Qxgi0Roa6UUU1LnxYH5JP74D1LUjNrkXigabc6kZM5vPFZi3NPi3dVXnFT+EQUM17IvEi1tL1xUkcEHb+lo6duvRUO644wwSDpaPWgG7sAApIKqqqm4jvxo1yvcrjdoTiqtrQ2I+u5nr19ItbUA2a5IAX3GvuP8U2ypMS5pSwFC5peTtM0lnSkMWVVUJb48a+8//Z",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
expect(anthropic.formatMessages(inputMessages)).toEqual(expectedOutput);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Tool Message Formatting", () => {
|
||||
@@ -251,47 +97,6 @@ describe("Message Formatting", () => {
|
||||
expect(OpenAI.toOpenAIMessage(toolCallMessages)).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
test("Anthropic formats tool calls correctly", () => {
|
||||
const anthropic = new Anthropic();
|
||||
const expectedOutput: MessageParam[] = [
|
||||
{
|
||||
role: "user",
|
||||
content: "What's the weather in London?",
|
||||
},
|
||||
{
|
||||
role: "assistant",
|
||||
content: [
|
||||
{
|
||||
type: "text",
|
||||
text: "Let me check the weather.",
|
||||
},
|
||||
{
|
||||
type: "tool_use",
|
||||
id: "call_123",
|
||||
name: "weather",
|
||||
input: {
|
||||
location: "London",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
role: "user", // anthropic considers all that comes not from their inference API is user role
|
||||
content: [
|
||||
{
|
||||
type: "tool_result",
|
||||
tool_use_id: "call_123",
|
||||
content: "The weather in London is sunny, +20°C",
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
expect(anthropic.formatMessages(toolCallMessages)).toEqual(
|
||||
expectedOutput,
|
||||
);
|
||||
});
|
||||
|
||||
test("OpenAI formats multiple tool calls correctly", () => {
|
||||
const multiToolMessages: ChatMessage[] = [
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/llamaindex-test",
|
||||
"private": true,
|
||||
"version": "0.0.8",
|
||||
"version": "0.0.9",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"test": "vitest run"
|
||||
@@ -16,7 +16,6 @@
|
||||
"dotenv": "^16.4.5",
|
||||
"llamaindex": "workspace:*",
|
||||
"msw": "^2.6.5",
|
||||
"@anthropic-ai/sdk": "0.32.1",
|
||||
"vitest": "^2.1.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @llamaindex/anthropic
|
||||
|
||||
## 0.0.31
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 067a489: fix: missing condition to stringify tool input
|
||||
|
||||
## 0.0.30
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/anthropic",
|
||||
"description": "Anthropic Adapter for LlamaIndex",
|
||||
"version": "0.0.30",
|
||||
"version": "0.0.31",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
@@ -27,7 +27,8 @@
|
||||
},
|
||||
"scripts": {
|
||||
"build": "bunchee",
|
||||
"dev": "bunchee --watch"
|
||||
"dev": "bunchee --watch",
|
||||
"test": "vitest run"
|
||||
},
|
||||
"devDependencies": {
|
||||
"bunchee": "6.2.0"
|
||||
@@ -36,6 +37,7 @@
|
||||
"@anthropic-ai/sdk": "0.32.1",
|
||||
"@llamaindex/core": "workspace:*",
|
||||
"@llamaindex/env": "workspace:*",
|
||||
"remeda": "^2.17.3"
|
||||
"remeda": "^2.17.3",
|
||||
"vitest": "^2.1.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import type {
|
||||
ToolUseBlock,
|
||||
} from "@anthropic-ai/sdk/resources/messages";
|
||||
import { wrapLLMEvent } from "@llamaindex/core/decorator";
|
||||
import type { JSONObject } from "@llamaindex/core/global";
|
||||
import type {
|
||||
BaseTool,
|
||||
ChatMessage,
|
||||
@@ -183,6 +184,18 @@ export class Anthropic extends ToolCallLLM<
|
||||
return model;
|
||||
};
|
||||
|
||||
parseToolInput = (input: string | JSONObject) => {
|
||||
if (typeof input === "object" && !Array.isArray(input)) return input;
|
||||
|
||||
if (typeof input === "string") {
|
||||
const parsed = JSON.parse(input);
|
||||
if (typeof parsed === "object" && !Array.isArray(parsed)) return parsed;
|
||||
}
|
||||
|
||||
console.error("Invalid tool input:", input);
|
||||
throw new Error("Tool input must be a dictionary");
|
||||
};
|
||||
|
||||
formatMessages(
|
||||
messages: ChatMessage<ToolCallLLMMessageOptions>[],
|
||||
): MessageParam[] {
|
||||
@@ -205,10 +218,7 @@ export class Anthropic extends ToolCallLLM<
|
||||
type: "tool_use" as const,
|
||||
id: tool.id,
|
||||
name: tool.name,
|
||||
input:
|
||||
typeof tool.input === "string"
|
||||
? JSON.parse(tool.input)
|
||||
: tool.input,
|
||||
input: this.parseToolInput(tool.input),
|
||||
})),
|
||||
],
|
||||
};
|
||||
@@ -444,7 +454,10 @@ export class Anthropic extends ToolCallLLM<
|
||||
toolCall: toolUseBlock.map((block) => ({
|
||||
id: block.id,
|
||||
name: block.name,
|
||||
input: JSON.stringify(block.input),
|
||||
input:
|
||||
typeof block.input === "string"
|
||||
? block.input
|
||||
: JSON.stringify(block.input),
|
||||
})),
|
||||
}
|
||||
: {},
|
||||
|
||||
@@ -0,0 +1,279 @@
|
||||
import type { MessageParam } from "@anthropic-ai/sdk/resources/messages";
|
||||
import type { ChatMessage } from "@llamaindex/core/llms";
|
||||
import { setEnvs } from "@llamaindex/env";
|
||||
import { beforeAll, describe, expect, test } from "vitest";
|
||||
import { Anthropic } from "../src/index";
|
||||
|
||||
beforeAll(() => {
|
||||
setEnvs({
|
||||
ANTHROPIC_API_KEY: "valid",
|
||||
});
|
||||
});
|
||||
|
||||
describe("Message Formatting", () => {
|
||||
describe("Basic Message Formatting", () => {
|
||||
test("Anthropic formats basic messages correctly", () => {
|
||||
const anthropic = new Anthropic();
|
||||
const inputMessages: ChatMessage[] = [
|
||||
{
|
||||
content: "You are a helpful assistant.",
|
||||
role: "assistant",
|
||||
},
|
||||
{
|
||||
content: "Hello?",
|
||||
role: "user",
|
||||
},
|
||||
];
|
||||
const expectedOutput: MessageParam[] = [
|
||||
{
|
||||
content: "You are a helpful assistant.",
|
||||
role: "assistant",
|
||||
},
|
||||
{
|
||||
content: "Hello?",
|
||||
role: "user",
|
||||
},
|
||||
];
|
||||
|
||||
expect(anthropic.formatMessages(inputMessages)).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
test("Anthropic handles multi-turn conversation correctly", () => {
|
||||
const anthropic = new Anthropic();
|
||||
const inputMessages: ChatMessage[] = [
|
||||
{ content: "Hi", role: "user" },
|
||||
{ content: "Hello! How can I help?", role: "assistant" },
|
||||
{ content: "What's the weather?", role: "user" },
|
||||
];
|
||||
const expectedOutput: MessageParam[] = [
|
||||
{ content: "Hi", role: "user" },
|
||||
{ content: "Hello! How can I help?", role: "assistant" },
|
||||
{ content: "What's the weather?", role: "user" },
|
||||
];
|
||||
expect(anthropic.formatMessages(inputMessages)).toEqual(expectedOutput);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Advanced Message Formatting", () => {
|
||||
test("Anthropic filters out system messages", () => {
|
||||
const anthropic = new Anthropic();
|
||||
const inputMessages: ChatMessage[] = [
|
||||
{
|
||||
content: "You are a helpful assistant.",
|
||||
role: "assistant",
|
||||
},
|
||||
{
|
||||
content: "Hello?",
|
||||
role: "user",
|
||||
},
|
||||
{
|
||||
content: "I am a system message.",
|
||||
role: "system",
|
||||
},
|
||||
{
|
||||
content: "What is your name?",
|
||||
role: "user",
|
||||
},
|
||||
];
|
||||
const expectedOutput: MessageParam[] = [
|
||||
{
|
||||
content: "You are a helpful assistant.",
|
||||
role: "assistant",
|
||||
},
|
||||
{
|
||||
content: "Hello?\nWhat is your name?",
|
||||
role: "user",
|
||||
},
|
||||
];
|
||||
|
||||
expect(anthropic.formatMessages(inputMessages)).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
test("Anthropic merges consecutive messages from the same role", () => {
|
||||
const anthropic = new Anthropic();
|
||||
const inputMessages: ChatMessage[] = [
|
||||
{
|
||||
content: "Hello?",
|
||||
role: "user",
|
||||
},
|
||||
{
|
||||
content: "How are you?",
|
||||
role: "user",
|
||||
},
|
||||
{
|
||||
content: "I am fine, thank you!",
|
||||
role: "assistant",
|
||||
},
|
||||
{
|
||||
content: "And you?",
|
||||
role: "assistant",
|
||||
},
|
||||
];
|
||||
const expectedOutput: MessageParam[] = [
|
||||
{
|
||||
content: "Hello?\nHow are you?",
|
||||
role: "user",
|
||||
},
|
||||
{
|
||||
content: "I am fine, thank you!\nAnd you?",
|
||||
role: "assistant",
|
||||
},
|
||||
];
|
||||
|
||||
expect(anthropic.formatMessages(inputMessages)).toEqual(expectedOutput);
|
||||
});
|
||||
|
||||
test("Anthropic handles image content", () => {
|
||||
const anthropic = new Anthropic();
|
||||
const inputMessages: ChatMessage[] = [
|
||||
{
|
||||
content: [
|
||||
{
|
||||
text: "What do you see in the image?",
|
||||
type: "text",
|
||||
},
|
||||
{
|
||||
type: "image_url",
|
||||
image_url: {
|
||||
url: `data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAQDAwQDAwQEAwQFBAQFBgoHBgYGBg0JCggKDw0QEA8NDw4RExgUERIXEg4PFRwVFxkZGxsbEBQdHx0aHxgaGxr/2wBDAQQFBQYFBgwHBwwaEQ8RGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhr/wAARCAAgACADASIAAhEBAxEB/8QAGAABAAMBAAAAAAAAAAAAAAAACAQHCQb/xAAvEAABAgUCBAUDBQEAAAAAAAACAQMEBQYHERIhAAgTYSIxMkJxI2KCFBVBUVKh/8QAGAEAAwEBAAAAAAAAAAAAAAAAAwQFAQL/xAAnEQABBAECAwkAAAAAAAAAAAACAQMEEQAFMiExYRITFCJBcXKBof/aAAwDAQACEQMRAD8Aufmb5mnbWREFRdvIMZ3cWcaBh2NHUGEFwtIKQp63CX0h+S7YQgRzGSq6kgqGAS8NQRc6fmkIMWwSxJEyP+m0bwggQr5iIom6KnnxXty61jK+uJUVUxzxm/M5g5EASr6G9WGwTsIIIp2FOHJfi0kyvzS9Cv0zGwEF+2whOAUY4a6mnm2lREURLPoTggNG5tS6xpmOT4GQptwNUZc6sbexzcZRVSTKTOgudMPEL0j7E2uQNOxIqcaYcqXNaxe2HKnauBiAraDZ6n0k0tTBpPNwE9pptqDP3DtlBC1Q8qNw5K4AwLEunYkWMwcYg6fnqoH/ADPHA2/qeZWquhJJ3pODmEhmg/qGl2XAloebL5HWK/K8dOMOM7xVPfJrMhmQiq0SFXOlyPc+jIq3lwakpeYNq27K491kfvbzls07ECiSdlThhWKvj1LLx0VVLWGqSBuFJ1jc3WBEUb8K4TUieHz3xni7ea3lSZvZDhUVImxAVtBso39VdLUe0nk2a+0030n+K7YUc95/J66tRIp3SVXUpGyUI7wvPxDBoJ/UaLIuIqtuInRwiiqp4z3XbBYr3cGp9P30zJXiSjk1HLsqdIvxvzV1q8ZtB3ppa5bkwZkDz7LsF09Qxgi0Roa6UUU1LnxYH5JP74D1LUjNrkXigabc6kZM5vPFZi3NPi3dVXnFT+EQUM17IvEi1tL1xUkcEHb+lo6duvRUO644wwSDpaPWgG7sAApIKqqqm4jvxo1yvcrjdoTiqtrQ2I+u5nr19ItbUA2a5IAX3GvuP8U2ypMS5pSwFC5peTtM0lnSkMWVVUJb48a+8//Z`,
|
||||
},
|
||||
},
|
||||
],
|
||||
role: "user",
|
||||
},
|
||||
];
|
||||
const expectedOutput: MessageParam[] = [
|
||||
{
|
||||
role: "user",
|
||||
content: [
|
||||
{
|
||||
type: "text",
|
||||
text: "What do you see in the image?",
|
||||
},
|
||||
{
|
||||
type: "image",
|
||||
source: {
|
||||
type: "base64",
|
||||
media_type: "image/jpeg",
|
||||
data: "/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAQDAwQDAwQEAwQFBAQFBgoHBgYGBg0JCggKDw0QEA8NDw4RExgUERIXEg4PFRwVFxkZGxsbEBQdHx0aHxgaGxr/2wBDAQQFBQYFBgwHBwwaEQ8RGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhr/wAARCAAgACADASIAAhEBAxEB/8QAGAABAAMBAAAAAAAAAAAAAAAACAQHCQb/xAAvEAABAgUCBAUDBQEAAAAAAAACAQMEBQYHERIhAAgTYSIxMkJxI2KCFBVBUVKh/8QAGAEAAwEBAAAAAAAAAAAAAAAAAwQFAQL/xAAnEQABBAECAwkAAAAAAAAAAAACAQMEEQAFMiExYRITFCJBcXKBof/aAAwDAQACEQMRAD8Aufmb5mnbWREFRdvIMZ3cWcaBh2NHUGEFwtIKQp63CX0h+S7YQgRzGSq6kgqGAS8NQRc6fmkIMWwSxJEyP+m0bwggQr5iIom6KnnxXty61jK+uJUVUxzxm/M5g5EASr6G9WGwTsIIIp2FOHJfi0kyvzS9Cv0zGwEF+2whOAUY4a6mnm2lREURLPoTggNG5tS6xpmOT4GQptwNUZc6sbexzcZRVSTKTOgudMPEL0j7E2uQNOxIqcaYcqXNaxe2HKnauBiAraDZ6n0k0tTBpPNwE9pptqDP3DtlBC1Q8qNw5K4AwLEunYkWMwcYg6fnqoH/ADPHA2/qeZWquhJJ3pODmEhmg/qGl2XAloebL5HWK/K8dOMOM7xVPfJrMhmQiq0SFXOlyPc+jIq3lwakpeYNq27K491kfvbzls07ECiSdlThhWKvj1LLx0VVLWGqSBuFJ1jc3WBEUb8K4TUieHz3xni7ea3lSZvZDhUVImxAVtBso39VdLUe0nk2a+0030n+K7YUc95/J66tRIp3SVXUpGyUI7wvPxDBoJ/UaLIuIqtuInRwiiqp4z3XbBYr3cGp9P30zJXiSjk1HLsqdIvxvzV1q8ZtB3ppa5bkwZkDz7LsF09Qxgi0Roa6UUU1LnxYH5JP74D1LUjNrkXigabc6kZM5vPFZi3NPi3dVXnFT+EQUM17IvEi1tL1xUkcEHb+lo6duvRUO644wwSDpaPWgG7sAApIKqqqm4jvxo1yvcrjdoTiqtrQ2I+u5nr19ItbUA2a5IAX3GvuP8U2ypMS5pSwFC5peTtM0lnSkMWVVUJb48a+8//Z",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
expect(anthropic.formatMessages(inputMessages)).toEqual(expectedOutput);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Tool Message Formatting", () => {
|
||||
const toolCallMessages: ChatMessage[] = [
|
||||
{
|
||||
role: "user",
|
||||
content: "What's the weather in London?",
|
||||
},
|
||||
{
|
||||
role: "assistant",
|
||||
content: "Let me check the weather.",
|
||||
options: {
|
||||
toolCall: [
|
||||
{
|
||||
id: "call_123",
|
||||
name: "weather",
|
||||
input: JSON.stringify({ location: "London" }),
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
role: "assistant",
|
||||
content: "The weather in London is sunny, +20°C",
|
||||
options: {
|
||||
toolResult: {
|
||||
id: "call_123",
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
test("Anthropic formats tool calls correctly", () => {
|
||||
const anthropic = new Anthropic();
|
||||
const expectedOutput: MessageParam[] = [
|
||||
{
|
||||
role: "user",
|
||||
content: "What's the weather in London?",
|
||||
},
|
||||
{
|
||||
role: "assistant",
|
||||
content: [
|
||||
{
|
||||
type: "text",
|
||||
text: "Let me check the weather.",
|
||||
},
|
||||
{
|
||||
type: "tool_use",
|
||||
id: "call_123",
|
||||
name: "weather",
|
||||
input: {
|
||||
location: "London",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
role: "user", // anthropic considers all that comes not from their inference API is user role
|
||||
content: [
|
||||
{
|
||||
type: "tool_result",
|
||||
tool_use_id: "call_123",
|
||||
content: "The weather in London is sunny, +20°C",
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
expect(anthropic.formatMessages(toolCallMessages)).toEqual(
|
||||
expectedOutput,
|
||||
);
|
||||
});
|
||||
|
||||
test("Anthropic throws error for invalid tool input", () => {
|
||||
const anthropic = new Anthropic();
|
||||
const invalidToolMessages: ChatMessage[] = [
|
||||
{
|
||||
role: "assistant",
|
||||
content: "Let me check that for you",
|
||||
options: {
|
||||
toolCall: [
|
||||
{
|
||||
id: "toolu_123",
|
||||
name: "search_tool",
|
||||
input: '"{\\"query\\":\\"test\\"}}"', // Invalid JSON string
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
expect(() => anthropic.formatMessages(invalidToolMessages)).toThrow();
|
||||
|
||||
const stringToolMessages: ChatMessage[] = [
|
||||
{
|
||||
role: "assistant",
|
||||
content: "Let me check that for you",
|
||||
options: {
|
||||
toolCall: [
|
||||
{
|
||||
id: "toolu_123",
|
||||
name: "search_tool",
|
||||
input: "not a json string",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
expect(() => anthropic.formatMessages(stringToolMessages)).toThrow();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/clip
|
||||
|
||||
## 0.0.31
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [2019a04]
|
||||
- @llamaindex/openai@0.1.47
|
||||
|
||||
## 0.0.30
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/clip",
|
||||
"description": "Clip Embedding Adapter for LlamaIndex",
|
||||
"version": "0.0.30",
|
||||
"version": "0.0.31",
|
||||
"type": "module",
|
||||
"types": "dist/index.d.ts",
|
||||
"main": "dist/index.cjs",
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/deepinfra
|
||||
|
||||
## 0.0.31
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [2019a04]
|
||||
- @llamaindex/openai@0.1.47
|
||||
|
||||
## 0.0.30
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/deepinfra",
|
||||
"description": "Deepinfra Adapter for LlamaIndex",
|
||||
"version": "0.0.30",
|
||||
"version": "0.0.31",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @llamaindex/google
|
||||
|
||||
## 0.0.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- e38e474: Add Gemini 2.0 models
|
||||
|
||||
## 0.0.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/google",
|
||||
"description": "Google Adapter for LlamaIndex",
|
||||
"version": "0.0.2",
|
||||
"version": "0.0.3",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
@@ -54,6 +54,9 @@ export const GEMINI_MODEL_INFO_MAP: Record<GEMINI_MODEL, GeminiModelInfo> = {
|
||||
[GEMINI_MODEL.GEMINI_PRO_1_5_LATEST]: { contextWindow: 2 * 10 ** 6 },
|
||||
[GEMINI_MODEL.GEMINI_PRO_1_5_FLASH_LATEST]: { contextWindow: 10 ** 6 },
|
||||
[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_THINKING_EXP]: { contextWindow: 32768 },
|
||||
};
|
||||
|
||||
const SUPPORT_TOOL_CALL_MODELS: GEMINI_MODEL[] = [
|
||||
@@ -68,6 +71,7 @@ const SUPPORT_TOOL_CALL_MODELS: GEMINI_MODEL[] = [
|
||||
GEMINI_MODEL.GEMINI_PRO_1_5_LATEST,
|
||||
GEMINI_MODEL.GEMINI_PRO_1_5_FLASH_LATEST,
|
||||
GEMINI_MODEL.GEMINI_2_0_FLASH_EXPERIMENTAL,
|
||||
GEMINI_MODEL.GEMINI_2_0_FLASH,
|
||||
];
|
||||
|
||||
const DEFAULT_GEMINI_PARAMS = {
|
||||
|
||||
@@ -65,6 +65,9 @@ export enum GEMINI_MODEL {
|
||||
GEMINI_PRO_1_5_LATEST = "gemini-1.5-pro-002",
|
||||
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_PREVIEW = "gemini-2.0-flash-lite-preview-02-05",
|
||||
GEMINI_2_0_FLASH_THINKING_EXP = "gemini-2.0-flash-thinking-exp-01-21",
|
||||
}
|
||||
|
||||
export interface GeminiModelInfo {
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/groq
|
||||
|
||||
## 0.0.46
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [2019a04]
|
||||
- @llamaindex/openai@0.1.47
|
||||
|
||||
## 0.0.45
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/groq",
|
||||
"description": "Groq Adapter for LlamaIndex",
|
||||
"version": "0.0.45",
|
||||
"version": "0.0.46",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/huggingface
|
||||
|
||||
## 0.0.31
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [2019a04]
|
||||
- @llamaindex/openai@0.1.47
|
||||
|
||||
## 0.0.30
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/huggingface",
|
||||
"description": "Huggingface Adapter for LlamaIndex",
|
||||
"version": "0.0.30",
|
||||
"version": "0.0.31",
|
||||
"type": "module",
|
||||
"types": "dist/index.d.ts",
|
||||
"main": "dist/index.cjs",
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# @llamaindex/openai
|
||||
|
||||
## 0.1.47
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 2019a04: fix: remove temp for o3-mini
|
||||
|
||||
## 0.1.46
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/openai",
|
||||
"description": "OpenAI Adapter for LlamaIndex",
|
||||
"version": "0.1.46",
|
||||
"version": "0.1.47",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
@@ -140,6 +140,10 @@ export function isFunctionCallingModel(llm: LLM): llm is OpenAI {
|
||||
return isChatModel && !isOld && !isO1;
|
||||
}
|
||||
|
||||
export function isTemperatureSupported(model: ChatModel | string): boolean {
|
||||
return !model.startsWith("o3");
|
||||
}
|
||||
|
||||
export type OpenAIAdditionalMetadata = object;
|
||||
|
||||
export type OpenAIAdditionalChatOptions = Omit<
|
||||
@@ -349,7 +353,7 @@ export class OpenAI extends ToolCallLLM<OpenAIAdditionalChatOptions> {
|
||||
const { messages, stream, tools, additionalChatOptions } = params;
|
||||
const baseRequestParams = <OpenAILLM.Chat.ChatCompletionCreateParams>{
|
||||
model: this.model,
|
||||
temperature: this.temperature,
|
||||
temperature: isTemperatureSupported(this.model) ? this.temperature : null,
|
||||
max_tokens: this.maxTokens,
|
||||
tools: tools?.map(OpenAI.toTool),
|
||||
messages: OpenAI.toOpenAIMessage(messages),
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# @llamaindex/vllm
|
||||
|
||||
## 0.0.17
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [2019a04]
|
||||
- @llamaindex/openai@0.1.47
|
||||
|
||||
## 0.0.16
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/vllm",
|
||||
"description": "vLLM Adapter for LlamaIndex",
|
||||
"version": "0.0.16",
|
||||
"version": "0.0.17",
|
||||
"type": "module",
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.js",
|
||||
|
||||
Generated
+8
-49
@@ -596,7 +596,7 @@ importers:
|
||||
specifier: ^1.0.14
|
||||
version: 1.0.14
|
||||
llamaindex:
|
||||
specifier: ^0.8.32
|
||||
specifier: ^0.8.33
|
||||
version: link:../packages/llamaindex
|
||||
mongodb:
|
||||
specifier: 6.7.0
|
||||
@@ -1059,9 +1059,6 @@ importers:
|
||||
|
||||
packages/llamaindex/tests:
|
||||
devDependencies:
|
||||
'@anthropic-ai/sdk':
|
||||
specifier: 0.32.1
|
||||
version: 0.32.1(encoding@0.1.13)
|
||||
'@azure/cosmos':
|
||||
specifier: ^4.1.1
|
||||
version: 4.1.1
|
||||
@@ -1135,6 +1132,9 @@ importers:
|
||||
remeda:
|
||||
specifier: ^2.17.3
|
||||
version: 2.17.3
|
||||
vitest:
|
||||
specifier: ^2.1.5
|
||||
version: 2.1.5(@edge-runtime/vm@4.0.4)(@types/node@22.9.0)(happy-dom@15.11.6)(msw@2.6.5(@types/node@22.9.0)(typescript@5.7.2))(terser@5.37.0)
|
||||
devDependencies:
|
||||
bunchee:
|
||||
specifier: 6.2.0
|
||||
@@ -11645,37 +11645,6 @@ packages:
|
||||
terser:
|
||||
optional: true
|
||||
|
||||
vite@5.4.11:
|
||||
resolution: {integrity: sha512-c7jFQRklXua0mTzneGW9QVyxFjUgwcihC4bXEtujIo2ouWCe1Ajt/amn2PCxYnhYfd5k09JX3SB7OYWFKYqj8Q==}
|
||||
engines: {node: ^18.0.0 || >=20.0.0}
|
||||
hasBin: true
|
||||
peerDependencies:
|
||||
'@types/node': ^18.0.0 || >=20.0.0
|
||||
less: '*'
|
||||
lightningcss: ^1.21.0
|
||||
sass: '*'
|
||||
sass-embedded: '*'
|
||||
stylus: '*'
|
||||
sugarss: '*'
|
||||
terser: ^5.4.0
|
||||
peerDependenciesMeta:
|
||||
'@types/node':
|
||||
optional: true
|
||||
less:
|
||||
optional: true
|
||||
lightningcss:
|
||||
optional: true
|
||||
sass:
|
||||
optional: true
|
||||
sass-embedded:
|
||||
optional: true
|
||||
stylus:
|
||||
optional: true
|
||||
sugarss:
|
||||
optional: true
|
||||
terser:
|
||||
optional: true
|
||||
|
||||
vite@5.4.12:
|
||||
resolution: {integrity: sha512-KwUaKB27TvWwDJr1GjjWthLMATbGEbeWYZIbGZ5qFIsgPP3vWzLu4cVooqhm5/Z2SPDUMjyPVjTztm5tYKwQxA==}
|
||||
engines: {node: ^18.0.0 || >=20.0.0}
|
||||
@@ -16470,14 +16439,14 @@ snapshots:
|
||||
chai: 5.1.2
|
||||
tinyrainbow: 1.2.0
|
||||
|
||||
'@vitest/mocker@2.1.5(msw@2.6.5(@types/node@22.9.0)(typescript@5.7.2))(vite@5.4.11(@types/node@22.9.0)(terser@5.37.0))':
|
||||
'@vitest/mocker@2.1.5(msw@2.6.5(@types/node@22.9.0)(typescript@5.7.2))(vite@5.4.12(@types/node@22.9.0)(terser@5.37.0))':
|
||||
dependencies:
|
||||
'@vitest/spy': 2.1.5
|
||||
estree-walker: 3.0.3
|
||||
magic-string: 0.30.17
|
||||
optionalDependencies:
|
||||
msw: 2.6.5(@types/node@22.9.0)(typescript@5.7.2)
|
||||
vite: 5.4.11(@types/node@22.9.0)(terser@5.37.0)
|
||||
vite: 5.4.12(@types/node@22.9.0)(terser@5.37.0)
|
||||
|
||||
'@vitest/pretty-format@2.1.5':
|
||||
dependencies:
|
||||
@@ -24301,16 +24270,6 @@ snapshots:
|
||||
fsevents: 2.3.3
|
||||
terser: 5.37.0
|
||||
|
||||
vite@5.4.11(@types/node@22.9.0)(terser@5.37.0):
|
||||
dependencies:
|
||||
esbuild: 0.21.5
|
||||
postcss: 8.5.1
|
||||
rollup: 4.34.1
|
||||
optionalDependencies:
|
||||
'@types/node': 22.9.0
|
||||
fsevents: 2.3.3
|
||||
terser: 5.37.0
|
||||
|
||||
vite@5.4.12(@types/node@22.9.0)(terser@5.37.0):
|
||||
dependencies:
|
||||
esbuild: 0.21.5
|
||||
@@ -24324,7 +24283,7 @@ snapshots:
|
||||
vitest@2.1.5(@edge-runtime/vm@4.0.4)(@types/node@22.9.0)(happy-dom@15.11.6)(msw@2.6.5(@types/node@22.9.0)(typescript@5.7.2))(terser@5.37.0):
|
||||
dependencies:
|
||||
'@vitest/expect': 2.1.5
|
||||
'@vitest/mocker': 2.1.5(msw@2.6.5(@types/node@22.9.0)(typescript@5.7.2))(vite@5.4.11(@types/node@22.9.0)(terser@5.37.0))
|
||||
'@vitest/mocker': 2.1.5(msw@2.6.5(@types/node@22.9.0)(typescript@5.7.2))(vite@5.4.12(@types/node@22.9.0)(terser@5.37.0))
|
||||
'@vitest/pretty-format': 2.1.8
|
||||
'@vitest/runner': 2.1.5
|
||||
'@vitest/snapshot': 2.1.5
|
||||
@@ -24340,7 +24299,7 @@ snapshots:
|
||||
tinyexec: 0.3.1
|
||||
tinypool: 1.0.2
|
||||
tinyrainbow: 1.2.0
|
||||
vite: 5.4.11(@types/node@22.9.0)(terser@5.37.0)
|
||||
vite: 5.4.12(@types/node@22.9.0)(terser@5.37.0)
|
||||
vite-node: 2.1.5(@types/node@22.9.0)(terser@5.37.0)
|
||||
why-is-node-running: 2.3.0
|
||||
optionalDependencies:
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
# @llamaindex/unit-test
|
||||
|
||||
## 0.0.43
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [2019a04]
|
||||
- @llamaindex/openai@0.1.47
|
||||
- llamaindex@0.8.33
|
||||
|
||||
## 0.0.42
|
||||
|
||||
### Patch Changes
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@llamaindex/unit-test",
|
||||
"private": true,
|
||||
"version": "0.0.42",
|
||||
"version": "0.0.43",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"test": "vitest run"
|
||||
|
||||
Reference in New Issue
Block a user