fix: switch RAG corpus to Serverless mode (RagManagedDb) in us-central1

This commit is contained in:
chrischristiansen-glitch 2026-05-24 16:13:24 +02:00
parent 09dcb4d1a2
commit a5fd5f58e8

View File

@ -3,9 +3,8 @@
setup_corpus.py Create a Vertex AI RAG Engine corpus and import documents. setup_corpus.py Create a Vertex AI RAG Engine corpus and import documents.
Project: propane-will-491900-m5 Project: propane-will-491900-m5
IMPORTANT: RAG Engine in us-central1 requires allowlist access. Serverless mode (RagManagedDb) no allowlist required.
Contact: vertex-ai-rag-engine-support@google.com Region: us-central1
Alternative: Use us-east1 or us-east4 for immediate access.
""" """
import os import os
@ -13,7 +12,7 @@ import vertexai
from vertexai import rag from vertexai import rag
PROJECT_ID = "propane-will-491900-m5" PROJECT_ID = "propane-will-491900-m5"
LOCATION = os.environ.get("RAG_LOCATION", "us-east1") # change to us-central1 after allowlist LOCATION = os.environ.get("RAG_LOCATION", "us-central1")
CORPUS_DISPLAY_NAME = os.environ.get("RAG_CORPUS_NAME", "oavauco-knowledge-base") CORPUS_DISPLAY_NAME = os.environ.get("RAG_CORPUS_NAME", "oavauco-knowledge-base")
GCS_SOURCE = os.environ.get( GCS_SOURCE = os.environ.get(
"RAG_GCS_SOURCE", "RAG_GCS_SOURCE",
@ -31,9 +30,12 @@ def main():
corpus = c corpus = c
break break
else: else:
print(f"Creating RAG corpus '{CORPUS_DISPLAY_NAME}' in {LOCATION}...") print(f"Creating RAG corpus '{CORPUS_DISPLAY_NAME}' in {LOCATION} (Serverless)...")
corpus = rag.create_corpus( corpus = rag.create_corpus(
display_name=CORPUS_DISPLAY_NAME, display_name=CORPUS_DISPLAY_NAME,
backend_config=rag.RagVectorDbConfig(
rag_managed_db=rag.RagManagedDb() # Serverless — no Spanner
),
) )
print(f"Corpus created: {corpus.name}") print(f"Corpus created: {corpus.name}")