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

Anthropic tool calls and extraction fails for single arguments #258

Closed
willbakst opened this issue May 18, 2024 · 3 comments
Closed

Anthropic tool calls and extraction fails for single arguments #258

willbakst opened this issue May 18, 2024 · 3 comments
Assignees
Labels
Bug Something isn't working external dependance Dependent on an issue in an external library

Comments

@willbakst
Copy link
Contributor

Description

It looks like when given a single argument it always returns the input as a string instead of as a single-key dictionary.

Ideally it would return the correct input as part of the tool call; however, if it isn't easy to force this then we can always just try parsing the returns string as json and dynamically grabbing the field name.

Python, Mirascope & OS Versions, related packages (not required)

mirascope=v0.13.3
@willbakst willbakst added the Bug Something isn't working label May 18, 2024
@willbakst willbakst self-assigned this May 18, 2024
@willbakst
Copy link
Contributor Author

Looks like this is actually an issue with Anthropic tool calls not returning list as a list but as a str.

This isn't really fixable on our end since the item could be deeply nested and would require a full scan of the object. Better to request that Anthropic fix this.

anthropics/anthropic-sdk-python#507

@willbakst
Copy link
Contributor Author

Update: we can get around this through prompt engineering.

Opus works out of the box, but for Sonnet and Haiku adding something like "MUST BE A LIST" seems to work.

@willbakst willbakst added invalid This doesn't seem right external dependance Dependent on an issue in an external library and removed invalid This doesn't seem right labels May 21, 2024
@willbakst
Copy link
Contributor Author

Update, this is something the Anthropic team is aware of but isn't something they can do except with updates to the model. Nothing we can do on our end to "fix" this unfortunately.

The near term solution on our end is to simply prompt engineer to get the result (i.e. add something like MUST BE A LIST). Not ideal, but works. Something the user should do, not something we should include in Mirascope (since it's dependent on the user's schema). We could try to prompt engineer this under the hood, but that would just add unknown/unseen tokens and likely not work as well as a more specific prompt since it would necessarily be general.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working external dependance Dependent on an issue in an external library
Projects
None yet
Development

No branches or pull requests

1 participant