Open4

Gemini API

nyamonsnyamons

URL context toolの登場

https://developers.googleblog.com/en/url-context-tool-for-gemini-api-now-generally-available/

リクエストに URL を含めると、モデルはそれらのページのコンテンツにアクセスし(制限事項のセクションに記載されている URL タイプでない限り)、回答の情報を取得して強化します。

URL コンテキスト ツールは、次のようなタスクに役立ちます。

  • データの抽出: 複数の URL から価格、名前、重要な調査結果などの特定の情報を取得します。
  • ドキュメントの比較: 複数のレポート、記事、PDF を分析して、違いを特定し、傾向を追跡します。
  • コンテンツの統合と作成: 複数のソース URL からの情報を組み合わせて、正確な要約、ブログ投稿、レポートを生成します。
  • コードとドキュメントを分析: GitHub リポジトリまたは技術ドキュメントを指定して、コードの説明、設定手順の生成、質問への回答を行います。
from google import genai
from google.genai.types import Tool, GenerateContentConfig
client = genai.Client()

model_id = "gemini-2.5-flash"
tools = [
     {"url_context": {}},
 ]


response = client.models.generate_content(
    model=model_id,
    contents="What are the top 3 recent announcements from the Gemini API according to https://ai.google.dev/gemini-api/docs/changelog",
    config=GenerateContentConfig(
        tools=tools,
    )
)
for each in response.candidates[0].content.parts:
   print(each.text)