pgai icon indicating copy to clipboard operation
pgai copied to clipboard

Use tools with anthropic_generate (example type tool_use)

Open jonatas opened this issue 1 year ago • 0 comments

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:

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

  • [x] Document the JSON print_summary

jonatas avatar Sep 03 '24 21:09 jonatas