mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 09:20:22 +08:00
refactor: 重构 API 格式相关代码到统一的 api_format 模块
- 新增 src/core/api_format/ 模块,整合所有 API 格式相关功能 - enums.py: APIFormat 枚举定义 - metadata.py: API 格式元数据注册 - headers.py: 请求头处理逻辑 - detection.py: API 格式检测 - conversion/: 格式转换器(Claude/OpenAI/Gemini 互转) - 删除分散在各处的旧实现 - src/core/api_format_metadata.py - src/core/headers.py - src/api/handlers/*/converter.py - src/api/handlers/base/format_converter_registry.py - 更新所有引用路径,使用新的统一模块 - 新增 cli_handler_base 中的格式转换支持
This commit is contained in:
@@ -10,7 +10,8 @@ from typing import Any, Dict, List, Optional
|
||||
|
||||
from pydantic import BaseModel, Field, field_validator, model_validator
|
||||
|
||||
from src.core.enums import APIFormat, ProviderBillingType
|
||||
from src.core.api_format import APIFormat
|
||||
from src.core.enums import ProviderBillingType
|
||||
|
||||
|
||||
class ProxyConfig(BaseModel):
|
||||
|
||||
@@ -49,7 +49,7 @@ class ProviderEndpointCreate(BaseModel):
|
||||
@classmethod
|
||||
def validate_api_format(cls, v: str) -> str:
|
||||
"""验证 API 格式"""
|
||||
from src.core.enums import APIFormat
|
||||
from src.core.api_format import APIFormat
|
||||
|
||||
allowed = [fmt.value for fmt in APIFormat]
|
||||
v_upper = v.upper()
|
||||
@@ -200,7 +200,7 @@ class EndpointAPIKeyCreate(BaseModel):
|
||||
if v is None:
|
||||
return v
|
||||
|
||||
from src.core.enums import APIFormat
|
||||
from src.core.api_format import APIFormat
|
||||
|
||||
allowed = [fmt.value for fmt in APIFormat]
|
||||
validated = []
|
||||
@@ -335,7 +335,7 @@ class EndpointAPIKeyUpdate(BaseModel):
|
||||
if v is None:
|
||||
return v
|
||||
|
||||
from src.core.enums import APIFormat
|
||||
from src.core.api_format import APIFormat
|
||||
|
||||
allowed = [fmt.value for fmt in APIFormat]
|
||||
validated = []
|
||||
|
||||
Reference in New Issue
Block a user