airflow.providers.amazon.aws.hooks.bedrock¶
Classes¶
Interact with Amazon Bedrock. |
|
Interact with the Amazon Bedrock Runtime. |
|
Interact with the Amazon Agents for Bedrock API. |
|
Interact with the Amazon Agents for Bedrock API. |
|
Interact with the Amazon Bedrock AgentCore control plane API. |
|
Interact with the Amazon Bedrock AgentCore runtime plane API. |
Module Contents¶
- class airflow.providers.amazon.aws.hooks.bedrock.BedrockHook(*args, **kwargs)[source]¶
Bases:
airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHookInteract with Amazon Bedrock.
Provide thin wrapper around
boto3.client("bedrock").Additional arguments (such as
aws_conn_id) may be specified and are passed down to the underlying AwsBaseHook.
- class airflow.providers.amazon.aws.hooks.bedrock.BedrockRuntimeHook(*args, **kwargs)[source]¶
Bases:
airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHookInteract with the Amazon Bedrock Runtime.
Provide thin wrapper around
boto3.client("bedrock-runtime").Additional arguments (such as
aws_conn_id) may be specified and are passed down to the underlying AwsBaseHook.
- class airflow.providers.amazon.aws.hooks.bedrock.BedrockAgentHook(*args, **kwargs)[source]¶
Bases:
airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHookInteract with the Amazon Agents for Bedrock API.
Provide thin wrapper around
boto3.client("bedrock-agent").Additional arguments (such as
aws_conn_id) may be specified and are passed down to the underlying AwsBaseHook.
- class airflow.providers.amazon.aws.hooks.bedrock.BedrockAgentRuntimeHook(*args, **kwargs)[source]¶
Bases:
airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHookInteract with the Amazon Agents for Bedrock API.
Provide thin wrapper around
boto3.client("bedrock-agent-runtime").Additional arguments (such as
aws_conn_id) may be specified and are passed down to the underlying AwsBaseHook.
- class airflow.providers.amazon.aws.hooks.bedrock.BedrockAgentCoreControlHook(*args, **kwargs)[source]¶
Bases:
airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHookInteract with the Amazon Bedrock AgentCore control plane API.
Provide thin wrapper around
boto3.client("bedrock-agentcore-control").Additional arguments (such as
aws_conn_id) may be specified and are passed down to the underlying AwsBaseHook.
- class airflow.providers.amazon.aws.hooks.bedrock.BedrockAgentCoreHook(*args, **kwargs)[source]¶
Bases:
airflow.providers.amazon.aws.hooks.base_aws.AwsBaseHook,airflow.providers.common.ai.managed_agents.base.BaseManagedAgentHookInteract with the Amazon Bedrock AgentCore runtime plane API.
Provide thin wrapper around
boto3.client("bedrock-agentcore").Additional arguments (such as
aws_conn_idandconfig) may be specified and are passed down to the underlying AwsBaseHook; the connection’sconfig_kwargsapply as they do for every other AWS hook.With the
common.aiextra installed, the hook also implements the Common AI managed-agent contract, sohook.agent(runtime_arn)can be handed to aManagedAgentToolset. The agent is the runtime ARN; the session is AgentCore’sruntimeSessionId, which the service requires to be 33 to 256 characters long. A request carrying apromptis sent as{"prompt": ...}and a request carryingmessagesas{"messages": [...]}, both asapplication/json. The container behind the runtime defines its own response shape, so the answer text is taken from the first ofoutput,result,textorresponsethat holds a string, or from thetext_keyvendor option when the container’s contract is known; otherwise the whole JSON body is returned as text. The decoded body is always available onManagedAgentResponse.raw.A remote invocation may have unknown effects, so the contract methods disable botocore’s retries unless the connection or the caller configured them, and let failures propagate to Airflow’s task-level retry instead.
ManagedAgentRequest.timeoutis honored as the botocore connect and read timeout of the call; a client is built per distinct timeout and reused. AgentCore has no error that means “rephrase the prompt” (a container’s own errors arrive inside a successful body), so the hook raises terminal errors or lets transient ones propagate, neverManagedAgentRejected.from airflow.providers.amazon.aws.hooks.bedrock import BedrockAgentCoreHook from airflow.providers.common.ai.toolsets import ManagedAgentToolset claims = BedrockAgentCoreHook(aws_conn_id="aws_prod", region_name="us-east-1").agent( "arn:aws:bedrock-agentcore:us-east-1:123456789012:runtime/claims" ) toolset = ManagedAgentToolset( claims, tool_name="ask_claims_agent", description="...", vendor_options={"text_key": "answer"} )
Two
vendor_optionsare read by the hook itself rather than forwarded toInvokeAgentRuntime:text_keynames the response field that holds the answer text when the container’s contract is known (a body without a string there is an error), andmax_response_bytesbounds the body read into worker memory (default 1 MiB). Every other option is passed to the API call as is.See also
- agent_platform = 'aws.bedrock_agentcore'[source]¶
The
platformeveryManagedAgentReffrom this hook carries.
- resolve_agent(agent)[source]¶
Normalize
agentinto a platform-qualified reference. Must not make a network call.