無題
ADKストリーミングクイックスタート¶
このクイックスタートでは、簡単なエージェントを作成し、ADKストリーミングを使用して、低遅延で双方向の音声およびビデオ通信を可能にする方法を学びます。ADKをインストールし、基本的な「Google検索」エージェントを設定し、adk webツールでストリーミングでエージェントを実行し、ADKストリーミングとFastAPIを使用して簡単な非同期ウェブアプリを自分で構築する方法を説明します。
2. Project Structure
Create the following folder structure with empty files:
adk-streaming/ # Project folder
└── app/ # the web app folder
├── .env # Gemini API key
└── google_search_agent/ # Agent folder
├── __init__.py # Python package
└── agent.py # Agent definition
agent.py
Copy-paste the following code block to the agent.py.
For model, please double check the model ID as described earlier in the Models section.
from google.adk.agents import Agent
from google.adk.tools import google_search # Import the tool
root_agent = Agent(
name = "basic_search_agent", # A unique name for the agent.
model = "gemini-2.0-flash-live-preview-04-09", # LLM that agent will use.
description = "Agent to answer questions using Google Search.", # A short description of the agent's purpose.
instruction = "You are an expert researcher. You always stick to the facts.", # Instructions to set the agent's behavior.
tools = [google_search] # Add google_search tool to perform grounding with Google search.
)
Note: To enable both text and audio/video input, the model must support the generateContent (for text) and bidiGenerateContent methods. Verify these capabilities by referring to the List Models Documentation. This quickstart utilizes the gemini-2.0-flash-exp model for demonstration purposes.
agent.py is where all your agent(s)' logic will be stored, and you must have a root_agentdefined.
Notice how easily you integrated grounding with Google Search capabilities. The Agent class and the google_search tool handle the complex interactions with the LLM and grounding with the search API, allowing you to focus on the agent's purpose and behavior.

Copy-paste the following code block to __init__.py and main.py files.
from . import agent
3. Set up the platform¶
To run the agent, choose a platform from either Google AI Studio or Google Cloud Vertex AI:
# excute these commands in terminal
export GOOGLE_GENAI_USE_VERTEXAI=TRUE
export GOOGLE_CLOUD_PROJECT=PASTE_YOUR_ACTUAL_PROJECT_ID
export GOOGLE_CLOUD_LOCATION=us-central1
4. Try the agent with adk web¶
マンチカン航海士の知恵袋
マンチカン航海士が記事全文を読んでいるニャ... 🐾