litellm icon indicating copy to clipboard operation
litellm copied to clipboard

Convert tool use arguments to string before counting tokens

Open jcmorrow opened this issue 1 year ago • 1 comments

Convert tool use arguments to string before counting tokens

Relevant issues

Fixes #6958

Type

🐛 Bug Fix

Changes

In at least some cases the messages["tool_calls"]["function"]["arguments"] is a dict, not a string. In order to tokenize it properly it needs to be a string. In the case that it is already a string this is a noop, which is also fine.

Testing

I'm not sure how to prove that this works, but I'm happy to provide some proof if you suggest how to do that.

jcmorrow avatar Dec 02 '24 22:12 jcmorrow

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

Name Status Preview Comments Updated (UTC)
litellm ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 2, 2024 10:49pm

vercel[bot] avatar Dec 02 '24 22:12 vercel[bot]