haystack-core-integrations icon indicating copy to clipboard operation
haystack-core-integrations copied to clipboard

Bedrock: "Parameter 'tools' is not allowed and will be ignored."

Open lambda-science opened this issue 1 year ago • 0 comments

Describe the bug When trying to use function calling with AWS Bedrock, the current integration ignore the tools keyword argument.

generator_json = AmazonBedrockChatGenerator(
    model="anthropic.claude-3-haiku-20240307-v1:0",
    aws_region_name=Secret.from_token("eu-west-3"),
    generation_kwargs={"temperature": 0, "max_tokens": 4096}, aws_profile_name=Secret.from_token("sandbox")
)
response = generator_json.run(
    messages=messages,
    generation_kwargs={"tools":tools}
)

08/13/2024 01:25:03 PM Parameter 'tools' is not allowed and will be ignored. Lines responsible of this error:

  • https://github.com/deepset-ai/haystack-core-integrations/blob/main/integrations/amazon_bedrock/src/haystack_integrations/components/generators/amazon_bedrock/chat/adapters.py#L76
  • https://github.com/deepset-ai/haystack-core-integrations/blob/main/integrations/amazon_bedrock/src/haystack_integrations/components/generators/amazon_bedrock/chat/adapters.py#L159

Describe your environment (please complete the following information):

  • OS: [e.g. iOS]: Linux Docker
  • Haystack version: 2.3.1
  • Integration version: amazon-bedrock-haystack==0.9.3

Additional infos: Also this integration could be modernized with the new "Converse" API from Bedrock, that allow cross-model integration (same API for all providers), thus making easier tools calling. https://docs.aws.amazon.com/bedrock/latest/userguide/tool-use.html

To use tools with a model you can use the Converse API (Converse or ConverseStream). The example code in this topic uses the Converse API to show how to use a tool that gets the most popular song for a radio station. For general information about calling the Converse API, see Use the Converse API.

It is possible to use tools with the base inference operations (InvokeModel or InvokeModelWithResponseStream).

The current integration with the kwargs tools is part of the old InvokeModel inference operation. But this would be a futur concern.

lambda-science avatar Aug 13 '24 11:08 lambda-science