airflow.providers.amazon.aws.operators.bedrock

BedrockInvokeModelOperator

呼叫指定的 Bedrock 模型以使用提供的輸入執行推理。

BedrockCustomizeModelOperator

建立微調作業以自定義基礎模型。

BedrockCreateProvisionedModelThroughputOperator

建立微調作業以自定義基礎模型。

BedrockCreateKnowledgeBaseOperator

建立包含 Amazon Bedrock LLMs 和 Agents 使用的資料來源的知識庫。

BedrockCreateDataSourceOperator

設定一個 Amazon Bedrock 資料來源以新增到 Amazon Bedrock 知識庫。

BedrockIngestDataOperator

開始一個攝取作業,其中 Amazon Bedrock 資料來源被新增到 Amazon Bedrock 知識庫。

BedrockRaGOperator

查詢知識庫並根據檢索到的結果生成響應,並附帶來源引用。

BedrockRetrieveOperator

查詢知識庫並檢索結果,並附帶來源引用。

BedrockBatchInferenceOperator

建立批次推理作業以在多個提示上呼叫模型。

模組內容

class airflow.providers.amazon.aws.operators.bedrock.BedrockInvokeModelOperator(model_id, input_data, content_type=None, accept_type=None, **kwargs)[source]

基類: airflow.providers.amazon.aws.operators.base_aws.AwsBaseOperator[airflow.providers.amazon.aws.hooks.bedrock.BedrockRuntimeHook]

呼叫指定的 Bedrock 模型以使用提供的輸入執行推理。

使用 InvokeModel 對文字模型、影像模型和嵌入模型執行推理。有關不同模型的 input_data 欄位的格式和內容,請參閱 推理引數文件

另請參閱

有關如何使用此操作器的更多資訊,請參閱指南:呼叫現有的 Amazon Bedrock 模型

引數:
  • model_id (str) – Bedrock 模型的 ID。(模板化)

  • input_data (dict[str, Any]) – 輸入資料,格式由 content-type 請求頭指定。(模板化)

  • content_type (str | None) – 請求中輸入資料的 MIME 型別。(模板化) 預設值: application/json

  • accept – 響應中推理體的所需 MIME 型別。(模板化) 預設值: application/json

  • aws_conn_id – 用於 AWS 憑據的 Airflow 連線。如果為 None 或為空,則使用預設的 boto3 行為。如果在分散式模式下執行 Airflow 且 aws_conn_id 為 None 或為空,則將使用預設的 boto3 配置(並且必須在每個 worker 節點上維護)。

  • region_name – AWS region_name。如果未指定,則使用預設的 boto3 行為。

  • verify – 是否驗證 SSL 證書。參見: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/core/session.html

  • botocore_config – botocore 客戶端的配置字典(鍵值對)。參見: https://botocore.amazonaws.com/v1/documentation/api/latest/reference/config.html

aws_hook_class[source]
template_fields: collections.abc.Sequence[str][source]
model_id[source]
input_data[source]
content_type = None[source]
accept_type = None[source]
execute(context)[source]

建立操作器時派生。

Context 是與渲染 jinja 模板時使用的字典相同。

有關更多上下文資訊,請參閱 get_template_context。

class airflow.providers.amazon.aws.operators.bedrock.BedrockCustomizeModelOperator(job_name, custom_model_name, role_arn, base_model_id, training_data_uri, output_data_uri, hyperparameters, ensure_unique_job_name=True, customization_job_kwargs=None, wait_for_completion=True, waiter_delay=120, waiter_max_attempts=75, deferrable=conf.getboolean('operators', 'default_deferrable', fallback=False), **kwargs)[source]

基類: airflow.providers.amazon.aws.operators.base_aws.AwsBaseOperator[airflow.providers.amazon.aws.hooks.bedrock.BedrockHook]

建立微調作業以自定義基礎模型。

另請參閱

有關如何使用此操作器的更多資訊,請參閱指南:自定義現有的 Amazon Bedrock 模型

