デプロイモードはプロジェクト レベルの構成です。2 つのモードを切り替えても、もう一方のモードのデータが移動または削除されることはありません。UpdateRagEngineConfig API を使用して、サーバーレス デプロイモードと Spanner デプロイモードを切り替えることができます。この API を使用して、Spanner デプロイモードのティアを設定したり、Spanner モードのプロビジョニングを解除して課金を停止したりすることもできます。GetRagEngineConfig API を使用して、現在のデプロイモード情報を読み取ることができます。
サーバーレス モードに切り替える
次のコードサンプルは、RagEngineConfig をサーバーレス モードに切り替える方法を示しています。
コンソール
- Google Cloud コンソールで、[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': {'serverless': {}}}"
Python
from vertexai.preview import rag
import vertexai
PROJECT_ID = YOUR_PROJECT_ID
LOCATION = YOUR_RAG_ENGINE_LOCATION
# Initialize Agent Platform 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 モードに切り替える方法について、以下のコード例をご覧ください。
コンソール
- Google Cloud コンソールで、[RAG Engine] ページに移動します。
- 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 Agent Platform 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 Agent Platform 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 モードに設定する方法を示します。
コンソール
- Google Cloud コンソールで、[RAG Engine] ページに移動します。
- 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 Agent Platform 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 モードに設定する方法を示します。
コンソール
- Google Cloud コンソールで、[RAG Engine] ページに移動します。
- 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 Agent Platform 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 デプロイモードからすべてのデータが完全に削除され、それによって発生する請求費用が停止します。
コンソール
- Google Cloud コンソールで、[RAG Engine] ページに移動します。
- RAG Engine が実行されているリージョンを選択します。
- まだ Spanner モードになっていない場合は、[Spanner に切り替える] オプションをクリックします。
- [RAG Engine を削除] をクリックします。確認ダイアログが表示されます。
- 「delete」と入力して、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 Agent Platform 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)