refs #703: configure OCI GenAI root compartment
This commit is contained in:
@@ -26,7 +26,10 @@ ALLOWED_OCI_SETTINGS = frozenset(
|
||||
"OCI_PROFILE",
|
||||
}
|
||||
)
|
||||
_COMPARTMENT_ID = re.compile(r"^ocid1\.compartment\.[A-Za-z0-9._-]+$")
|
||||
# OCI permits the tenancy OCID when the root compartment is selected.
|
||||
_COMPARTMENT_OR_ROOT_ID = re.compile(
|
||||
r"^ocid1\.(?:compartment|tenancy)\.[A-Za-z0-9._-]+$"
|
||||
)
|
||||
|
||||
|
||||
class CompletionClient(Protocol):
|
||||
@@ -95,7 +98,7 @@ def load_oci_settings() -> OCISettings:
|
||||
raise ValueError("unsupported OCI authentication mode")
|
||||
|
||||
compartment_id = values.get("OCI_GENAI_COMPARTMENT_ID", "").strip()
|
||||
if not _COMPARTMENT_ID.fullmatch(compartment_id):
|
||||
if not _COMPARTMENT_OR_ROOT_ID.fullmatch(compartment_id):
|
||||
raise ValueError("OCI Generative AI compartment is not configured")
|
||||
return OCISettings(
|
||||
auth_type=auth_type,
|
||||
|
||||
Reference in New Issue
Block a user