Os modos de implantação são uma configuração para envolvidos no projeto. A troca entre os dois modos não move nem exclui seus dados do outro modo. Você pode usar a API UpdateRagEngineConfig para alternar entre os modos de implantação sem servidor e do Spanner. Você também pode usar essa API para definir o nível no modo de implantação do Spanner ou para cancelar o provisionamento do modo do Spanner e interromper o faturamento. Use a API GetRagEngineConfig para ler as informações do modo de implantação atual.
Mudando para o modo sem servidor
Os exemplos de código a seguir mostram como mudar seu RagEngineConfig para o modo sem servidor:
Console
- No console do Google Cloud , acesse a página Mecanismo RAG.
- Selecione a região em que o Mecanismo RAG da Vertex AI está sendo executado.
- Clique na opção Mudar para sem servidor. Ele pode não aparecer se você estiver no modo sem servidor. Você pode verificar seu modo atual no rótulo no canto superior direito da página.
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)
Mudar para o modo Spanner
Os exemplos de código a seguir mostram como mudar seu RagEngineConfig para o modo do Spanner. Se você já usou o modo Spanner e escolheu um nível, não precisa informá-lo explicitamente ao mudar. Caso contrário, consulte os exemplos de código abaixo sobre como mudar para o modo do Spanner ao fornecer um nível.
Console
- No console do Google Cloud , acesse a página Mecanismo RAG.
- Selecione a região em que o Mecanismo RAG da Vertex AI está sendo executado.
- Clique na opção Mudar para o Spanner. Ele pode não estar visível se você estiver no modo Spanner. Você pode verificar o modo atual no rótulo do modo.
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)
Ler seu RagEngineConfig atual
Os exemplos de código a seguir mostram como ler seu RagEngineConfig para ver qual modo e nível foram escolhidos:
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)
Atualizar o nível no modo do Spanner
Os exemplos de código a seguir demonstram como atualizar o nível no modo do Spanner:
Atualize seu RagEngineConfig para o nível escalonado do modo Spanner
Os exemplos de código a seguir demonstram como definir o RagEngineConfig para o modo do Spanner com o nível escalonado:
Console
- No console do Google Cloud , acesse a página Mecanismo RAG.
- Selecione a região em que o Mecanismo RAG da Vertex AI está sendo executado.
- Clique na opção Mudar para o Spanner, se ainda não estiver no modo Spanner.
- Clique em Configurar o mecanismo RAG. O painel Configurar o mecanismo RAG é exibido.
- Selecione o nível em que você quer executar o mecanismo RAG.
- Clique em Salvar.
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)
Atualize seu RagEngineConfig para o modo Spanner com o nível Básico
Os exemplos de código a seguir demonstram como definir o RagEngineConfig para o modo do Spanner com o nível básico:
Console
- No console do Google Cloud , acesse a página Mecanismo RAG.
- Selecione a região em que o Mecanismo RAG da Vertex AI está sendo executado.
- Clique na opção Mudar para o Spanner, se ainda não estiver no modo Spanner.
- Clique em Configurar o mecanismo RAG. O painel Configurar o mecanismo RAG é exibido.
- Selecione o nível em que você quer executar o mecanismo RAG.
- Clique em Salvar.
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)
Atualizar o RagEngineConfig para o nível não provisionado
Os exemplos de código a seguir demonstram como definir o RagEngineConfig para o modo do Spanner com o nível não provisionado. Isso vai excluir permanentemente todos os dados do seu modo de implantação do Spanner e interromper as despesas de faturamento decorrentes dele.
Console
- No console do Google Cloud , acesse a página Mecanismo RAG.
- Selecione a região em que o Mecanismo RAG da Vertex AI está sendo executado.
- Clique na opção Mudar para o Spanner, se ainda não estiver no modo Spanner.
- Clique em Excluir mecanismo RAG. Uma caixa de diálogo de confirmação é exibida.
- Verifique se você está prestes a excluir seus dados no mecanismo de RAG da Vertex AI inserindo delete.
- Clique em Confirmar.
- Clique em Salvar.
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)