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

Use tools with anthropic_generate (example type tool_use) #68

Merged
merged 1 commit into from
Dec 5, 2024

Conversation

jonatas
Copy link
Contributor

@jonatas jonatas commented Sep 3, 2024

A minimal example of how to use tool_use.

The original function gives me this error
 ERROR:  anthropic.BadRequestError: Error code: 400 - {'type': 'error', 'error': {'type': 'invalid_request_error', 'message': 'tools: Input should be a valid list'}}
CONTEXT:  Traceback (most recent call last):
  PL/Python function "anthropic_generate", line 42, in <module>
    message = client.messages.create(model=_model, messages=_messages_1, max_tokens=_max_tokens, **args)
  PL/Python function "anthropic_generate", line 276, in wrapper
  PL/Python function "anthropic_generate", line 903, in create
  PL/Python function "anthropic_generate", line 1248, in post
  PL/Python function "anthropic_generate", line 930, in request
  PL/Python function "anthropic_generate", line 1028, in _request

Then, profiling with Claude, I just got this fix and I also added the final example porting same Name Entity Recognition.

TODO:

  • Wrap the code example into a useful function like extract_entities
image

@jonatas jonatas marked this pull request as draft September 3, 2024 21:30
Copy link
Collaborator

@jgpruitt jgpruitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great. Thanks for the bug fixes.

@jonatas jonatas marked this pull request as ready for review September 13, 2024 13:18
@jonatas jonatas force-pushed the fix-tools branch 2 times, most recently from 459db2d to 3c1e765 Compare September 17, 2024 18:27
Copy link
Collaborator

@jgpruitt jgpruitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonatas sorry for the mess. think you could rebase on the latest main?

@jonatas
Copy link
Contributor Author

jonatas commented Nov 21, 2024

Rebased @jgpruitt!

@jgpruitt
Copy link
Collaborator

jgpruitt commented Nov 21, 2024

@jonatas Awesome. You'll need to make the commit message conform to a "conventional commit format" to get it to pass the linter.
https://github.com/conventional-changelog/commitlint

@jonatas jonatas dismissed jgpruitt’s stale review November 26, 2024 14:55

I updated the commit message!

@adolsalamanca adolsalamanca merged commit 2cb2fe9 into main Dec 5, 2024
5 checks passed
@adolsalamanca adolsalamanca deleted the fix-tools branch December 5, 2024 18:00
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.

3 participants