Mode deployment adalah konfigurasi level project. Beralih di antara kedua mode tidak akan memindahkan atau menghapus data Anda dari mode lainnya. Anda dapat menggunakan UpdateRagEngineConfig API untuk beralih antara mode deployment Serverless dan Spanner. Anda juga dapat menggunakan API ini untuk menetapkan paket pada mode deployment Spanner atau membatalkan penyediaan mode Spanner untuk menghentikan penagihan. Anda dapat menggunakan GetRagEngineConfig API untuk membaca informasi mode deployment saat ini.
Beralih ke mode Serverless
Contoh kode berikut menunjukkan cara mengalihkan RagEngineConfig ke mode Serverless:
Konsol
- Di konsol Google Cloud , buka halaman RAG Engine.
- Pilih region tempat RAG Engine Anda berjalan.
- Klik opsi Switch to Serverless. Opsi ini mungkin tidak terlihat jika Anda menggunakan mode Serverless. Anda dapat memverifikasi mode saat ini dari label mode di bagian kanan atas halaman.
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)
Beralih ke mode Spanner
Contoh kode berikut menunjukkan cara mengalihkan RagEngineConfig ke mode Spanner. Jika sebelumnya Anda telah menggunakan mode Spanner, dan telah memilih paket, Anda tidak perlu menyediakannya secara eksplisit saat beralih. Jika tidak, lihat contoh kode di bawah tentang cara beralih ke mode Spanner sambil menyediakan paket.
Konsol
- Di konsol Google Cloud , buka halaman RAG Engine.
- Pilih region tempat RAG Engine Anda berjalan.
- Klik opsi Switch to Spanner. Opsi ini mungkin tidak terlihat jika Anda menggunakan mode Spanner. Anda dapat memverifikasi mode saat ini dari label mode.
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)
Membaca RagEngineConfig saat ini
Contoh kode berikut menunjukkan cara membaca RagEngineConfig untuk melihat mode dan tingkat yang dipilih:
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)
Memperbarui paket di mode Spanner
Contoh kode berikut menunjukkan cara memperbarui paket di mode Spanner:
Mengupdate RagEngineConfig ke tingkat Scaled mode Spanner
Contoh kode berikut menunjukkan cara menetapkan RagEngineConfig ke mode Spanner dengan tingkat skala:
Konsol
- Di konsol Google Cloud , buka halaman RAG Engine.
- Pilih region tempat RAG Engine Anda berjalan.
- Klik opsi Switch to Spanner, jika belum berada dalam mode Spanner.
- Klik Configure RAG Engine. Panel Configure RAG Engine akan muncul.
- Pilih paket yang ingin Anda gunakan untuk menjalankan RAG Engine.
- Klik Simpan.
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)
Mengupdate RagEngineConfig ke mode Spanner dengan paket Basic
Contoh kode berikut menunjukkan cara menyetel RagEngineConfig ke mode Spanner dengan paket Basic:
Konsol
- Di konsol Google Cloud , buka halaman RAG Engine.
- Pilih region tempat RAG Engine Anda berjalan.
- Klik opsi Switch to Spanner, jika belum berada dalam mode Spanner.
- Klik Configure RAG Engine. Panel Configure RAG Engine akan muncul.
- Pilih paket yang ingin Anda gunakan untuk menjalankan RAG Engine.
- Klik Simpan.
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)
Mengupdate RagEngineConfig ke paket Unprovisioned
Contoh kode berikut menunjukkan cara menetapkan RagEngineConfig ke mode Spanner dengan paket Unprovisioned. Tindakan ini akan menghapus semua data secara permanen dari mode deployment Spanner Anda dan menghentikan biaya penagihan yang timbul darinya.
Konsol
- Di konsol Google Cloud , buka halaman RAG Engine.
- Pilih region tempat RAG Engine Anda berjalan.
- Klik opsi Switch to Spanner, jika belum berada dalam mode Spanner.
- Klik Delete RAG Engine. Dialog konfirmasi akan muncul.
- Verifikasi bahwa Anda akan menghapus data di RAG Engine dengan memasukkan delete.
- Klik Konfirmasi.
- Klik Simpan.
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)