mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-04 23:00:30 +08:00
Fix: The multi-model comparison page cannot output messages. (#17507)
This commit is contained in:
@@ -435,6 +435,37 @@ def ensure_tenant_model_ids_for_params(tenant_id: str, params: dict) -> dict:
|
||||
|
||||
|
||||
def get_api_key(tenant_id: str, model_name: str):
|
||||
# Try direct model ID (UUID) lookup first
|
||||
exist, model_obj = TenantModelService.get_by_id(model_name)
|
||||
if exist:
|
||||
# Verify tenant ownership through the provider chain
|
||||
ok, provider_obj = TenantModelProviderService.get_by_id(model_obj.provider_id)
|
||||
if not ok:
|
||||
raise LookupError(f"Provider id={model_obj.provider_id} not found for model {model_name}.")
|
||||
if tenant_id != provider_obj.tenant_id:
|
||||
joined_tenants = TenantService.get_joined_tenants_by_user_id(tenant_id)
|
||||
joined_tenant_ids = [t["tenant_id"] for t in joined_tenants]
|
||||
if provider_obj.tenant_id not in joined_tenant_ids:
|
||||
raise LookupError(f"Tenant {tenant_id} has no access to provider owned by tenant {provider_obj.tenant_id}.")
|
||||
|
||||
exist_inst, instance_obj = TenantModelInstanceService.get_by_id(model_obj.instance_id)
|
||||
if not exist_inst:
|
||||
logger.warning(
|
||||
"Direct-ID resolution: instance not found | tenant_id=%s model_id=%s instance_id=%s",
|
||||
tenant_id,
|
||||
model_name,
|
||||
model_obj.instance_id,
|
||||
)
|
||||
raise LookupError(f"Instance {model_obj.instance_id} not found for model {model_name}.")
|
||||
logger.debug(
|
||||
"Direct-ID resolution: resolved | tenant_id=%s model_id=%s instance_id=%s",
|
||||
tenant_id,
|
||||
model_name,
|
||||
model_obj.instance_id,
|
||||
)
|
||||
return instance_obj.api_key
|
||||
|
||||
# Fall back to name-based resolution: model[@instance]@provider
|
||||
_, instance_name, provider_name = split_model_name(model_name)
|
||||
|
||||
if not provider_name:
|
||||
|
||||
Reference in New Issue
Block a user