引數:
  • job_name (str) – 微調作業的唯一名稱。

  • custom_model_name (str) – 正在建立的自定義模型的名稱。

  • role_arn (str) – Amazon Bedrock 可以代您執行任務的 IAM 角色的 Amazon 資源名稱 (ARN)。

  • base_model_id (str) – 基礎模型的名稱。

  • training_data_uri (str) – 訓練資料儲存所在的 S3 URI。

  • output_data_uri (str) – 輸出資料儲存所在的 S3 URI。

  • hyperparameters (dict[str, str]) – 與調整模型相關的引數。

  • ensure_unique_job_name (bool) – 如果設定為 True,操作器將檢查配置中指定的名稱是否存在模型自定義作業,如果名稱衝突,則附加當前時間戳。(預設值: True)

  • customization_job_kwargs (dict[str, Any] | None) – 傳遞給 API 的任何可選引數。

  • wait_for_completion (bool) – 是否等待叢集停止。(預設值: True)

  • waiter_delay (int) – 兩次狀態檢查之間的等待時間(秒)。(預設值: 120)

  • waiter_max_attempts (int) – 檢查作業完成狀態的最大嘗試次數。(預設值: 75)

  • deferrable (bool) – 如果為 True,操作器將非同步等待叢集停止。這意味著等待完成。此模式需要安裝 aiobotocore 模組。(預設值: False)

  • aws_conn_id – 用於 AWS 憑據的 Airflow 連線。如果為 None 或為空,則使用預設的 boto3 行為。如果在分散式模式下執行 Airflow 且 aws_conn_id 為 None 或為空,則將使用預設的 boto3 配置(並且必須在每個 worker 節點上維護)。

  • region_name – AWS region_name。如果未指定,則使用預設的 boto3 行為。

  • verify – 是否驗證 SSL 證書。參見: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/core/session.html

  • botocore_config – botocore 客戶端的配置字典(鍵值對)。參見: https://botocore.amazonaws.com/v1/documentation/api/latest/reference/config.html

aws_hook_class[source]
template_fields: collections.abc.Sequence[str][source]
wait_for_completion = True[source]
waiter_delay = 120[source]
waiter_max_attempts = 75[source]
deferrable = True[source]
job_name[source]
custom_model_name[source]
role_arn[source]
base_model_id[source]
training_data_config[source]
output_data_config[source]
hyperparameters[source]
ensure_unique_job_name = True[source]
customization_job_kwargs[source]
valid_action_if_job_exists: set[str][source]
execute_complete(context, event=None)[source]
execute(context)[source]

建立操作器時派生。

Context 是與渲染 jinja 模板時使用的字典相同。

有關更多上下文資訊,請參閱 get_template_context。

class airflow.providers.amazon.aws.operators.bedrock.BedrockCreateProvisionedModelThroughputOperator(model_units, provisioned_model_name, model_id, create_throughput_kwargs=None, wait_for_completion=True, waiter_delay=60, waiter_max_attempts=20, deferrable=conf.getboolean('operators', 'default_deferrable', fallback=False), **kwargs)[source]

基類: airflow.providers.amazon.aws.operators.base_aws.AwsBaseOperator[airflow.providers.amazon.aws.hooks.bedrock.BedrockHook]

建立微調作業以自定義基礎模型。

另請參閱

有關如何使用此操作器的更多資訊,請參閱指南:為現有的 Amazon Bedrock 模型預置吞吐量

引數:
  • model_units (int) – 要分配的模型單元數。(模板化)

  • provisioned_model_name (str) – 此預置吞吐量的唯一名稱。(模板化)

  • model_id (str) – 與此預置吞吐量關聯的模型的名稱或 ARN。(模板化)

  • create_throughput_kwargs (dict[str, Any] | None) – 傳遞給 API 的任何可選引數。

  • wait_for_completion (bool) – 是否等待叢集停止。(預設值: True)

  • waiter_delay (int) – 兩次狀態檢查之間的等待時間(秒)。(預設值: 60)

  • waiter_max_attempts (int) – 檢查作業完成狀態的最大嘗試次數。(預設值: 20)

  • deferrable (bool) – 如果為 True,操作器將非同步等待叢集停止。這意味著等待完成。此模式需要安裝 aiobotocore 模組。(預設值: False)

  • aws_conn_id – 用於 AWS 憑據的 Airflow 連線。如果為 None 或為空,則使用預設的 boto3 行為。如果在分散式模式下執行 Airflow 且 aws_conn_id 為 None 或為空,則將使用預設的 boto3 配置(並且必須在每個 worker 節點上維護)。

  • region_name – AWS region_name。如果未指定,則使用預設的 boto3 行為。

  • verify – 是否驗證 SSL 證書。參見: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/core/session.html

  • botocore_config – botocore 客戶端的配置字典(鍵值對)。參見: https://botocore.amazonaws.com/v1/documentation/api/latest/reference/config.html

