fix: reason convert

This commit is contained in:
Seefs
2026-01-25 15:31:23 +08:00
parent 7afa476770
commit 48efa1ddb9
3 changed files with 45 additions and 26 deletions

View File

@@ -10,6 +10,7 @@ import (
"github.com/QuantumNous/new-api/dto"
"github.com/QuantumNous/new-api/relay/channel/openrouter"
relaycommon "github.com/QuantumNous/new-api/relay/common"
"github.com/QuantumNous/new-api/relay/reasonmap"
)
func ClaudeToOpenAIRequest(claudeRequest dto.ClaudeRequest, info *relaycommon.RelayInfo) (*dto.GeneralOpenAIRequest, error) {
@@ -540,20 +541,7 @@ func ResponseOpenAI2Claude(openAIResponse *dto.OpenAITextResponse, info *relayco
}
func stopReasonOpenAI2Claude(reason string) string {
switch reason {
case "stop":
return "end_turn"
case "stop_sequence":
return "stop_sequence"
case "length":
fallthrough
case "max_tokens":
return "max_tokens"
case "tool_calls":
return "tool_use"
default:
return reason
}
return reasonmap.OpenAIFinishReasonToClaudeStopReason(reason)
}
func toJSONString(v interface{}) string {