Skip to content

Commit 2990379

Browse files
authored
fix: correct bedrock naming (envoyproxy#1194)
**Description** Fix Bedrock naming **Related Issues/PRs (if applicable)** Related PR: envoyproxy#1155 Signed-off-by: Xiaolin Lin <[email protected]>
1 parent 884d344 commit 2990379

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

internal/apischema/openai/openai.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,9 +1167,9 @@ type ChatCompletionResponseChoiceMessage struct {
11671167
// Audio is the audio response generated by the model, if applicable.
11681168
Audio *ChatCompletionResponseChoiceMessageAudio `json:"audio,omitempty"`
11691169

1170-
// AWSBedRockResponseVendorFields is used to hold any non-standard fields from the backend,
1170+
// AWSBedrockResponseVendorFields is used to hold any non-standard fields from the backend,
11711171
// like "reasoningContent" from AWS Bedrock.
1172-
*AWSBedRockResponseVendorFields `json:",inline,omitempty"`
1172+
*AWSBedrockResponseVendorFields `json:",inline,omitempty"`
11731173
}
11741174

11751175
// URLCitation contains citation information for web search results.
@@ -1303,7 +1303,7 @@ type ChatCompletionResponseChunkChoiceDelta struct {
13031303
Role string `json:"role,omitempty"`
13041304
ToolCalls []ChatCompletionMessageToolCallParam `json:"tool_calls,omitempty"`
13051305
Annotations *[]Annotation `json:"annotations,omitempty"`
1306-
ReasoningContent *AWSBedRockStreamReasoningContent `json:"reasoning_content,omitempty"`
1306+
ReasoningContent *AWSBedrockStreamReasoningContent `json:"reasoning_content,omitempty"`
13071307
}
13081308

13091309
// Error is described in the OpenAI API documentation
@@ -1516,20 +1516,20 @@ type AnthropicVendorFields struct {
15161516
Thinking *anthropic.ThinkingConfigParamUnion `json:"thinking,omitzero"`
15171517
}
15181518

1519-
// AWSBedRockResponseVendorFields contains extra vendor-specific fields to add to the openai response.
1520-
type AWSBedRockResponseVendorFields struct {
1519+
// AWSBedrockResponseVendorFields contains extra vendor-specific fields to add to the openai response.
1520+
type AWSBedrockResponseVendorFields struct {
15211521
// Contains content regarding the reasoning that is carried out by the model. Reasoning refers to a Chain of Thought (CoT) that the model generates to enhance the accuracy of its final response.
15221522
// Note: This object is a Union. Only one member of this object can be specified or returned.
15231523
// Required: No
15241524
// See https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_ReasoningContentBlock.html for more information.
1525-
ReasoningContent *AWSBedRockReasoningContent `json:"reasoning_content,omitzero"`
1525+
ReasoningContent *AWSBedrockReasoningContent `json:"reasoning_content,omitzero"`
15261526
}
15271527

1528-
type AWSBedRockReasoningContent struct {
1528+
type AWSBedrockReasoningContent struct {
15291529
ReasoningContent *awsbedrock.ReasoningContentBlock `json:"reasoningContent,omitzero"`
15301530
}
15311531

1532-
type AWSBedRockStreamReasoningContent struct {
1532+
type AWSBedrockStreamReasoningContent struct {
15331533
Text string `json:"text,omitzero"`
15341534
Signature string `json:"signature,omitzero"`
15351535
RedactedContent []byte `json:"redactedContent,omitzero"`

internal/extproc/translator/openai_awsbedrock.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -668,10 +668,10 @@ func (o *openAIToAWSBedrockTranslatorV1ChatCompletion) ResponseBody(_ map[string
668668
choice.Message.Content = output.Text
669669
}
670670
case output.ReasoningContent != nil:
671-
if choice.Message.AWSBedRockResponseVendorFields == nil {
672-
choice.Message.AWSBedRockResponseVendorFields = &openai.AWSBedRockResponseVendorFields{}
671+
if choice.Message.AWSBedrockResponseVendorFields == nil {
672+
choice.Message.AWSBedrockResponseVendorFields = &openai.AWSBedrockResponseVendorFields{}
673673
}
674-
choice.Message.ReasoningContent = &openai.AWSBedRockReasoningContent{ReasoningContent: output.ReasoningContent}
674+
choice.Message.ReasoningContent = &openai.AWSBedrockReasoningContent{ReasoningContent: output.ReasoningContent}
675675
}
676676
}
677677
openAIResp.Choices = append(openAIResp.Choices, choice)
@@ -761,7 +761,7 @@ func (o *openAIToAWSBedrockTranslatorV1ChatCompletion) convertEvent(event *awsbe
761761
},
762762
})
763763
case event.Delta.ReasoningContent != nil:
764-
reasoningDelta := &openai.AWSBedRockStreamReasoningContent{}
764+
reasoningDelta := &openai.AWSBedrockStreamReasoningContent{}
765765

766766
// Map all relevant fields from the Bedrock delta to our flattened OpenAI delta struct.
767767
if event.Delta.ReasoningContent.ReasoningText != nil {

internal/extproc/translator/openai_awsbedrock_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,8 +1603,8 @@ func TestOpenAIToAWSBedrockTranslatorV1ChatCompletion_ResponseBody(t *testing.T)
16031603
Message: openai.ChatCompletionResponseChoiceMessage{
16041604
Role: awsbedrock.ConversationRoleAssistant,
16051605
Content: ptr.To("This is the final answer."),
1606-
AWSBedRockResponseVendorFields: &openai.AWSBedRockResponseVendorFields{
1607-
ReasoningContent: &openai.AWSBedRockReasoningContent{
1606+
AWSBedrockResponseVendorFields: &openai.AWSBedrockResponseVendorFields{
1607+
ReasoningContent: &openai.AWSBedrockReasoningContent{
16081608
ReasoningContent: &awsbedrock.ReasoningContentBlock{
16091609
ReasoningText: &awsbedrock.ReasoningTextBlock{
16101610
Text: "This is the model's thought process.",
@@ -1807,7 +1807,7 @@ func TestOpenAIToAWSBedrockTranslator_convertEvent(t *testing.T) {
18071807
Choices: []openai.ChatCompletionResponseChunkChoice{
18081808
{
18091809
Delta: &openai.ChatCompletionResponseChunkChoiceDelta{
1810-
ReasoningContent: &openai.AWSBedRockStreamReasoningContent{
1810+
ReasoningContent: &openai.AWSBedrockStreamReasoningContent{
18111811
Text: "thinking...",
18121812
},
18131813
},

0 commit comments

Comments
 (0)