5
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Amazon Nova Web Groundingやってみた

Last updated at Posted at 2025-10-30

Amazon NovaにWeb Groundingが登場しました!

外部に検索APIを用意しなくてもWebの情報でグラウンディングができるようになりましたよ!

toolConfig={"tools": [{"systemTool": {"name": "nova_grounding"}}]}を追加するだけで、Tool呼び出しとTool結果の取得までBedrock側でやってくれます。

Boto3の1.40.62で対応が入りました。リリースは10/30です。

systemToolが新しく追加されたので古いBoto3では動作しません。(バリデーションエラーになります)

本日時点の日本の首相を聞いてみましょう。

import json

import boto3

client = boto3.client("bedrock-runtime")

response = client.converse(
    modelId="us.amazon.nova-premier-v1:0",
    messages=[
        {
            "role": "user",
            "content": [{"text": "2025年10月30日時点の、日本の首相を教えて下さい。"}],
        }
    ],
    toolConfig={"tools": [{"systemTool": {"name": "nova_grounding"}}]},
)

print(json.dumps(response, indent=2, ensure_ascii=False))

レスポンス

一回目
{
  "ResponseMetadata": {
    "RequestId": "f5189692-e6c0-4d5f-8df0-0515aa8bec57",
    "HTTPStatusCode": 200,
    "HTTPHeaders": {
      "date": "Thu, 30 Oct 2025 13:53:57 GMT",
      "content-type": "application/json",
      "content-length": "1428",
      "connection": "keep-alive",
      "x-amzn-requestid": "f5189692-e6c0-4d5f-8df0-0515aa8bec57"
    },
    "RetryAttempts": 0
  },
  "output": {
    "message": {
      "role": "assistant",
      "content": [
        {
          "text": "<thinking>The current date is October 30, 2025. To find Japan's prime minister at this exact moment, I need the latest verified information since leadership positions can change.</thinking> "
        },
        {
          "toolUse": {
            "toolUseId": "tooluse_pxLL-oSWfA-5RAhWoq2-kw",
            "name": "nova_grounding",
            "input": {
              "query": "日本の首相はだれか 2025年10月30日時点"
            },
            "type": "server_tool_use"
          }
        },
        {
          "toolResult": {
            "toolUseId": "tooluse_pxLL-oSWfA-5RAhWoq2-kw",
            "content": [
              {
                "text": "[HIDDEN]"
              }
            ],
            "status": "success",
            "type": "nova_grounding_result"
          }
        },
        {
          "text": "高市早苗は、2025年10月30日時点での日本の首相です。"
        },
        {
          "citationsContent": {
            "citations": [
              {
                "location": {
                  "web": {
                    "url": "https://www.cnsoftnews.com/industry/905085183489.html",
                    "domain": "cnsoftnews.com"
                  }
                }
              }
            ]
          }
        },
        {
          "text": "\n\n彼女は自民党総裁として、10月21日に第102代内閣総理大臣に就任しました。"
        },
        {
          "citationsContent": {
            "citations": [
              {
                "location": {
                  "web": {
                    "url": "https://www.cnsoftnews.com/industry/905085183489.html",
                    "domain": "cnsoftnews.com"
                  }
                }
              }
            ]
          }
        },
        {
          "text": "\n\n日本初の女性総理大臣となります。"
        },
        {
          "citationsContent": {
            "citations": [
              {
                "location": {
                  "web": {
                    "url": "https://www.cnsoftnews.com/industry/905085183489.html",
                    "domain": "cnsoftnews.com"
                  }
                }
              }
            ]
          }
        }
      ]
    }
  },
  "stopReason": "end_turn",
  "usage": {
    "inputTokens": 372,
    "outputTokens": 220,
    "totalTokens": 592
  },
  "metrics": {
    "latencyMs": 12988
  }
}

もう一度実行

二回目
{
  "ResponseMetadata": {
    "RequestId": "3a1553f6-3506-4c42-9a32-a4ab7bef4ec2",
    "HTTPStatusCode": 200,
    "HTTPHeaders": {
      "date": "Thu, 30 Oct 2025 13:54:49 GMT",
      "content-type": "application/json",
      "content-length": "851",
      "connection": "keep-alive",
      "x-amzn-requestid": "3a1553f6-3506-4c42-9a32-a4ab7bef4ec2"
    },
    "RetryAttempts": 0
  },
  "output": {
    "message": {
      "role": "assistant",
      "content": [
        {
          "text": "<thinking>The current date is October 30, 2025. To answer who is Japan's prime minister, I need to verify the latest information.</thinking>\n"
        },
        {
          "toolUse": {
            "toolUseId": "tooluse_D1VmVdLg2iRkqyki7SLSkw",
            "name": "nova_grounding",
            "input": {
              "query": "2025年10月30日時点での日本の首相は誰ですか?"
            },
            "type": "server_tool_use"
          }
        },
        {
          "toolResult": {
            "toolUseId": "tooluse_D1VmVdLg2iRkqyki7SLSkw",
            "content": [
              {
                "text": "[HIDDEN]"
              }
            ],
            "status": "success",
            "type": "nova_grounding_result"
          }
        },
        {
          "text": "2025年10月30日時点の日本の首相は、高市早苗です。高市早苗は、2025年10月21日に第102代内閣総理大臣に就任しました。"
        }
      ]
    }
  },
  "stopReason": "end_turn",
  "usage": {
    "inputTokens": 372,
    "outputTokens": 98,
    "totalTokens": 470
  },
  "metrics": {
    "latencyMs": 7260
  }
}

まとめ

  • リクエストのたびに検索結果や答えが変わりそう
  • 情報源のURLがわかるときとわからない時がある
  • 情報源のコンテンツがそのまま取得できるわけではなさそう([HIDDEN]ってなる模様)
  • まぁまぁ待つ。
5
1
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
5
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?