Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🆕 新增文件
app/middleware/smart_routing_middleware.py
— 智能路由中间件核心实现📝 修改文件
app/middleware/middleware.py
— 注册智能路由中间件app/config/config.py
— 添加URL_NORMALIZATION_ENABLED
配置Dockerfile
— 添加环境变量默认配置✨ 核心功能
智能 URL 检测和转换
/v1beta/v1/chat/completions
→/v1/chat/completions
/openai/chat
→/openai/v1/chat/completions
/hf/models
→/hf/v1/models
/gemini-pro
→/v1beta/models/gemini-pro:generateContent
格式优先级处理
OpenAI
>HF
>Gemini
> 默认正确格式保护(已规范的不动)
/v1beta/models/gemini-2.0-flash:generateContent
/openai/v1/chat/completions
/v1/chat/completions
🔧 配置
URL_NORMALIZATION_ENABLED=true
(默认 false)ENV URL_NORMALIZATION_ENABLED=false
🔄 向后兼容
🐛 Fixes
/v1beta/v1/chat/completions
重复路径段