fix: normalize relay request compatibility and classify errors

This commit is contained in:
wlx committed 2026-09-28 08:12:07 +08:00
1 parent 8a2591ef51
commit 4ec47cdb23
3 files changed
+130 -30

No files matched your search

@@ -86,7 +86,9 @@ public class GatewayController {
String providerId=String.valueOf(model.get("providerId"));
boolean mock="provider-mock".equals(providerId);
if(!mock && !provider.isConfigured(providerId)) throw new ApiException("PROVIDER_NOT_CONFIGURED","该供应商尚未配置密钥,不能执行真实调用",503);
ChatMeter.Request request=ChatMeter.request(input,json);
Map<String,Object> normalizedInput = new LinkedHashMap<>(input);
OpenAiCompatibleProvider.prepareRequestForModel(String.valueOf(model.get("upstreamModel")), normalizedInput);
ChatMeter.Request request=ChatMeter.request(normalizedInput,json);
guard.checkRate(UUID.fromString(String.valueOf(key.get("id"))), false);
// Reserve both limits atomically. A queued request never consumes a
// model slot while waiting for the API-Key slot (or vice versa).