aws_hook_class[source]
template_fields: collections.abc.Sequence[str][source]
model_units[source]
provisioned_model_name[source]
model_id[source]
create_throughput_kwargs[source]
wait_for_completion = True[source]
waiter_delay = 60[source]
waiter_max_attempts = 20[source]
deferrable = True[source]
execute(context)[source]

建立操作器時派生。

Context 是與渲染 jinja 模板時使用的字典相同。

有關更多上下文資訊,請參閱 get_template_context。

execute_complete(context, event=None)[source]
class airflow.providers.amazon.aws.operators.bedrock.BedrockCreateKnowledgeBaseOperator(name, embedding_model_arn, role_arn, storage_config, create_knowledge_base_kwargs=None, wait_for_indexing=True, indexing_error_retry_delay=5, indexing_error_max_attempts=20, wait_for_completion=True, waiter_delay=60, waiter_max_attempts=20, deferrable=conf.getboolean('operators', 'default_deferrable', fallback=False), **kwargs)[source]

基類: airflow.providers.amazon.aws.operators.base_aws.AwsBaseOperator[airflow.providers.amazon.aws.hooks.bedrock.BedrockAgentHook]

建立包含 Amazon Bedrock LLMs 和 Agents 使用的資料來源的知識庫。

要建立知識庫,您必須首先設定資料來源並配置支援的向量儲存。

另請參閱

有關如何使用此操作器的更多資訊,請參閱指南:建立 Amazon Bedrock 知識庫

引數:
  • name (str) – 知識庫的名稱。(模板化)

  • embedding_model_arn (str) – 用於為知識庫建立向量嵌入的模型的 ARN。(模板化)

  • role_arn (str) – 擁有建立知識庫許可權的 IAM 角色的 ARN。(模板化)

  • storage_config (dict[str, Any]) – 知識庫使用的向量資料庫的配置詳情。(模板化)

  • wait_for_indexing (bool) – 向量索引可能需要一些時間,且在嘗試建立知識庫之前沒有明確的方法檢查其狀態。如果此引數為 True,且建立因索引不可用而失敗,運算子將等待並重試。(預設值: True) (模板化)

  • indexing_error_retry_delay (int) – 遇到索引錯誤時,重試之間的秒數。(預設值 5) (模板化)

  • indexing_error_max_attempts (int) – 遇到索引錯誤時,最大重試次數。(預設值 20) (模板化)

  • create_knowledge_base_kwargs (dict[str, Any] | None) – 傳遞給 API 呼叫的任何其他可選引數。(模板化)

  • wait_for_completion (bool) – 是否等待叢集停止。(預設值: True)

  • waiter_delay (int) – 兩次狀態檢查之間的等待時間(秒)。(預設值: 60)

  • waiter_max_attempts (int) – 檢查作業完成狀態的最大嘗試次數。(預設值: 20)

  • deferrable (bool) – 如果為 True,操作器將非同步等待叢集停止。這意味著等待完成。此模式需要安裝 aiobotocore 模組。(預設值: False)

  • aws_conn_id – 用於 AWS 憑據的 Airflow 連線。如果為 None 或為空,則使用預設的 boto3 行為。如果在分散式模式下執行 Airflow 且 aws_conn_id 為 None 或為空,則將使用預設的 boto3 配置(並且必須在每個 worker 節點上維護)。

  • region_name – AWS region_name。如果未指定,則使用預設的 boto3 行為。

  • verify – 是否驗證 SSL 證書。參見: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/core/session.html

  • botocore_config – botocore 客戶端的配置字典(鍵值對)。參見: https://botocore.amazonaws.com/v1/documentation/api/latest/reference/config.html

