mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-27 01:22:18 +00:00
fix(oci/embed): validate OCI credentials in validate_environment
Mirror OCIChatConfig.validate_environment so embedding requests fail fast with a clear error when oci_user/oci_fingerprint/oci_tenancy/ oci_compartment_id or an oci_key/oci_key_file is missing, instead of deferring the failure until sign_request. Co-authored-by: Yassin Kortam <yassin@berri.ai>
This commit is contained in:
parent
802a5f833d
commit
032381a500
1 changed files with 23 additions and 0 deletions
|
|
@ -113,6 +113,29 @@ class OCIEmbedConfig(BaseEmbeddingConfig):
|
|||
api_key: Optional[str] = None,
|
||||
api_base: Optional[str] = None,
|
||||
) -> dict:
|
||||
if optional_params.get("oci_signer") is None:
|
||||
creds = resolve_oci_credentials(optional_params)
|
||||
missing = [
|
||||
k
|
||||
for k in (
|
||||
"oci_user",
|
||||
"oci_fingerprint",
|
||||
"oci_tenancy",
|
||||
"oci_compartment_id",
|
||||
)
|
||||
if not creds.get(k)
|
||||
]
|
||||
if missing or not (creds.get("oci_key") or creds.get("oci_key_file")):
|
||||
raise OCIError(
|
||||
status_code=401,
|
||||
message=(
|
||||
"Missing required parameters: oci_user, oci_fingerprint, oci_tenancy, "
|
||||
"oci_compartment_id and at least one of oci_key or oci_key_file. "
|
||||
"These can be supplied via optional_params or via OCI_USER, OCI_FINGERPRINT, "
|
||||
"OCI_TENANCY, OCI_COMPARTMENT_ID, OCI_KEY_FILE environment variables. "
|
||||
"Alternatively, provide an oci_signer object from the OCI SDK."
|
||||
),
|
||||
)
|
||||
return validate_oci_environment(headers, optional_params, api_key)
|
||||
|
||||
def get_complete_url(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue