diff --git a/agents/rag/setup_corpus.py b/agents/rag/setup_corpus.py index 7142201..d64f130 100644 --- a/agents/rag/setup_corpus.py +++ b/agents/rag/setup_corpus.py @@ -3,12 +3,9 @@ setup_corpus.py — Create a Vertex AI RAG Engine corpus and import documents. Project: propane-will-491900-m5 -Explicitly uses Serverless (RagManagedDb) to avoid Spanner allowlist -restrictions on new projects in us-central1. - -Tested against vertexai SDK 1.153.1: - RagVectorDbConfig(vector_db=RagManagedDb()) - RagManagedDb is a no-arg marker class — selecting it is sufficient for serverless. +Serverless mode is controlled via the project-level ragEngineConfig PATCH +(ensure_serverless_engine_config). Passing backend_config to create_corpus +triggers a SDK 1.153.1 bug and must be omitted. """ import os @@ -31,7 +28,8 @@ GCS_SOURCE = os.environ.get( def ensure_serverless_engine_config() -> None: """ Pre-flight: set project-level RAG Engine Config to basic (serverless) tier. - Idempotent — safe to re-run. + This is what actually controls the backend — backend_config in create_corpus + is intentionally omitted due to SDK bug in 1.153.1. """ print("Ensuring RAG Engine Config is set to serverless (basic) tier...") endpoint = ( @@ -71,21 +69,17 @@ def ensure_serverless_engine_config() -> None: def get_or_create_corpus() -> RagCorpus: - """Return existing corpus by display name, or create a new serverless one.""" + """Return existing corpus by display name, or create a new one.""" for c in rag.list_corpora(): if c.display_name == CORPUS_DISPLAY_NAME: print(f"Corpus '{CORPUS_DISPLAY_NAME}' already exists: {c.name}") return c - print(f"Creating corpus '{CORPUS_DISPLAY_NAME}' in {LOCATION} (serverless)...") - corpus = rag.create_corpus( - display_name=CORPUS_DISPLAY_NAME, - # RagManagedDb() is a no-arg marker class in SDK 1.153.1 - # Selecting it routes to serverless managed DB (basic tier) - backend_config=rag.RagVectorDbConfig( - vector_db=rag.RagManagedDb() - ), - ) + print(f"Creating corpus '{CORPUS_DISPLAY_NAME}' in {LOCATION}...") + # NOTE: backend_config is intentionally omitted. + # SDK 1.153.1 has a bug where passing any backend_config crashes. + # Serverless mode is already guaranteed by ensure_serverless_engine_config(). + corpus = rag.create_corpus(display_name=CORPUS_DISPLAY_NAME) print(f"✓ Corpus created: {corpus.name}") return corpus