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

Agentspace を Custom Runtime で構築した Agent Engine で拡張する

Posted at

a3d4aade52097d.png

tl;dr

  • Agent Engine の Custom Runtime を使用することで、標準では含まれないバイナリ(FFmpeg、Playwright 等)を含むエージェントエンジンをデプロイできます。
  • Setup Script でバイナリをインストールし、デプロイ時に設定を追加することでエージェントを拡張することが可能です。

はじめに

この blog では、Agentspace を使用したエージェント開発について書きます。AI エージェントの開発環境は日々進化しており、適切なツールとフレームワークの選択が開発の効率と品質に影響すると考えています。

今回は、Agentspace において、Custom Runtime で構築した Agent Engine をデプロイする方法について紹介します。

Agentspace の概要

Agentspace については、以前作成した記事を参照してください。

Custom Runtime で Agent Engine にデプロイする

Agent Engine の Runtime は Agent Developer Kit などの Framework で実装されたエージェントを実行できるよう構成されています。一方で、エージェント内で画像変換やブラウザ操作などを実行したい場合があります。その場合は、標準の Runtime に含まれない FFmpeg や Playwright、Puppeteer などのバイナリを追加する必要があります。そこで必要になるのが Custom Runtime です。

Agent Engine を Custom Runtime でデプロイするには、以下の手順を実行します。

  1. Setup Script の作成: Binary をインストールする Script を作成します。
    • ポイントは環境変数で PLAYWRIGHT_BROWSERS_PATH を設定してインストールすることです。
    install.sh
    #!/bin/bash
    set -e
    apt-get update
    apt-get install -y python3 python3-pip
    pip3 install playwright
    export PLAYWRIGHT_BROWSERS_PATH=/opt/playwright-browsers
    playwright install-deps
    playwright install chromium firefox webkit
    
  2. デプロイ Script の作成: Setup Script をデプロイ Script から実行するようにします。
    • ポイントは環境変数( PLAYWRIGHT_BROWSERS_PATH )を設定することです。インストールされたバスの Browser を指定しないと、実行時にエラーとなります。 BrowserType.launch: Executable doesn't exist at /home/appuser/.cache/ms-playwright/chromium_headless_shell-1187/chrome-linux/headless_shell
    deploy.py
        remote_app = agent_engines.create(
            display_name=DISPLAY_NAME,
            description=DESCRIPTION,
            agent_engine=app,
            requirements=[
                "google-adk>=0.1.0",
                "google-cloud-aiplatform[adk,agent-engines]>=1.88.0",
                "playwright>=1.40.0",
                "python-dotenv>=1.0.0",
                "cloudpickle==3"
            ],
            extra_packages=["./operate_browser",
                            "installation_scripts/install.sh"],
            build_options={"installation_scripts": [
                "installation_scripts/install.sh"]},
            env_vars={
                "PLAYWRIGHT_BROWSERS_PATH": "/opt/playwright-browsers"
            }
        )
    
  3. デプロイ: 設定が完了したら、エージェントをデプロイします。

これで、Custom Runtime 上でエージェントが実行されるようになります。

Summary

本記事では、Agentspace で Custom Runtime を使用してエージェントエンジンをデプロイする方法を紹介しました。Custom Runtime を活用することで、エージェントの活動範囲を大きく広げることができます。

Closing

今の自分にとっての成功とは。

経営課題の解決に向けた AI エージェントの社会実装で目の前の景色が変わること。

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