Skip to content

feat(BedrockConverseModel): add additional configuration fields to Bedrock Runtime API #1458

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

Merged
merged 15 commits into from
Apr 15, 2025

Conversation

leandrodamascena
Copy link
Contributor

@leandrodamascena leandrodamascena commented Apr 11, 2025

Closes #1396
Closes #1170

Description

This PR extends the BedrockModelSettings class with several new configuration options to provide more comprehensive control over Bedrock Runtime API requests.

Changes

  • Added bedrock_guardrail_config for content moderation settings
  • Added bedrock_performance_configuration for inference optimization
  • Added bedrock_request_metadata for tracking and compliance metadata
  • Added bedrock_additional_model_response_fields_paths for extracting custom fields
  • Added bedrock_prompt_variables for template substitution
  • Added bedrock_additional_model_requests_fields for model-specific parameters

Motivation

These additions allow for more fine-grained control over Bedrock model invocations, enabling features such as content filtering, performance tuning, and access to model-specific parameters not covered by the standard API interface.

Copy link
Contributor

hyperlint-ai bot commented Apr 11, 2025

PR Change Summary

Extended the BedrockModelSettings class with new configuration options for enhanced control over Bedrock Runtime API requests.

  • Added bedrock_guardrail_config for content moderation settings
  • Introduced bedrock_performance_configuration for inference optimization
  • Included bedrock_request_metadata for tracking and compliance
  • Added bedrock_prompt_variables for template substitution

Modified Files

  • docs/models/bedrock.md

How can I customize these reviews?

Check out the Hyperlint AI Reviewer docs for more information on how to customize the review.

If you just want to ignore it on this PR, you can add the hyperlint-ignore label to the PR. Future changes won't trigger a Hyperlint review.

Note specifically for link checks, we only check the first 30 links in a file and we cache the results for several hours (for instance, if you just added a page, you might experience this). Our recommendation is to add hyperlint-ignore to the PR to ignore the link check for this PR.

@leandrodamascena
Copy link
Contributor Author

Hey @Kludex this PR add support for extra fields. Looks like CI is failing with network error in Python 3.10

Copy link
Member

@Kludex Kludex left a comment

Choose a reason for hiding this comment

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

@leandrodamascena all good here besides the references. I think we need to make it easier for people to navigate to the bedrock documentation, where it explains those settings.

Comment on lines 143 to 144
bedrock_additional_model_requests_fields: Mapping[str, Any]
"""Additional model-specific parameters to include in requests."""
Copy link
Member

Choose a reason for hiding this comment

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

It would be nice to add links to those.

Suggested change
bedrock_additional_model_requests_fields: Mapping[str, Any]
"""Additional model-specific parameters to include in requests."""
bedrock_additional_model_requests_fields: Mapping[str, Any]
"""Additional model-specific parameters to include in requests.
See more about it on <url>.
"""

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey @Kludex yeah, make sense! While we don't have specific links in the boto3 configuration, I can add the API reference link for each field: https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_Converse.html

Copy link
Member

Choose a reason for hiding this comment

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

That would be great. :)

I want to make it easier for us to maintain each model/provider.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, especially since you deal with dozens of integrations, this concern is super valid.

Comment on lines 49 to 50
You can customize the Bedrock Runtime API calls by adding additional parameters, such as guardrail
configurations and performance settings. For a complete list of configurable parameters, refer to the
Copy link
Member

Choose a reason for hiding this comment

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

Can we add links to the guardrail configurations and performance settings?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure.

@leandrodamascena leandrodamascena requested a review from Kludex April 15, 2025 09:38
@leandrodamascena
Copy link
Contributor Author

leandrodamascena commented Apr 15, 2025

Hi @Kludex! I've already addressed all the feedback and pushed a new commit. Please see if this is enough or if I need to make more changes.

@Kludex
Copy link
Member

Kludex commented Apr 15, 2025

It's enough.

Obrigado. :)

@leandrodamascena
Copy link
Contributor Author

It's enough.

Obrigado. :)

Valeu de novo! 🚀

@Kludex Kludex enabled auto-merge (squash) April 15, 2025 10:30
@Kludex Kludex merged commit 858319e into pydantic:main Apr 15, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants