Compare commits

..

4 Commits

Author SHA1 Message Date
github-actions[bot] 6fcc6bcb84 Release @llamaindex/anthropic@0.1.2 (#1671)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-02-20 12:56:33 +07:00
Thuc Pham be74207945 fix: dont add empty text block to tool call (#1670) 2025-02-20 12:47:43 +07:00
Alex Yang 6be223dfad chore: bump version (#1668) 2025-02-19 19:28:12 +08:00
Alex Yang 4cbfdb5f5c ci: only run in pull request (#1669) 2025-02-19 19:11:53 +08:00
13 changed files with 720 additions and 744 deletions
+3 -1
View File
@@ -119,6 +119,7 @@ jobs:
size-limit:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
name: Size Limit
steps:
- uses: actions/checkout@v4
@@ -132,12 +133,13 @@ jobs:
run: pnpm install
- name: Build llamaindex
run: pnpm run build
- uses: andresz1/size-limit-action@v1
- uses: andresz1/size-limit-action@94bc357df29c36c8f8d50ea497c3e225c3c95d1d
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
directory: e2e/examples/vite-import-llamaindex
skip_step: "install"
build_script: build
package_manager: pnpm
typecheck-examples:
runs-on: ubuntu-latest
+3 -3
View File
@@ -44,10 +44,10 @@
"hast-util-to-jsx-runtime": "^2.3.2",
"llamaindex": "workspace:*",
"lucide-react": "^0.460.0",
"next": "15.0.3",
"next": "15.1.7",
"next-themes": "^0.4.3",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-icons": "^5.3.0",
"react-monaco-editor": "^0.56.2",
"react-text-transition": "^3.1.0",
+3 -3
View File
@@ -10,9 +10,9 @@
"dependencies": {
"ai": "^4.0.0",
"llamaindex": "workspace:*",
"next": "15.0.3",
"react": "18.3.1",
"react-dom": "18.3.1"
"next": "15.1.7",
"react": "19.0.0",
"react-dom": "19.0.0"
},
"devDependencies": {
"@types/node": "^22.9.0",
@@ -9,7 +9,7 @@
},
"dependencies": {
"llamaindex": "workspace:*",
"next": "15.0.3",
"next": "15.1.7",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
@@ -11,9 +11,9 @@
"llamaindex": "workspace:*",
"@llamaindex/huggingface": "workspace:*",
"@llamaindex/readers": "workspace:*",
"next": "15.0.3",
"react": "18.3.1",
"react-dom": "18.3.1"
"next": "15.1.7",
"react": "19.0.0",
"react-dom": "19.0.0"
},
"devDependencies": {
"@types/node": "^22.9.0",
@@ -5,3 +5,4 @@ dist
.cache
.DS_Store
*.pem
/src/pages.gen.ts
+4 -4
View File
@@ -11,10 +11,10 @@
"dependencies": {
"@llamaindex/env": "workspace:*",
"llamaindex": "workspace:*",
"react": "19.0.0-rc-5c56b873-20241107",
"react-dom": "19.0.0-rc-5c56b873-20241107",
"react-server-dom-webpack": "19.0.0-rc-5c56b873-20241107",
"waku": "0.21.6"
"react": "19.0.0",
"react-dom": "19.0.0",
"react-server-dom-webpack": "19.0.0",
"waku": "0.21.20"
},
"devDependencies": {
"@types/react": "18.3.12",
@@ -15,7 +15,7 @@
"dotenv": "^16.3.1",
"llamaindex": "workspace:*",
"lucide-react": "^0.460.0",
"next": "15.0.3",
"next": "15.1.7",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-markdown": "^9.0.1",
+1 -1
View File
@@ -77,7 +77,7 @@
"@types/node": "^22.9.0",
"bunchee": "6.3.4",
"llamaindex": "workspace:*",
"next": "15.0.3",
"next": "15.1.7",
"rollup": "^4.28.1",
"tsx": "^4.19.0",
"typescript": "^5.7.2",
@@ -1,5 +1,11 @@
# @llamaindex/anthropic
## 0.1.2
### Patch Changes
- be74207: fix: dont add empty text block to tool call
## 0.1.1
### Patch Changes
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "@llamaindex/anthropic",
"description": "Anthropic Adapter for LlamaIndex",
"version": "0.1.1",
"version": "0.1.2",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
+23 -17
View File
@@ -207,23 +207,26 @@ export class Anthropic extends ToolCallLLM<
}
if ("toolCall" in options) {
const formattedMessage: MessageParam = {
role: "assistant",
content: [
{
type: "text" as const,
text: extractText(message.content),
},
...options.toolCall.map((tool) => ({
type: "tool_use" as const,
id: tool.id,
name: tool.name,
input: this.parseToolInput(tool.input),
})),
],
};
const text = extractText(message.content);
return formattedMessage;
const content: MessageParam["content"] = [];
if (text && text.trim().length > 0) {
// don't add empty text blocks
content.push({
type: "text" as const,
text: text,
});
}
content.push(
...options.toolCall.map((tool) => ({
type: "tool_use" as const,
id: tool.id,
name: tool.name,
input: this.parseToolInput(tool.input),
})),
);
return { role: "assistant", content } satisfies MessageParam;
}
// Handle tool results
@@ -442,7 +445,10 @@ export class Anthropic extends ToolCallLLM<
raw: response,
message: {
content: response.content
.filter((content): content is TextBlock => content.type === "text")
.filter(
(content): content is TextBlock =>
content.type === "text" && content.text?.trim().length > 0,
)
.map((content) => ({
type: "text" as const,
text: content.text,
+670 -709
View File
File diff suppressed because it is too large Load Diff