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

botocore: add basic handling for bedrock invoke.model #3200

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

xrmx
Copy link
Contributor

@xrmx xrmx commented Jan 22, 2025

Description

Handle the invokeModel operation in the bedrock extension of the botocore instrumentation for a bunch of models from Amazon and Anthropic. The API changes between models and so we need custom code for each model 😭 . We are tracing a bunch of request and response params that are available in all models. Next batch of changes will add tracing for the streaming versions of the Converse and InvokeModel.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • tox -e py310-test-instrumentation-botocore

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@xrmx xrmx changed the title Add basic handling for invoke.model botocore: add basic handling for invoke.model Jan 22, 2025
@xrmx xrmx requested a review from a team as a code owner January 22, 2025 16:09

@pytest.fixture(scope="module", autouse=True)
def fixture_vcr(vcr):
vcr.register_serializer("yaml", PrettyPrintJSONBody)
Copy link
Contributor Author

@xrmx xrmx Jan 22, 2025

Choose a reason for hiding this comment

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

Had to remove this because botocore is validating the response against the content-length, after updating the header in scrub_response_headers it was still failing saying that didn't find a matching cassette... reporting no failing matchers. After trying to understand what was going on I've preferred to sacrifice the cassettes readability over my sanity.

@@ -66,7 +64,7 @@ def environment():
if not os.getenv("AWS_SESSION_TOKEN"):
os.environ["AWS_SESSION_TOKEN"] = "test_aws_session_token"
if not os.getenv("AWS_DEFAULT_REGION"):
os.environ["AWS_DEFAULT_REGION"] = "eu-central-1"
os.environ["AWS_DEFAULT_REGION"] = "us-east-1"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some models are not available in europe :)

@xrmx xrmx changed the title botocore: add basic handling for invoke.model botocore: add basic handling for bedrock invoke.model Jan 22, 2025
@karthikscale3
Copy link
Contributor

Looks good to me, thanks

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.

2 participants