feat: add intelligent backend routing and model service

- Add modelService for centralized model management
  - Support dynamic model list from config file (data/supported_models.json)
  - Include 2025 latest models: GPT-4.1, o3, o4-mini, Gemini 2.5, etc.
  - File watcher for hot-reload configuration changes

- Improve model detection logic in api.js
  - Priority: modelService lookup → prefix matching fallback
  - Smart backend routing based on model provider

- Add intelligent routing endpoints
  - /v1/chat/completions: unified OpenAI-compatible endpoint
  - /v1/completions: legacy format support
  - Auto-route to Claude/OpenAI/Gemini based on requested model

- Add Xcode system prompt support in openaiToClaude
  - Detect and preserve Xcode-specific system messages

- Export handler functions for reuse
  - openaiClaudeRoutes: export handleChatCompletion
  - openaiRoutes: export handleResponses

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
jft0m
2025-10-14 14:12:30 +00:00
parent 8ddb905213
commit e540ec3a52
6 changed files with 527 additions and 31 deletions

View File

@@ -490,3 +490,4 @@ router.post('/v1/completions', authenticateApiKey, async (req, res) => {
})
module.exports = router
module.exports.handleChatCompletion = handleChatCompletion