14
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

最小限のコマンドでADKをCloud Runにデプロイする

Posted at

はじめに

アイレット DX開発事業部深川です。
この記事ではAgent Development Kit(ADK)を最小限のコマンドでCloud Runにデプロイする手順を記載します。

前提

  • 開発言語はPython
  • Google Cloudプロジェクトは作成済み
  • リージョンは us-central1
    • ※東京リージョンだと最新のモデルが対応していなかったりするので us-central1 にしています
  • adk CLIを利用
    • gcloud CLIだとDockerfile等の作成も必要なのでadk CLIを利用します

手順

export GOOGLE_CLOUD_PROJECT={your-project-id}
export GOOGLE_CLOUD_LOCATION=us-central1
export GOOGLE_GENAI_USE_VERTEXAI=True
# Set the path to your agent code directory
export AGENT_PATH="./multi_tool_agent" # Assuming multi_tool_agent is in the current directory
  • ターミナルで下記を実行してgcloud CLIを実行できる状態にする
# ログイン
$ gcloud auth login
# デプロイ先のGoogle Cloudプロジェクトを設定する
$ gcloud config set project {your-project-id}
  • 最小限のコマンドでCloud Runにデプロイ
adk deploy cloud_run \
--project=$GOOGLE_CLOUD_PROJECT \
--region=$GOOGLE_CLOUD_LOCATION \
$AGENT_PATH

API テスト

export APP_URL="YOUR_CLOUD_RUN_SERVICE_URL"
export TOKEN=$(gcloud auth print-identity-token)
  • アプリケーション一覧取得
curl -X GET -H "Authorization: Bearer $TOKEN" $APP_URL/list-apps
  • セッション作成
curl -X POST -H "Authorization: Bearer $TOKEN" \
    $APP_URL/apps/multi_tool_agent/users/user_123/sessions/session_abc \
    -H "Content-Type: application/json" \
    -d '{"state": {"preferred_language": "English", "visit_count": 5}}'
  • エージェントを実行
curl -X POST -H "Authorization: Bearer $TOKEN" \
    $APP_URL/run_sse \
    -H "Content-Type: application/json" \
    -d '{
    "app_name": "multi_tool_agent",
    "user_id": "user_123",
    "session_id": "session_abc",
    "new_message": {
        "role": "user",
        "parts": [{
        "text": "What is the capital of Canada?"
        }]
    },
    "streaming": false
    }'

参考

14
0
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
14
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?