Skip to content

feat(community): Permit bedrock application inference profiles #7822

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 4 commits into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions libs/langchain-community/src/chat_models/bedrock/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,10 @@ export class BedrockChat
this.guardrailIdentifier =
fields?.guardrailIdentifier ?? this.guardrailIdentifier;
this.guardrailConfig = fields?.guardrailConfig;
// Permit Application Inference Profile override (expects to be url-encoded)
if (fields?.modelAlias) {
this.model = fields?.modelAlias;
}
}

override invocationParams(options?: this["ParsedCallOptions"]) {
Expand Down
6 changes: 6 additions & 0 deletions libs/langchain-community/src/utils/bedrock/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ export interface BaseBedrockInput {
*/
model: string;

/** Optional URL Encoded model alias to use. Necessary for invoking an Application Inference Profile
For example, "arn%3Aaws%3Abedrock%3Aus-east-1%3A1234567890%3Aapplication-inference-profile%2Fabcdefghi", will override this.model in final /invoke URL call.
Must still provide `model` as normal modelId to benefit from all the metadata.
*/
modelAlias?: string;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we call this applicationInferenceProfile?

Copy link
Contributor Author

@bioshazard bioshazard Mar 13, 2025

Choose a reason for hiding this comment

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

Works for me. Figured to make the url override generic tho application inference profile is the only use case today. I'll push the change today if y'all don't beat me to it

Copy link
Contributor Author

@bioshazard bioshazard Mar 13, 2025

Choose a reason for hiding this comment

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

@jacoblee93 ok I pushed an update to rename as suggested. Still working fine in testing in my app. Thanks!

Copy link
Contributor Author

@bioshazard bioshazard Mar 17, 2025

Choose a reason for hiding this comment

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

@jacoblee93 friendly bump, hoping to stay w/ LangChain as we migrate to App Inf profiles. Gotta deliver this soon. Thanks!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Will try to get this in today thanks!


/** The AWS region e.g. `us-west-2`.
Fallback to AWS_DEFAULT_REGION env variable or region specified in ~/.aws/config in case it is not provided here.
*/
Expand Down