aws_hook_class[source]
template_fields: collections.abc.Sequence[str][source]
name[source]
role_arn[source]
storage_config[source]
create_knowledge_base_kwargs[source]
embedding_model_arn[source]
knowledge_base_config[source]
wait_for_indexing = True[source]
indexing_error_retry_delay = 5[source]
indexing_error_max_attempts = 20[source]
wait_for_completion = True[source]
waiter_delay = 60[source]
waiter_max_attempts = 20[source]
deferrable = True[source]
execute_complete(context, event=None)[source]
execute(context)[source]

建立操作器時派生。

Context 是與渲染 jinja 模板時使用的字典相同。

有關更多上下文資訊,請參閱 get_template_context。

class airflow.providers.amazon.aws.operators.bedrock.BedrockCreateDataSourceOperator(name, knowledge_base_id, bucket_name=None, create_data_source_kwargs=None, **kwargs)[source]

基類: airflow.providers.amazon.aws.operators.base_aws.AwsBaseOperator[airflow.providers.amazon.aws.hooks.bedrock.BedrockAgentHook]

設定一個 Amazon Bedrock 資料來源以新增到 Amazon Bedrock 知識庫。

另請參閱

有關如何使用此運算子的更多資訊,請參閱指南:建立 Amazon Bedrock 資料來源

引數:
  • name (str) – 要建立的 Amazon Bedrock 資料來源的名稱。(模板化)。

  • bucket_name (str | None) – 用於資料來源儲存的 Amazon S3 桶的名稱。(模板化)

  • knowledge_base_id (str) – 要新增資料來源的知識庫的唯一識別符號。(模板化)

  • create_data_source_kwargs (dict[str, Any] | None) – 傳遞給 API 呼叫的任何其他可選引數。(模板化)

  • aws_conn_id – 用於 AWS 憑據的 Airflow 連線。如果為 None 或為空,則使用預設的 boto3 行為。如果在分散式模式下執行 Airflow 且 aws_conn_id 為 None 或為空,則將使用預設的 boto3 配置(並且必須在每個 worker 節點上維護)。

  • region_name – AWS region_name。如果未指定,則使用預設的 boto3 行為。

  • verify – 是否驗證 SSL 證書。參見: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/core/session.html

  • botocore_config – botocore 客戶端的配置字典(鍵值對)。參見: https://botocore.amazonaws.com/v1/documentation/api/latest/reference/config.html

aws_hook_class[source]
template_fields: collections.abc.Sequence[str][source]
name[source]
knowledge_base_id[source]
bucket_name = None[source]
create_data_source_kwargs[source]
execute(context)[source]

建立操作器時派生。

Context 是與渲染 jinja 模板時使用的字典相同。

有關更多上下文資訊,請參閱 get_template_context。

class airflow.providers.amazon.aws.operators.bedrock.BedrockIngestDataOperator(knowledge_base_id, data_source_id, ingest_data_kwargs=None, wait_for_completion=True, waiter_delay=60, waiter_max_attempts=10, deferrable=conf.getboolean('operators', 'default_deferrable', fallback=False), **kwargs)[source]

基類: airflow.providers.amazon.aws.operators.base_aws.AwsBaseOperator[airflow.providers.amazon.aws.hooks.bedrock.BedrockAgentHook]

開始一個攝取作業,其中 Amazon Bedrock 資料來源被新增到 Amazon Bedrock 知識庫。

另請參閱

有關如何使用此運算子的更多資訊,請參閱指南:將資料攝取到 Amazon Bedrock 資料來源

引數:
  • knowledge_base_id (str) – 要新增資料來源的知識庫的唯一識別符號。(模板化)

  • data_source_id (str) – 要攝取資料的資料來源的唯一識別符號。(模板化)

  • ingest_data_kwargs (dict[str, Any] | None) – 傳遞給 API 呼叫的任何其他可選引數。(模板化)

  • wait_for_completion (bool) – 是否等待叢集停止。(預設值: True)

  • waiter_delay (int) – 兩次狀態檢查之間的等待時間(秒)。(預設值: 60)

  • waiter_max_attempts (int) – 檢查作業完成情況的最大嘗試次數。(預設值: 10)

  • deferrable (bool) – 如果為 True,操作器將非同步等待叢集停止。這意味著等待完成。此模式需要安裝 aiobotocore 模組。(預設值: False)

  • aws_conn_id – 用於 AWS 憑據的 Airflow 連線。如果為 None 或為空,則使用預設的 boto3 行為。如果在分散式模式下執行 Airflow 且 aws_conn_id 為 None 或為空,則將使用預設的 boto3 配置(並且必須在每個 worker 節點上維護)。

  • region_name – AWS region_name。如果未指定,則使用預設的 boto3 行為。

  • verify – 是否驗證 SSL 證書。參見: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/core/session.html

  • botocore_config – botocore 客戶端的配置字典(鍵值對)。參見: https://botocore.amazonaws.com/v1/documentation/api/latest/reference/config.html

