環境を設定する

Google Cloud プロジェクトを設定する

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. Google Cloud Console の [プロジェクト セレクタ] ページで、Google Cloud プロジェクトを選択または作成します。

    プロジェクト セレクタに移動

  3. Google Cloud プロジェクトで課金が有効になっていることを確認します

  4. Vertex AI and Cloud Storage API を有効にします。

    API を有効にする

  5. Google Cloud Console の [プロジェクト セレクタ] ページで、Google Cloud プロジェクトを選択または作成します。

    プロジェクト セレクタに移動

  6. Google Cloud プロジェクトで課金が有効になっていることを確認します

  7. Vertex AI and Cloud Storage API を有効にします。

    API を有効にする

必要なロールを取得する

Reasoning Engine の使用に必要な権限を取得するには、プロジェクトに関する次の IAM ロールを付与するよう管理者に依頼してください。

ロールの付与の詳細については、アクセスの管理をご覧ください。

必要な権限は、カスタムロールや他の事前定義ロールから取得することもできます。

Cloud Storage バケットを作成する

Reasoning Engine は、デプロイ プロセスの一環として、アプリケーションのアーティファクトを Cloud Storage バケットにステージングします。Vertex AI SDK for Python の使用を認証されたプリンシパル(ご自身またはサービス アカウント)に、このバケットへの Storage Admin アクセス権があることを確認します。Vertex AI SDK for Python がコードを自動的にパッケージ化して、後の段階でこのバケットに書き込むため、この権限が必要になります。

Google Cloud コンソール

  1. In the Google Cloud console, go to the Cloud Storage Buckets page.

    Go to Buckets page

  2. Click Create bucket.
  3. On the Create a bucket page, enter your bucket information. To go to the next step, click Continue.
    • For Name your bucket, enter a name that meets the bucket naming requirements.
    • For Choose where to store your data, do the following:
      • Select a Location type option.
      • Select a Location option.
    • For Choose a default storage class for your data, select a storage class.
    • For Choose how to control access to objects, select an Access control option.
    • For Advanced settings (optional), specify an encryption method, a retention policy, or bucket labels.
  4. Click Create.

コマンドライン

    Create a Cloud Storage bucket and configure it as follows:
    • STORAGE_CLASS は、目的のストレージ クラスで置き換えます。
    • LOCATION は、目的のロケーション(ASIAEU、または US)で置き換えます。
    • BUCKET_NAME は、 バケット名の要件を満たすバケット名に置き換えます。
    • gcloud storage buckets create gs://BUCKET_NAME --default-storage-class STORAGE_CLASS --location LOCATION

Vertex AI SDK for Python をインストールして初期化する

次のコマンドを実行して、Reasoning Engine 用の Vertex AI SDK for Python をインストールします。

pip install google-cloud-aiplatform[reasoningengine,langchain]

次のコードを実行して、Reasoning Engine の SDK のインポートと初期化を行います。

import vertexai
from vertexai.preview import reasoning_engines

vertexai.init(
    project="PROJECT_ID",
    location="LOCATION",
    staging_bucket="gs://BUCKET_NAME",
)
  • PROJECT_ID: 実際のプロジェクト ID。
  • LOCATION: リージョン。現在のところ、us-central1 のみがサポートされています。
  • BUCKET_NAME: Google Cloud バケット。

次のステップ