Mode deployment adalah konfigurasi tingkat 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 menyetel tingkat pada mode deployment Spanner atau untuk membatalkan penyediaan mode Spanner guna menghentikan penagihan. Anda dapat menggunakan GetRagEngineConfig API untuk membaca informasi mode deployment Anda 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. 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 memilih tingkat, Anda tidak perlu menyediakannya secara eksplisit saat beralih. Jika tidak, lihat contoh kode yang lebih rendah tentang cara beralih ke mode Spanner sambil menyediakan tingkat.
Konsol
- Di konsol Google Cloud , buka halaman RAG Engine.
- Pilih region tempat RAG Engine Anda berjalan.
- Klik opsi Beralih ke Spanner. 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 Anda 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 tingkat pada mode Spanner
Contoh kode berikut menunjukkan cara memperbarui tingkat pada mode Spanner:
Perbarui RagEngineConfig Anda ke tingkat Scaled mode Spanner
Contoh kode berikut menunjukkan cara menyetel RagEngineConfig ke mode Spanner dengan tingkat Scaled:
Konsol
- Di konsol Google Cloud , buka halaman RAG Engine.
- Pilih region tempat RAG Engine Anda berjalan.
- Klik opsi Switch to Spanner, jika belum dalam mode Spanner.
- Klik Configure RAG Engine. Panel Configure RAG Engine akan muncul.
- Pilih tingkat 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)
Perbarui RagEngineConfig ke mode Spanner dengan tingkat Dasar
Contoh kode berikut menunjukkan cara menyetel RagEngineConfig ke mode Spanner dengan tingkat Dasar:
Konsol
- Di konsol Google Cloud , buka halaman RAG Engine.
- Pilih region tempat RAG Engine Anda berjalan.
- Klik opsi Switch to Spanner, jika belum dalam mode Spanner.
- Klik Configure RAG Engine. Panel Configure RAG Engine akan muncul.
- Pilih tingkat yang ingin Anda jalankan 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)
Perbarui RagEngineConfig Anda ke tingkat Unprovisioned
Contoh kode berikut menunjukkan cara menyetel RagEngineConfig ke mode Spanner dengan tingkat Unprovisioned. Tindakan ini akan menghapus semua data dari mode deployment Spanner Anda secara permanen 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 dalam mode Spanner.
- Klik Hapus RAG Engine. Dialog konfirmasi akan muncul.
- Verifikasi bahwa Anda akan menghapus data Anda 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)