Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add tool call history support in chat messages #1565

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

erik-balfe
Copy link
Contributor

@erik-balfe erik-balfe commented Dec 12, 2024

Add proper message format transformation for tool calls and results in chat history when using Anthropic agent. This allows Anthropic agent to handle tool history consistently with OpenAI agent, which already had this functionality.

Previously, chat history with tool calls would cause API errors with Anthropic but worked fine with OpenAI. Now both agents handle the same message format correctly.
Closes #1564

Copy link

changeset-bot bot commented Dec 12, 2024

🦋 Changeset detected

Latest commit: c81e9a5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 30 packages
Name Type
@llamaindex/anthropic Patch
llamaindex Patch
@llamaindex/core Patch
@llamaindex/unit-test Patch
docs Patch
@llamaindex/doc Patch
@llamaindex/cloudflare-worker-agent-test Patch
@llamaindex/next-agent-test Patch
@llamaindex/nextjs-edge-runtime-test Patch
@llamaindex/next-node-runtime-test Patch
@llamaindex/waku-query-engine-test Patch
@llamaindex/autotool Patch
@llamaindex/experimental Patch
@llamaindex/autotool-01-node-example Patch
@llamaindex/autotool-02-next-example Patch
@llamaindex/cloud Patch
@llamaindex/community Patch
@llamaindex/node-parser Patch
@llamaindex/readers Patch
@llamaindex/clip Patch
@llamaindex/deepinfra Patch
@llamaindex/huggingface Patch
@llamaindex/ollama Patch
@llamaindex/openai Patch
@llamaindex/portkey-ai Patch
@llamaindex/replicate Patch
@llamaindex/vercel Patch
@llamaindex/llama-parse-browser-test Patch
@llamaindex/groq Patch
@llamaindex/vllm Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Dec 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
legacy-llama-index-ts-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 13, 2024 11:47am
llamaindex-ts-doc ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 13, 2024 11:47am

Copy link

vercel bot commented Dec 12, 2024

@erik-balfe is attempting to deploy a commit to the LlamaIndex Team on Vercel.

A member of the Team first needs to authorize it.

@erik-balfe erik-balfe changed the title add tool call history support in chat messages (1564) add tool call history support in chat messages (#1564) Dec 12, 2024
Copy link

pkg-pr-new bot commented Dec 12, 2024

Open in Stackblitz

@llamaindex/autotool

npm i https://pkg.pr.new/run-llama/LlamaIndexTS/@llamaindex/autotool@1565

@llamaindex/cloud

npm i https://pkg.pr.new/run-llama/LlamaIndexTS/@llamaindex/cloud@1565

@llamaindex/community

npm i https://pkg.pr.new/run-llama/LlamaIndexTS/@llamaindex/community@1565

@llamaindex/core

npm i https://pkg.pr.new/run-llama/LlamaIndexTS/@llamaindex/core@1565

@llamaindex/experimental

npm i https://pkg.pr.new/run-llama/LlamaIndexTS/@llamaindex/experimental@1565

llamaindex

npm i https://pkg.pr.new/run-llama/LlamaIndexTS/llamaindex@1565

@llamaindex/env

npm i https://pkg.pr.new/run-llama/LlamaIndexTS/@llamaindex/env@1565

@llamaindex/node-parser

npm i https://pkg.pr.new/run-llama/LlamaIndexTS/@llamaindex/node-parser@1565

@llamaindex/readers

npm i https://pkg.pr.new/run-llama/LlamaIndexTS/@llamaindex/readers@1565

@llamaindex/wasm-tools

npm i https://pkg.pr.new/run-llama/LlamaIndexTS/@llamaindex/wasm-tools@1565

@llamaindex/workflow

npm i https://pkg.pr.new/run-llama/LlamaIndexTS/@llamaindex/workflow@1565

@llamaindex/anthropic

npm i https://pkg.pr.new/run-llama/LlamaIndexTS/@llamaindex/anthropic@1565

@llamaindex/clip

npm i https://pkg.pr.new/run-llama/LlamaIndexTS/@llamaindex/clip@1565

@llamaindex/deepinfra

npm i https://pkg.pr.new/run-llama/LlamaIndexTS/@llamaindex/deepinfra@1565

@llamaindex/groq

npm i https://pkg.pr.new/run-llama/LlamaIndexTS/@llamaindex/groq@1565

@llamaindex/huggingface

npm i https://pkg.pr.new/run-llama/LlamaIndexTS/@llamaindex/huggingface@1565

@llamaindex/ollama

npm i https://pkg.pr.new/run-llama/LlamaIndexTS/@llamaindex/ollama@1565

@llamaindex/openai

npm i https://pkg.pr.new/run-llama/LlamaIndexTS/@llamaindex/openai@1565

@llamaindex/portkey-ai

npm i https://pkg.pr.new/run-llama/LlamaIndexTS/@llamaindex/portkey-ai@1565

@llamaindex/replicate

npm i https://pkg.pr.new/run-llama/LlamaIndexTS/@llamaindex/replicate@1565

@llamaindex/vercel

npm i https://pkg.pr.new/run-llama/LlamaIndexTS/@llamaindex/vercel@1565

@llamaindex/vllm

npm i https://pkg.pr.new/run-llama/LlamaIndexTS/@llamaindex/vllm@1565

commit: c81e9a5

Add proper message format transformation for tool calls and results in chat
history when using Anthropic agent. This allows Anthropic agent to handle
tool history consistently with OpenAI agent, which already had this
functionality.

Previously, chat history with tool calls would cause API errors with
Anthropic but worked fine with OpenAI. Now both agents handle the same
message format correctly.
@erik-balfe erik-balfe force-pushed the anthropic-tool-calls-formatting branch from 2ec1502 to 04b4f76 Compare December 12, 2024 20:49
@erik-balfe erik-balfe marked this pull request as ready for review December 12, 2024 21:04
@erik-balfe erik-balfe changed the title add tool call history support in chat messages (#1564) add tool call history support in chat messages Dec 12, 2024
@erik-balfe
Copy link
Contributor Author

@marcusschiesser could you help me please? Is it something required from me or some permission issue?
In the checks here.
Vercel – llamaindex-ts-doc — Authorization required to deploy

packages/core/src/llms/type.ts Outdated Show resolved Hide resolved
.changeset/pink-days-appear.md Outdated Show resolved Hide resolved
@marcusschiesser
Copy link
Collaborator

@marcusschiesser could you help me please? Is it something required from me or some permission issue? In the checks here. Vercel – llamaindex-ts-doc — Authorization required to deploy

that's only for building the docs, which are not changed by this PR, so no worries

@erik-balfe
Copy link
Contributor Author

So are the any other problems with the PR? @himself65
I have fixed all these comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Tool Call History Support for Anthropic Agent
3 participants