Преглед на файлове

Merge pull request #2968 from 0-don/fix/claude-input-text-content-block

fix: normalize input_text content blocks in Claude-to-OpenAI conversion
Seefs преди 2 седмици
родител
ревизия
dbc3236245
променени са 2 файла, в които са добавени 6 реда и са изтрити 2 реда
  1. 1 1
      service/convert.go
  2. 5 1
      service/openaicompat/chat_to_responses.go

+ 1 - 1
service/convert.go

@@ -127,7 +127,7 @@ func ClaudeToOpenAIRequest(claudeRequest dto.ClaudeRequest, info *relaycommon.Re
 
 			for _, mediaMsg := range contents {
 				switch mediaMsg.Type {
-				case "text":
+				case "text", "input_text":
 					message := dto.MediaContent{
 						Type:         "text",
 						Text:         mediaMsg.GetText(),

+ 5 - 1
service/openaicompat/chat_to_responses.go

@@ -214,8 +214,12 @@ func ChatCompletionsRequestToResponsesRequest(req *dto.GeneralOpenAIRequest) (*d
 		for _, part := range parts {
 			switch part.Type {
 			case dto.ContentTypeText:
+				textType := "input_text"
+				if role == "assistant" {
+					textType = "output_text"
+				}
 				contentParts = append(contentParts, map[string]any{
-					"type": "input_text",
+					"type": textType,
 					"text": part.Text,
 				})
 			case dto.ContentTypeImageURL: