デプロイ モードはプロジェクト レベルの構成です。2 つのモードを切り替えても、データが他のモードに移動したり削除されたりすることはありません。UpdateRagEngineConfig
API を使用して、サーバーレス デプロイ モードと Spanner デプロイ モードを切り替えることができます。また、この API
を使用して、Spanner デプロイ モードのティアを設定したり、Spanner モードのプロビジョニングを解除して課金を停止したりすることもできます。GetRagEngineConfig API を使用して、現在のデプロイ モードの情報を読み取ることができます。
サーバーレス モードに切り替える
次のコードサンプルでは、RagEngineConfig をサーバーレス モードに切り替える方法を示します。
コンソール
- コンソールで、[RAG Engine] ページに移動します。 Google Cloud
- Vertex AI RAG Engine が実行されているリージョンを選択します。
- [サーバーレスに切り替え] オプションをクリックします。サーバーレス モードの場合、表示されないことがあります。現在のモードは、ページの右上にあるモードラベルで確認できます。
REST
PROJECT_ID: Your project ID.
LOCATION: The region to process the request.
curl -X PATCH \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragEngineConfig -d "{'ragManagedDbConfig': {'serverless': {}}}"
Python
from vertexai.preview import rag
import vertexai
PROJECT_ID = YOUR_PROJECT_ID
LOCATION = YOUR_RAG_ENGINE_LOCATION
# Initialize Vertex AI API once per session
vertexai.init(project=PROJECT_ID, location=LOCATION)
rag_engine_config_name=f"projects/{PROJECT_ID}/locations/{LOCATION}/ragEngineConfig"
new_rag_engine_config = rag.RagEngineConfig(
name=rag_engine_config_name,
rag_managed_db_config=rag.RagManagedDbConfig(mode=rag.Serverless()),
)
updated_rag_engine_config = rag.rag_data.update_rag_engine_config(
rag_engine_config=new_rag_engine_config
)
print(updated_rag_engine_config)
Spanner モードに切り替える
次のコードサンプルでは、RagEngineConfig を Spanner モードに切り替える方法を示します。以前に Spanner
モードを使用していて、ティアを選択している場合は、切り替え時に明示的に指定する必要はありません。そうでない場合は、ティアを指定しながら
Spanner モードに切り替える方法について、以下のコード例をご覧ください。
コンソール
- コンソールで、[RAG Engine] ページに移動します。 Google Cloud
- Vertex AI RAG Engine が実行されているリージョンを選択します。
- [Spanner に切り替え] オプションをクリックします。Spanner モードの場合、表示されないことがあります。現在のモードは、モードラベルで確認できます。
REST
PROJECT_ID: Your project ID.
LOCATION: The region to process the request.
curl -X PATCH \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragEngineConfig -d "{'ragManagedDbConfig': {'spanner': {}}}"
Python
from vertexai.preview import rag
import vertexai
PROJECT_ID = YOUR_PROJECT_ID
LOCATION = YOUR_RAG_ENGINE_LOCATION
# Initialize Vertex AI API once per session
vertexai.init(project=PROJECT_ID, location=LOCATION)
rag_engine_config_name=f"projects/{PROJECT_ID}/locations/{LOCATION}/ragEngineConfig"
new_rag_engine_config = rag.RagEngineConfig(
name=rag_engine_config_name,
rag_managed_db_config=rag.RagManagedDbConfig(mode=rag.Spanner()),
)
updated_rag_engine_config = rag.rag_data.update_rag_engine_config(
rag_engine_config=new_rag_engine_config
)
print(updated_rag_engine_config)
現在の RagEngineConfig を読み取る
次のコードサンプルでは、RagEngineConfig を読み取って、選択されているモードとティアを確認する方法を示します。
REST
PROJECT_ID: Your project ID.
LOCATION: The region to process the request.
curl -X GET \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragEngineConfig
Python
from vertexai.preview import rag
import vertexai
PROJECT_ID = YOUR_PROJECT_ID
LOCATION = YOUR_RAG_ENGINE_LOCATION
# Initialize Vertex AI API once per session
vertexai.init(project=PROJECT_ID, location=LOCATION)
rag_engine_config = rag.rag_data.get_rag_engine_config(
name=f"projects/{PROJECT_ID}/locations/{LOCATION}/ragEngineConfig"
)
print(rag_engine_config)
Spanner モードのティアを更新する
次のコードサンプルでは、Spanner モードのティアを更新する方法を示します。
RagEngineConfig を Spanner モードのスケールティアに更新する
次のコードサンプルでは、RagEngineConfig をスケールティアの Spanner モードに設定する方法を示します。
コンソール
- コンソールで、[RAG Engine] ページに移動します。 Google Cloud
- Vertex AI RAG Engine が実行されているリージョンを選択します。
- Spanner モードになっていない場合は、[Spanner に切り替え] オプションをクリックします。
- [RAG Engine を構成] をクリックします。[RAG Engine を構成する] ペインが表示されます。
- RAG Engine を実行するティアを選択します。
- [保存] をクリックします。
REST
PROJECT_ID: Your project ID.
LOCATION: The region to process the request.
curl -X PATCH \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragEngineConfig -d "{'ragManagedDbConfig': {'spanner': {'scaled': {}}}}"
Python
from vertexai.preview import rag
import vertexai
PROJECT_ID = YOUR_PROJECT_ID
LOCATION = YOUR_RAG_ENGINE_LOCATION
# Initialize Vertex AI API once per session
vertexai.init(project=PROJECT_ID, location=LOCATION)
rag_engine_config_name=f"projects/{PROJECT_ID}/locations/{LOCATION}/ragEngineConfig"
new_rag_engine_config = rag.RagEngineConfig(
name=rag_engine_config_name,
rag_managed_db_config=rag.RagManagedDbConfig(mode=rag.Spanner(tier=rag.Scaled())),
)
updated_rag_engine_config = rag.rag_data.update_rag_engine_config(
rag_engine_config=new_rag_engine_config
)
print(updated_rag_engine_config)
RagEngineConfig をベーシック ティアの Spanner モードに更新する
次のコードサンプルでは、RagEngineConfig をベーシック ティアの Spanner モードに設定する方法を示します。
コンソール
- コンソールで、[RAG Engine] ページに移動します。 Google Cloud
- Vertex AI RAG Engine が実行されているリージョンを選択します。
- Spanner モードになっていない場合は、[Spanner に切り替え] オプションをクリックします。
- [RAG Engine を構成] をクリックします。[RAG Engine を構成する] ペインが表示されます。
- RAG Engine を実行するティアを選択します。
- [保存] をクリックします。
REST
PROJECT_ID: Your project ID.
LOCATION: The region to process the request.
curl -X PATCH \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragEngineConfig -d "{'ragManagedDbConfig': {'spanner': {'basic': {}}}}"
Python
from vertexai.preview import rag
import vertexai
PROJECT_ID = YOUR_PROJECT_ID
LOCATION = YOUR_RAG_ENGINE_LOCATION
# Initialize Vertex AI API once per session
vertexai.init(project=PROJECT_ID, location=LOCATION)
rag_engine_config_name=f"projects/{PROJECT_ID}/locations/{LOCATION}/ragEngineConfig"
new_rag_engine_config = rag.RagEngineConfig(
name=rag_engine_config_name,
rag_managed_db_config=rag.RagManagedDbConfig(mode=rag.Spanner(tier=rag.Basic())),
)
updated_rag_engine_config = rag.rag_data.update_rag_engine_config(
rag_engine_config=new_rag_engine_config
)
print(updated_rag_engine_config)
RagEngineConfig を未プロビジョニング ティアに更新する
次のコードサンプルでは、RagEngineConfig を未プロビジョニング ティアの Spanner
モードに設定する方法を示します。これにより、Spanner デプロイ モードのすべてのデータが完全に削除され、それに関連する課金が停止します。
コンソール
- コンソールで、[RAG Engine] ページに移動します。 Google Cloud
- Vertex AI RAG Engine が実行されているリージョンを選択します。
- Spanner モードになっていない場合は、[Spanner に切り替え] オプションをクリックします。
- [RAG Engine を削除] をクリックします。確認ダイアログが表示されます。
- 「delete 」と入力して、Vertex AI RAG Engine でデータを削除することを確認します。
- [確認] をクリックします。
- [保存] をクリックします。
REST
PROJECT_ID: Your project ID.
LOCATION: The region to process the request.
curl -X PATCH \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
https://LOCATION-aiplatform.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/ragEngineConfig -d "{'ragManagedDbConfig': {'spanner': {'unprovisioned': {}}}}"
Python
from vertexai.preview import rag
import vertexai
PROJECT_ID = YOUR_PROJECT_ID
LOCATION = YOUR_RAG_ENGINE_LOCATION
# Initialize Vertex AI API once per session
vertexai.init(project=PROJECT_ID, location=LOCATION)
rag_engine_config_name=f"projects/{PROJECT_ID}/locations/{LOCATION}/ragEngineConfig"
new_rag_engine_config = rag.RagEngineConfig(
name=rag_engine_config_name,
rag_managed_db_config=rag.RagManagedDbConfig(mode=rag.Spanner(tier=rag.Unprovisioned())),
)
updated_rag_engine_config = rag.rag_data.update_rag_engine_config(
rag_engine_config=new_rag_engine_config
)
print(updated_rag_engine_config)