MENU
  • HOME
  • 取引実績
  • 会社概要
  • 資料DL
  • お問い合わせ
  • FAQ
  • BigQuery記事
  • Struccle記事
データ流通、検索エンジン開発のプロフェッショナル
DataStructor
  • HOME
  • 取引実績
  • 会社概要
  • 資料DL
  • お問い合わせ
  • FAQ
  • BigQuery記事
  • Struccle記事
DataStructor
  • HOME
  • 取引実績
  • 会社概要
  • 資料DL
  • お問い合わせ
  • FAQ
  • BigQuery記事
  • Struccle記事
  1. ホーム
  2. AI_Agent
  3. Agent開発
  4. AI Agent開発日記 2025/05/01

AI Agent開発日記 2025/05/01

2025 5/01
AI_Agent Agent開発
2025年5月1日
目次

この記事について

本記事は、Agent Builder を使用したデータストア参照型対話エージェントの作成に関する調査記録です。

やりたいこと

Agent Builder を用いたデータストア参照型対話エージェントの作成において、
既存のデータストア機能だとデータ数増加により回答率の低下が発生する為、elastic + dataflow + bigqueryで作成した検索が可能なデータストアを実装したい。

前回の調査日記

あわせて読みたい
AI Agent開発日記 2025/04/30 この記事について 本記事は、Agent Builder を使用したデータストア参照型対話エージェントの作成に関する調査記録です。 やりたいこと Agent Builder を用いたデータス...

agentbuilderのデータストアtoolとしてElastic Cloudで検索できるよう設定する。

  • やりたいこと
    • Agent Builderで作成した「Tool」を使って、指定したElasticsearchクラスターにあるfamous-songインデックスのデータを検索できるようにしたい。
    • 認証方式は「API キー」を使いたい。
  • 試したこと
    • Python(Jupyter)での検証
      • 指定したElasticsearchのURLとAPI キーを使って、pythonを使ってjupyterでfamous-song インデックスの検索 (GET /_search を使用) が成功することを確認してURLとAPI キー自体は有効という事が分かった。
    • openAPIスキーマ作成
      • Pythonでの検証結果に基づき、Agent Builder用のOpenAPIスキーマを作成した。
      • スキーマには、APIキー認証(Authorization ヘッダー)が必要であることも記述(components と security セクションを追加)
    • Agent Builderへの設定
      • 作成したOpenAPIスキーマをAgent BuilderのTool設定に貼り付けた
      • Toolの認証設定で、APIキー情報を入力した (プレフィックス ApiKey を付ける/付けない、両方のパターンを試した)。
    • Agent Builder でのテスト
      • toolの「Test tool」機能を使って、設定したToolの動作確認を試みた
  • 現状
    • 進展
      • 「Test tool」画面で、実行するActionとして、OpenAPI スキーマで定義した正しいGET操作 (searchElasticsearchGet)を選択できるようになった
    • 現在の課題
      • 依然としてテスト実行時に 401 認証エラー が発生しているように見える(または、テスト実行に必要な設定が不完全)。
      • 「Test tool」画面の Tool Input (パラメータ入力) の設定が適切でない。
        • 正しい Action (GET) が選択されているにも関わらず、その Action が必要とする検索パラメータ (index や source など) が入力されておらず、代わりに不要な requestBody が選択されている状態。
    • 根本的な問題
      • 401エラーは認証が通っていないことを示すが、Agent Builderが正しいパラメータで完全なリクエストを組み立てて送信しない限り、設定した API キー認証が実際に試される段階に至らない可能性がある。
  • 次のステップ
    • 「Test tool」画面で正しいパラメータを入力し、完全なリクエストを送信できるようにする

現在のスキーマ

openapi: 3.0.0
info:
  title: Elasticsearch Search API (via GET)
  version: v1
servers:
  - url: 'エンドポイントurl'
paths:
  /_search:
    get:
      summary: Search documents in Elasticsearch using GET
      description: Executes a search query against an Elasticsearch index using GET request. Requires ApiKey authentication via Header.
      operationId: searchElasticsearchGet # Agent Builder がオペレーションを識別するためのID
      parameters:
        - in: query
          name: index
          schema:
            type: string
          required: true
          description: The name of the Elasticsearch index to search. Example - famous-song
        - in: query
          name: q
          schema:
            type: string
          required: false
          description: Query in Lucene query string syntax. Example - artist:Queen
        - in: query
          name: source
          schema:
            type: string
          required: false
          description: Query in Query DSL format (JSON String, URL-encoded). Example - {"query":{"match_all":{}}}
        - in: query
          name: source_content_type
          schema:
            type: string
            enum: ["application/json"]
            default: "application/json"
          required: false 
          description: Content type of the 'source' parameter. Must be 'application/json'.
        - in: query
          name: size
          schema:
            type: integer
            default: 10
          required: false
          description: Number of hits to return.
      responses:
        '200':
          description: Successful response with search results.
          content:
            application/json:
              schema:
                type: object
                properties:
                  took:
                    type: integer
                  timed_out:
                    type: boolean
                  _shards:
                    type: object
                  hits:
                    type: object
                    properties:
                      total:
                        type: object
                      max_score:
                        type: number
                      hits:
                        type: array
                        items:
                          type: object
        '400':
          description: Bad Request. Invalid query parameters or syntax.
        '401':
          description: Unauthorized. Invalid API Key or authentication setup.
        '404':
          description: Not Found. Index not found.
        '500':
          description: Internal Server Error. Elasticsearch error.
components:
  securitySchemes:
    ApiKeyAuth: 
      type: apiKey
      in: header
      name: Authorization # 使用するヘッダー名 (Elasticsearch の ApiKey 認証はこれ)
      description: "Elasticsearch API Key authentication. The value should be the complete string 'ApiKey YOUR_BASE64_ENCODED_ID:API_KEY'. Provide this full value in the Agent Builder authentication settings."
security:
  - ApiKeyAuth: [] # この securitySchemes (ApiKeyAuth) を API 全体で有効にする

人気記事

  • BigQueryの無料枠を活用しよう!制限と注意点、活用方法を解説
  • BigQueryでエラー解決!よくあるエラーと対処法
  • BigQueryのレベル別学習リソースまとめ!初心者から上級者まで役立つ情報源
  • 【SUUMOスクレイピング】Struccleで物件データを全件収集
  • BigQuery入門!無料データでSQLの基本文字列関数をマスター
AI_Agent Agent開発
よかったらシェアしてね!
  • URLをコピーしました!
  • URLをコピーしました!
目次
カテゴリー
  • AI_Agent (110)
    • Agent開発 (110)
  • BigQuery (100)
    • BigQueryTips (11)
    • BigQueryでデータ分析 (49)
    • BigQueryのFAQ (1)
    • BigQuery入門 (8)
    • BigQuery学習教材 (22)
    • BigQuery導入ガイド (3)
    • BigQuery最新情報 (3)
    • BigQuery活用事例 (4)
  • Struccle (153)
    • Struccleでスクレイピング (10)
      • suumoの物件データを収集&分析 (1)
      • アニマルジョブの電話番号、メールアドレスを全件収集 (1)
      • データ集計 (6)
      • ホットペッパービューティーのヘアサロンデータを収集&分析 (1)
      • 食べログの飲食店データを収集&分析 (1)
    • Struccleデータ料金事例 (142)
      • 商品分析 (15)
      • 営業リスト (88)
      • 競合分析&市場調査 (58)
      • 自動車 (11)
      • 自社活用 (7)
    • Struccle活用企業様の紹介 (1)
  • 当ブログのコーディング実行環境設定 (2)
目次