aws_hook_class[source]
template_fields: collections.abc.Sequence[str][source]
knowledge_base_id[source]
data_source_id[source]
ingest_data_kwargs[source]
wait_for_completion = True[source]
waiter_delay = 60[source]
waiter_max_attempts = 10[source]
deferrable = True[source]
execute_complete(context, event=None)[source]
execute(context)[source]

建立操作器時派生。

Context 是與渲染 jinja 模板時使用的字典相同。

有關更多上下文資訊,請參閱 get_template_context。

class airflow.providers.amazon.aws.operators.bedrock.BedrockRaGOperator(input, source_type, model_arn, prompt_template=None, knowledge_base_id=None, vector_search_config=None, sources=None, rag_kwargs=None, **kwargs)[source]

基類: airflow.providers.amazon.aws.operators.base_aws.AwsBaseOperator[airflow.providers.amazon.aws.hooks.bedrock.BedrockAgentRuntimeHook]

查詢知識庫並根據檢索到的結果生成響應,並附帶來源引用。

注意: 對 EXTERNAL SOURCES 的支援已在 botocore 1.34.90 中新增

另請參閱

有關如何使用此運算子的更多資訊,請參閱指南:Amazon Bedrock 檢索增強生成 (RaG)

引數:
  • input (str) – 向知識庫發起的查詢。(模板化)

  • source_type (str) – 請求查詢的資源型別。(模板化) 必須是“KNOWLEDGE_BASE”或“EXTERNAL_SOURCES”之一,並且必須提供相應的配置值。如果設定為“KNOWLEDGE_BASE”,則必須提供 knowledge_base_id,並且可以提供 vector_search_config。如果設定為 EXTERNAL_SOURCES,則還必須提供 sources。注意: 對 EXTERNAL SOURCES 的支援已在 botocore 1.34.90 中新增。

  • model_arn (str) – 用於生成響應的基礎模型的 ARN。(模板化)

  • prompt_template (str | None) – 用於傳送到模型生成響應的提示模板。您可以包含提示佔位符,這些佔位符在傳送到模型之前會被替換,以向模型提供指令和上下文。此外,您可以包含 XML 標籤來劃分提示模板中有意義的部分。(模板化)

  • knowledge_base_id (str | None) – 被查詢的知識庫的唯一識別符號。(模板化) 僅當 source_type='KNOWLEDGE_BASE' 時可以指定。

  • vector_search_config (dict[str, Any] | None) – 向量搜尋結果的返回方式。(模板化) 僅當 source_type='KNOWLEDGE_BASE' 時可以指定。更多資訊,請參閱 https://docs.aws.amazon.com/bedrock/latest/userguide/kb-test-config.html

  • sources (list[dict[str, Any]] | None) – 用作響應參考的文件。(模板化) 僅當 source_type='EXTERNAL_SOURCES' 時可以指定。注意: 對 EXTERNAL SOURCES 的支援已在 botocore 1.34.90 中新增。

  • rag_kwargs (dict[str, Any] | None) – 傳遞給 API 呼叫的額外關鍵字引數。(模板化)

aws_hook_class[source]
template_fields: collections.abc.Sequence[str][source]
input[source]
prompt_template = None[source]
source_type[source]
knowledge_base_id = None[source]
model_arn[source]
vector_search_config = None[source]
sources = None[source]
rag_kwargs[source]
validate_inputs()[source]
build_rag_config()[source]
execute(context)[source]

建立操作器時派生。

Context 是與渲染 jinja 模板時使用的字典相同。

