mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 17:30:23 +08:00
fix: 修复同族 API 格式转换判断逻辑
- OPENAI 和 OPENAI_CLI 使用不同协议(Chat Completions vs Responses API),需要转换 - CLAUDE/CLAUDE_CLI、GEMINI/GEMINI_CLI 格式相同仅认证不同,可透传 - 添加 max_completion_tokens 参数支持(OpenAI 新参数名) - 移除登录表单冗余的 keyup.enter 事件处理
This commit is contained in:
@@ -59,12 +59,30 @@ def is_format_compatible(
|
||||
if provider_format == client_format_upper:
|
||||
return True, False, None
|
||||
|
||||
# 2. 同族格式匹配(CLAUDE 和 CLAUDE_CLI、OPENAI 和 OPENAI_CLI 等)
|
||||
# 这些格式在响应层面是兼容的,只是认证方式不同
|
||||
# 2. 同族格式检查
|
||||
provider_base = get_base_format(provider_format)
|
||||
client_base = get_base_format(client_format_upper)
|
||||
|
||||
if provider_base == client_base:
|
||||
return True, False, None
|
||||
# 同族格式:检查是否需要转换
|
||||
# - OPENAI 和 OPENAI_CLI 的请求/响应格式不同(Chat Completions vs Responses API),需要转换
|
||||
# - CLAUDE 和 CLAUDE_CLI、GEMINI 和 GEMINI_CLI 格式相同,只是认证不同,可透传
|
||||
if provider_base == "OPENAI":
|
||||
# OPENAI/OPENAI_CLI 同族转换:兼容但需要转换
|
||||
# 检查转换器能力(同族转换不需要全局开关和端点配置)
|
||||
if registry.can_convert_full(
|
||||
client_format_upper, provider_format, require_stream=is_stream
|
||||
):
|
||||
return True, True, None # 兼容,需要转换
|
||||
else:
|
||||
return (
|
||||
False,
|
||||
False,
|
||||
f"不存在 {client_format} <-> {provider_format} 的完整转换器",
|
||||
)
|
||||
else:
|
||||
# CLAUDE/CLAUDE_CLI、GEMINI/GEMINI_CLI 等:格式相同,可透传
|
||||
return True, False, None
|
||||
|
||||
# 3. 检查全局开关
|
||||
if not global_conversion_enabled:
|
||||
|
||||
@@ -3,6 +3,8 @@ Claude CLI Normalizer
|
||||
|
||||
CLAUDE_CLI 的请求/响应 body 与 CLAUDE 一致(Anthropic Messages API),差异主要在认证头。
|
||||
因此这里复用 ClaudeNormalizer 的转换逻辑,仅更换 FORMAT_ID。
|
||||
|
||||
如需 CLI 特殊处理,可覆盖 request_from_internal / request_to_internal 等方法。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -3,6 +3,8 @@ Gemini CLI Normalizer
|
||||
|
||||
GEMINI_CLI 的请求/响应 body 与 GEMINI 一致(Google Gemini API),差异主要在鉴权/UA 等请求层。
|
||||
因此这里复用 GeminiNormalizer 的转换逻辑,仅更换 FORMAT_ID。
|
||||
|
||||
如需 CLI 特殊处理,可覆盖 request_from_internal / request_to_internal 等方法。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -138,12 +138,18 @@ class OpenAINormalizer(FormatNormalizer):
|
||||
|
||||
stop_sequences = self._coerce_str_list(request.get("stop"))
|
||||
|
||||
# 兼容新旧参数名:优先使用 max_completion_tokens,回退到 max_tokens
|
||||
mct = request.get("max_completion_tokens")
|
||||
max_tokens_value = self._optional_int(
|
||||
mct if mct is not None else request.get("max_tokens")
|
||||
)
|
||||
|
||||
internal = InternalRequest(
|
||||
model=model,
|
||||
messages=messages,
|
||||
instructions=instructions,
|
||||
system=system_text,
|
||||
max_tokens=self._optional_int(request.get("max_tokens")),
|
||||
max_tokens=max_tokens_value,
|
||||
temperature=self._optional_float(request.get("temperature")),
|
||||
top_p=self._optional_float(request.get("top_p")),
|
||||
stop_sequences=stop_sequences,
|
||||
|
||||
Reference in New Issue
Block a user