pgai
pgai copied to clipboard
Use tools with anthropic_generate (example type tool_use)
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 -
[x] Document the JSON print_summary