fix: RagManagedDb() takes no arguments in SDK 1.153.1

This commit is contained in:
chrischristiansen-glitch 2026-05-24 19:02:43 +02:00
parent 582967a994
commit 46b3c52607

View File

@ -3,12 +3,12 @@
setup_corpus.py Create a Vertex AI RAG Engine corpus and import documents.
Project: propane-will-491900-m5
Explicitly uses Serverless (RagManagedDb basic tier) to avoid
Spanner allowlist restrictions on new projects in us-central1.
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(tier=1))
tier=1 == BASIC (serverless), tier=2 == ENTERPRISE
RagVectorDbConfig(vector_db=RagManagedDb())
RagManagedDb is a no-arg marker class selecting it is sufficient for serverless.
"""
import os
@ -27,9 +27,6 @@ GCS_SOURCE = os.environ.get(
f"gs://{PROJECT_ID}-agent-staging/rag-docs/",
)
# tier=1 == BASIC (serverless), tier=2 == ENTERPRISE
_TIER_BASIC = 1
def ensure_serverless_engine_config() -> None:
"""
@ -83,10 +80,10 @@ def get_or_create_corpus() -> RagCorpus:
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(
tier=_TIER_BASIC, # 1 = BASIC (serverless)
)
vector_db=rag.RagManagedDb()
),
)
print(f"✓ Corpus created: {corpus.name}")