diff --git a/plugins/wasm-go/extensions/ai-proxy/provider/bedrock.go b/plugins/wasm-go/extensions/ai-proxy/provider/bedrock.go index c78b2d9ed..e84603a3e 100644 --- a/plugins/wasm-go/extensions/ai-proxy/provider/bedrock.go +++ b/plugins/wasm-go/extensions/ai-proxy/provider/bedrock.go @@ -35,11 +35,9 @@ const ( // converseStream路径 /model/{modelId}/converse-stream bedrockStreamChatCompletionPath = "/model/%s/converse-stream" // invoke_model 路径 /model/{modelId}/invoke - bedrockInvokeModelPath = "/model/%s/invoke" - bedrockSignedHeaders = "host;x-amz-date" - requestIdHeader = "X-Amzn-Requestid" - reasoningContextMarkerStart = "" - reasoningContextMarkerEnd = "" + bedrockInvokeModelPath = "/model/%s/invoke" + bedrockSignedHeaders = "host;x-amz-date" + requestIdHeader = "X-Amzn-Requestid" ) type bedrockProviderInitializer struct{} @@ -122,7 +120,7 @@ func (b *bedrockProvider) convertEventFromBedrockToOpenAI(ctx wrapper.HttpContex if bedrockEvent.Delta.ReasoningContent != nil { var content string if ctx.GetContext("thinking_start") == nil { - content += reasoningContextMarkerStart + content += reasoningStartTag ctx.SetContext("thinking_start", true) } content += bedrockEvent.Delta.ReasoningContent.Text @@ -130,7 +128,7 @@ func (b *bedrockProvider) convertEventFromBedrockToOpenAI(ctx wrapper.HttpContex } else if bedrockEvent.Delta.Text != nil { var content string if ctx.GetContext("thinking_start") != nil && ctx.GetContext("thinking_end") == nil { - content += reasoningContextMarkerEnd + content += reasoningEndTag ctx.SetContext("thinking_end", true) } content += *bedrockEvent.Delta.Text @@ -844,7 +842,7 @@ func (b *bedrockProvider) buildChatCompletionResponse(ctx wrapper.HttpContext, b } } if reasoningContent != "" { - outputContent = reasoningContextMarkerStart + reasoningContent + reasoningContextMarkerEnd + normalContent + outputContent = reasoningStartTag + reasoningContent + reasoningEndTag + normalContent } else { outputContent = normalContent } diff --git a/plugins/wasm-go/extensions/ai-proxy/provider/vertex.go b/plugins/wasm-go/extensions/ai-proxy/provider/vertex.go index e98cb7d54..050994757 100644 --- a/plugins/wasm-go/extensions/ai-proxy/provider/vertex.go +++ b/plugins/wasm-go/extensions/ai-proxy/provider/vertex.go @@ -31,8 +31,6 @@ const ( vertexChatCompletionAction = "generateContent" vertexChatCompletionStreamAction = "streamGenerateContent?alt=sse" vertexEmbeddingAction = "predict" - reasoningContextMarkerStart = "" - reasoningContextMarkerEnd = "" ) type vertexProviderInitializer struct{} @@ -278,7 +276,7 @@ func (v *vertexProvider) buildChatCompletionResponse(ctx wrapper.HttpContext, re }, } } else if part.Thounght != nil && len(candidate.Content.Parts) > 1 { - choice.Message.Content = reasoningContextMarkerStart + part.Text + reasoningContextMarkerEnd + candidate.Content.Parts[1].Text + choice.Message.Content = reasoningStartTag + part.Text + reasoningEndTag + candidate.Content.Parts[1].Text } else if part.Text != "" { choice.Message.Content = part.Text } @@ -339,14 +337,14 @@ func (v *vertexProvider) buildChatCompletionStreamResponse(ctx wrapper.HttpConte } } else if part.Thounght != nil { if ctx.GetContext("thinking_start") == nil { - choice.Delta = &chatMessage{Content: reasoningContextMarkerStart + part.Text} + choice.Delta = &chatMessage{Content: reasoningStartTag + part.Text} ctx.SetContext("thinking_start", true) } else { choice.Delta = &chatMessage{Content: part.Text} } } else if part.Text != "" { if ctx.GetContext("thinking_start") != nil && ctx.GetContext("thinking_end") == nil { - choice.Delta = &chatMessage{Content: reasoningContextMarkerEnd + part.Text} + choice.Delta = &chatMessage{Content: reasoningEndTag + part.Text} ctx.SetContext("thinking_end", true) } else { choice.Delta = &chatMessage{Content: part.Text}