4
3

BedrockのナレッジベースでS3同期処理の自動化

Posted at

一気に大量のデータを同期したため、2日間位同期処理が終わらずCohere Embed Modelの利用料が$30位行ってしまいました:fearful:

手順

下記同期の箇所です。

detasorce.png

①Lambda用のIAMロールにbedrock:StartIngestionJobを追加
②Lambdaを作成

import boto3

def lambda_handler(event, context):
    client = boto3.client('bedrock-agent')
    response = client.start_ingestion_job(
        knowledgeBaseId='ナレッジベースID',
        dataSourceId='データソースID'
    )

③EventBridgeでLambdaを定期実行

差分データ

同期は増分であるため、前回の同期以降に追加、変更、または削除されたドキュメントのみを処理します。

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3