모드 간 전환

배포 모드는 프로젝트 수준 구성입니다. 두 모드 간에 전환해도 다른 모드의 데이터가 이동하거나 삭제되지 않습니다. UpdateRagEngineConfig API를 사용하여 서버리스 배포 모드와 Spanner 배포 모드 간에 전환할 수 있습니다. 이 API를 사용하여 Spanner 배포 모드에서 등급을 설정하거나 Spanner 모드를 프로비저닝 해제하여 청구를 중지할 수도 있습니다. GetRagEngineConfig API를 사용하여 현재 배포 모드 정보를 읽을 수 있습니다.

서버리스 모드로 전환

다음 코드 샘플에서는 RagEngineConfig를 서버리스 모드로 전환하는 방법을 보여줍니다.

콘솔

  1. 콘솔에서 RAG Engine 페이지로 이동합니다. Google Cloud

    RAG Engine으로 이동

  2. Vertex AI RAG Engine이 실행 중인 리전을 선택합니다.
  3. 서버리스로 전환 옵션을 클릭합니다. 서버리스 모드인 경우 표시되지 않을 수 있습니다. 페이지 오른쪽 상단의 모드 라벨에서 현재 모드를 확인할 수 있습니다.

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)

Spanner 모드로 전환

다음 코드 샘플에서는 RagEngineConfig를 Spanner 모드로 전환하는 방법을 보여줍니다. 이전에 Spanner 모드를 사용하고 등급을 선택한 경우 전환 중에 명시적으로 제공할 필요가 없습니다. 그렇지 않은 경우 등급을 제공하면서 Spanner 모드로 전환하는 방법을 보여주는 아래 코드 예시를 참고하세요.

콘솔

  1. 콘솔에서 RAG Engine 페이지로 이동합니다. Google Cloud

    RAG Engine으로 이동

  2. Vertex AI RAG Engine이 실행 중인 리전을 선택합니다.
  3. 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 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)

현재 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 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)

Spanner 모드에서 등급 업데이트

다음 코드 샘플에서는 Spanner 모드에서 등급을 업데이트하는 방법을 보여줍니다.

RagEngineConfig를 Spanner 모드 확대 단계 등급으로 업데이트

다음 코드 샘플에서는 RagEngineConfig를 확대 단계 등급이 있는 Spanner 모드로 설정하는 방법을 보여줍니다.

콘솔

  1. 콘솔에서 RAG Engine 페이지로 이동합니다. Google Cloud

    RAG Engine으로 이동

  2. Vertex AI RAG Engine이 실행 중인 리전을 선택합니다.
  3. Spanner 모드가 아닌 경우 Spanner로 전환 옵션을 클릭합니다.
  4. RAG Engine 구성 을 클릭합니다. RAG 엔진 구성 창이 표시됩니다.
  5. RAG Engine을 실행할 등급을 선택합니다.
  6. 저장 을 클릭합니다.

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)

RagEngineConfig를 기본 등급이 있는 Spanner 모드로 업데이트

다음 코드 샘플에서는 RagEngineConfig를 기본 등급이 있는 Spanner 모드로 설정하는 방법을 보여줍니다.

콘솔

  1. 콘솔에서 RAG Engine 페이지로 이동합니다. Google Cloud

    RAG Engine으로 이동

  2. Vertex AI RAG Engine이 실행 중인 리전을 선택합니다.
  3. Spanner 모드가 아닌 경우 Spanner로 전환 옵션을 클릭합니다.
  4. RAG Engine 구성 을 클릭합니다. RAG 엔진 구성 창이 표시됩니다.
  5. RAG 엔진을 실행할 등급을 선택합니다.
  6. 저장 을 클릭합니다.

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)

RagEngineConfig를 프로비저닝되지 않음 등급으로 업데이트

다음 코드 샘플에서는 RagEngineConfig를 프로비저닝되지 않음 등급이 있는 Spanner 모드로 설정하는 방법을 보여줍니다. 이렇게 하면 Spanner 배포 모드의 모든 데이터가 영구적으로 삭제되고 이로 인해 발생하는 청구 비용이 중지됩니다.

콘솔

  1. 콘솔에서 RAG Engine 페이지로 이동합니다. Google Cloud

    RAG Engine으로 이동

  2. Vertex AI RAG Engine이 실행 중인 리전을 선택합니다.
  3. Spanner 모드가 아닌 경우 Spanner로 전환 옵션을 클릭합니다.
  4. RAG 엔진 삭제 를 클릭합니다. 확인 대화상자가 나타납니다.
  5. delete 를 입력하여 Vertex AI RAG Engine에서 데이터를 삭제할 것임을 확인합니다.
  6. 확인 을 클릭합니다.
  7. 저장 을 클릭합니다.

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)