Browse Source

fix(openai): 简化OpenAI客户端异常抛出参数

- 移除ApiException中多余的空字符串参数
- 统一异常消息格式,仅保留必要信息
- 清理未使用的异常参数传递
master
zhangf@suq.cn 7 days ago
parent
commit
dbba5ee924
  1. 8
      plugin/piadmin/app/utils/openai/OpenAiClient.php

8
plugin/piadmin/app/utils/openai/OpenAiClient.php

@ -15,16 +15,16 @@ class OpenAiClient
$defaultPlatform = config('openai.default');
$platform = config('openai.platforms.' . $defaultPlatform, []);
if (empty($platform)) {
throw new ApiException("默认的AI平台: {$defaultPlatform} 未配置", '', '', []);
throw new ApiException("默认的AI平台: {$defaultPlatform} 未配置");
}
if (empty($platform['base_url'])) {
throw new ApiException("默认的AI平台: {$defaultPlatform} 未配置base_url", '', '', []);
throw new ApiException("默认的AI平台: {$defaultPlatform} 未配置base_url");
}
if (empty($platform['api_key'])) {
throw new ApiException("默认的AI平台: {$defaultPlatform} 未配置api_key", '', '', []);
throw new ApiException("默认的AI平台: {$defaultPlatform} 未配置api_key");
}
if (empty($platform['model'])) {
throw new ApiException("默认的AI平台: {$defaultPlatform} 未配置model", '', '', []);
throw new ApiException("默认的AI平台: {$defaultPlatform} 未配置model");
}
return $platform;
}

Loading…
Cancel
Save