diff --git a/relay/adaptor/doubao/main.go b/relay/adaptor/doubao/main.go index c9726957e3..f529c6ac7b 100644 --- a/relay/adaptor/doubao/main.go +++ b/relay/adaptor/doubao/main.go @@ -19,6 +19,12 @@ func GetRequestURL(meta *meta.Meta) (string, error) { return fmt.Sprintf("%s/api/v3/chat/completions", meta.BaseURL), nil case relaymode.Embeddings: return fmt.Sprintf("%s/api/v3/embeddings", meta.BaseURL), nil + case relaymode.ClaudeMessages: + // 豆包支持 Claude Messages API 格式,转换为 ChatCompletions 处理 + if strings.HasPrefix(meta.ActualModelName, "bot") { + return fmt.Sprintf("%s/api/v3/bots/chat/completions", meta.BaseURL), nil + } + return fmt.Sprintf("%s/api/v3/chat/completions", meta.BaseURL), nil default: } return "", errors.Errorf("unsupported relay mode %d for doubao", meta.Mode) diff --git a/relay/adaptor/openai_compatible/claude_convert.go b/relay/adaptor/openai_compatible/claude_convert.go index 065cf50717..465adb33c2 100644 --- a/relay/adaptor/openai_compatible/claude_convert.go +++ b/relay/adaptor/openai_compatible/claude_convert.go @@ -261,8 +261,15 @@ func ConvertOpenAIStreamToClaudeSSE(c *gin.Context, resp *http.Response, promptT // Process choices for _, choice := range chunk.Choices { - // Thinking delta + // Thinking delta - try Thinking field first, fallback to ReasoningContent + var thinkingContent *string if choice.Delta.Thinking != nil && *choice.Delta.Thinking != "" { + thinkingContent = choice.Delta.Thinking + } else if choice.Delta.ReasoningContent != nil && *choice.Delta.ReasoningContent != "" { + thinkingContent = choice.Delta.ReasoningContent + } + + if thinkingContent != nil && *thinkingContent != "" { if thinkingIndex == -1 { // Start thinking block at next index start := map[string]any{ @@ -279,7 +286,7 @@ func ConvertOpenAIStreamToClaudeSSE(c *gin.Context, resp *http.Response, promptT thinkingIndex = nextIndex nextIndex++ } - thinkingDelta := *choice.Delta.Thinking + thinkingDelta := *thinkingContent accumThinking += thinkingDelta delta := map[string]any{ "type": "content_block_delta",