支持 OpenAI Chat 兼容协议 (#99)

* feat: 完成 openai 接口兼容

* feat: 完成 openai 协议兼容

* fix: 修复测试用例
This commit is contained in:
claude-code-best
2026-04-03 23:33:17 +08:00
committed by GitHub
parent 465e9f01c6
commit 00b044e8b2
22 changed files with 2283 additions and 18 deletions

View File

@@ -1301,6 +1301,15 @@ async function* queryModel(
API_MAX_MEDIA_PER_REQUEST,
)
// OpenAI-compatible provider: delegate to the OpenAI adapter layer
// after shared preprocessing (message normalization, tool filtering,
// media stripping) but before Anthropic-specific logic (betas, thinking, caching).
if (getAPIProvider() === 'openai') {
const { queryModelOpenAI } = await import('./openai/index.js')
yield* queryModelOpenAI(messagesForAPI, systemPrompt, filteredTools, signal, options)
return
}
// Instrumentation: Track message count after normalization
logEvent('tengu_api_after_normalize', {
postNormalizedMessageCount: messagesForAPI.length,