有關更多上下文資訊,請參閱 get_template_context。

airflow.providers.amazon.aws.operators.bedrock.BedrockRetrieveOperator(retrieval_query, knowledge_base_id, vector_search_config=None, retrieve_kwargs=None, **kwargs)[source]

基類: airflow.providers.amazon.aws.operators.base_aws.AwsBaseOperator[airflow.providers.amazon.aws.hooks.bedrock.BedrockAgentRuntimeHook]

查詢知識庫並檢索結果,並附帶來源引用。

另請參閱

關於如何使用此運算子的更多資訊,請參閱指南: Amazon Bedrock Retrieve

引數:
aws_hook_class[source]
template_fields: collections.abc.Sequence[str][source]
retrieval_query[source]
knowledge_base_id[source]
vector_search_config = None[source]
retrieve_kwargs[source]
execute(context)[source]

建立操作器時派生。

Context 是與渲染 jinja 模板時使用的字典相同。

有關更多上下文資訊,請參閱 get_template_context。

airflow.providers.amazon.aws.operators.bedrock.BedrockBatchInferenceOperator(job_name, role_arn, model_id, input_uri, output_uri, invoke_kwargs=None, wait_for_completion=True, waiter_delay=60, waiter_max_attempts=20, deferrable=conf.getboolean('operators', 'default_deferrable', fallback=False), **kwargs)[source]

基類: airflow.providers.amazon.aws.operators.base_aws.AwsBaseOperator[airflow.providers.amazon.aws.hooks.bedrock.BedrockHook]

建立批次推理作業以在多個提示上呼叫模型。

另請參閱

關於如何使用此運算子的更多資訊,請參閱指南: Create an Amazon Bedrock Batch Inference Job

引數:
  • job_name (str) – 批次推理作業的名稱。(templated)

  • role_arn (str) – 擁有建立知識庫許可權的 IAM 角色的 ARN。(模板化)

  • model_id (str) – 與此預置吞吐量關聯的模型的名稱或 ARN。(模板化)

  • input_uri (str) – 輸入資料的 S3 位置。(templated)

  • output_uri (str) – 輸出資料的 S3 位置。(templated)

  • invoke_kwargs (dict[str, Any] | None) – 要傳遞給 API 呼叫的額外關鍵字引數。(templated)

  • wait_for_completion (bool) – 是否等待作業停止。(default: True) 注意:批次推理作業的工作方式是將您的作業新增到佇列中並“最終”完成,因此使用可延遲模式比使用 wait_for_completion 更實用。

  • waiter_delay (int) – 兩次狀態檢查之間的等待時間(秒)。(預設值: 60)

  • waiter_max_attempts (int) – 檢查作業完成情況的最大嘗試次數。(預設值: 10)

  • deferrable (bool) – 如果為 True,操作器將非同步等待叢集停止。這意味著等待完成。此模式需要安裝 aiobotocore 模組。(預設值: False)

  • aws_conn_id – 用於 AWS 憑據的 Airflow 連線。如果為 None 或為空,則使用預設的 boto3 行為。如果在分散式模式下執行 Airflow 且 aws_conn_id 為 None 或為空,則將使用預設的 boto3 配置(並且必須在每個 worker 節點上維護)。

  • region_name – AWS region_name。如果未指定,則使用預設的 boto3 行為。

  • verify – 是否驗證 SSL 證書。參見: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/core/session.html

  • botocore_config – botocore 客戶端的配置字典(鍵值對)。參見: https://botocore.amazonaws.com/v1/documentation/api/latest/reference/config.html

aws_hook_class[source]
template_fields: collections.abc.Sequence[str][source]
job_name[source]
role_arn[source]
model_id[source]
input_uri[source]
output_uri[source]
invoke_kwargs[source]
wait_for_completion = True[source]
waiter_delay = 60[source]
waiter_max_attempts = 20[source]
deferrable = True[source]
activity = 'Bedrock 批次推理作業'[source]
execute_complete(context, event=None)[source]
execute(context)[source]

建立操作器時派生。

Context 是與渲染 jinja 模板時使用的字典相同。

有關更多上下文資訊,請參閱 get_template_context。

本條目有幫助嗎?