Passare da una modalità all'altra

Le modalità di deployment sono una configurazione a livello di progetto. Il passaggio da una modalità all'altra non comporta lo spostamento o l'eliminazione dei dati dall'altra modalità. Puoi utilizzare l'API UpdateRagEngineConfig per passare dalla modalità di deployment serverless a quella di Spanner e viceversa. Puoi anche utilizzare questa API per impostare il livello della modalità di deployment di Spanner o per eseguire il deprovisioning della modalità Spanner per interrompere la fatturazione. Puoi utilizzare l'API GetRagEngineConfig per leggere le informazioni sulla modalità di deployment attuale.

Passaggio alla modalità serverless

I seguenti esempi di codice mostrano come passare RagEngineConfig alla modalità serverless:

Console

  1. Nella console Google Cloud , vai alla pagina RAG Engine.

    Vai a RAG Engine

  2. Seleziona la regione in cui è in esecuzione il motore RAG.
  3. Fai clic sull'opzione Passa a serverless. Potrebbe non essere visibile se sei in modalità serverless. Puoi verificare la modalità corrente dall'etichetta della modalità nella sezione in alto a destra della pagina.

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)

Passaggio alla modalità Spanner

I seguenti esempi di codice mostrano come passare RagEngineConfig alla modalità Spanner. Se hai già utilizzato la modalità Spanner e hai scelto un livello, non è necessario specificarlo esplicitamente durante il passaggio. In caso contrario, consulta gli esempi di codice riportati di seguito su come passare alla modalità Spanner fornendo un livello.

Console

  1. Nella console Google Cloud , vai alla pagina RAG Engine.

    Vai a RAG Engine

  2. Seleziona la regione in cui è in esecuzione il motore RAG.
  3. Fai clic sull'opzione Passa a Spanner. Potrebbe non essere visibile se sei in modalità Spanner. Puoi verificare la modalità corrente dall'etichetta della modalità.

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)

Leggi il tuo RagEngineConfig attuale

I seguenti esempi di codice mostrano come leggere il tuo RagEngineConfig per vedere quale modalità e livello sono stati scelti:

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)

Aggiorna il livello in modalità Spanner

I seguenti esempi di codice mostrano come aggiornare il livello in modalità Spanner:

Aggiorna RagEngineConfig al livello Scaled della modalità Spanner

I seguenti esempi di codice mostrano come impostare RagEngineConfig sulla modalità Spanner con il livello Scaled:

Console

  1. Nella console Google Cloud , vai alla pagina RAG Engine.

    Vai a RAG Engine

  2. Seleziona la regione in cui è in esecuzione il motore RAG.
  3. Fai clic sull'opzione Passa a Spanner, se non sei già in modalità Spanner.
  4. Fai clic su Configura RAG Engine. Viene visualizzato il riquadro Configura RAG Engine.
  5. Seleziona il livello con cui vuoi eseguire il motore RAG.
  6. Fai clic su Salva.

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)

Aggiorna RagEngineConfig alla modalità Spanner con il livello Base

I seguenti esempi di codice mostrano come impostare RagEngineConfig sulla modalità Spanner con il livello Base:

Console

  1. Nella console Google Cloud , vai alla pagina RAG Engine.

    Vai a RAG Engine

  2. Seleziona la regione in cui è in esecuzione il motore RAG.
  3. Fai clic sull'opzione Passa a Spanner, se non sei già in modalità Spanner.
  4. Fai clic su Configura RAG Engine. Viene visualizzato il riquadro Configura RAG Engine.
  5. Seleziona il livello in cui vuoi eseguire il motore RAG.
  6. Fai clic su Salva.

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)

Aggiorna RagEngineConfig al livello Unprovisioned

I seguenti esempi di codice mostrano come impostare RagEngineConfig sulla modalità Spanner con il livello Non sottoposto a provisioning. In questo modo, tutti i dati della modalità di deployment di Spanner verranno eliminati definitivamente e le spese di fatturazione derivanti verranno interrotte.

Console

  1. Nella console Google Cloud , vai alla pagina RAG Engine.

    Vai a RAG Engine

  2. Seleziona la regione in cui è in esecuzione il motore RAG.
  3. Fai clic sull'opzione Passa a Spanner, se non sei già in modalità Spanner.
  4. Fai clic su Elimina RAG Engine. Viene visualizzata una finestra di dialogo di conferma.
  5. Conferma che stai per eliminare i tuoi dati nel motore RAG inserendo delete.
  6. Fai clic su Conferma.
  7. Fai clic su Salva.

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)