Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Sun <dsun20@bloomberg.net>
  • Loading branch information
yuzisun committed Jan 5, 2025
1 parent 56b81a0 commit 5cd9ad6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion internal/apischema/awsbedrock/awsbedrock.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ type ToolConfiguration struct {
// information, see Tool use (function calling) (https://docs.aws.amazon.com/bedrock/latest/userguide/tool-use.html)
// in the Amazon Bedrock User Guide.
type Tool struct {
// The specfication for the tool.
// The specification for the tool.
ToolSpec *ToolSpecification `json:"toolSpec"`
}

Expand Down
2 changes: 1 addition & 1 deletion internal/apischema/openai/openai.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Package openai contains the followings are the OpenAI API schema definitions.
// Package openai contains the following is the OpenAI API schema definitions.
// Note that we intentionally do not use the code generation tools like OpenAPI Generator not only to keep the code simple
// but also because the OpenAI's OpenAPI definition is not compliant with the spec and the existing tools do not work well.
package openai
Expand Down
7 changes: 3 additions & 4 deletions internal/extproc/translator/openai_awsbedrock.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,11 @@ func (o *openAIToAWSBedrockTranslatorV1ChatCompletion) RequestBody(body router.R
// Convert Messages
bedrockReq.Messages = make([]*awsbedrock.Message, 0, len(openAIReq.Messages))
for _, msg := range openAIReq.Messages {
var role string
switch msg.Role {
case openai.ChatMessageRoleUser, openai.ChatMessageRoleAssistant:
role = msg.Role
text := msg.Content
bedrockReq.Messages = append(bedrockReq.Messages, &awsbedrock.Message{
Role: role,
Role: msg.Role,
Content: []*awsbedrock.ContentBlock{
{Text: &text},
},
Expand All @@ -102,6 +100,7 @@ func (o *openAIToAWSBedrockTranslatorV1ChatCompletion) RequestBody(body router.R
Text: msg.Content,
})
case openai.ChatMessageRoleTool:
text := msg.Content
bedrockReq.Messages = append(bedrockReq.Messages, &awsbedrock.Message{
// bedrock does not support tool role, merging to the user role
Role: awsbedrock.ConversationRoleUser,
Expand All @@ -110,7 +109,7 @@ func (o *openAIToAWSBedrockTranslatorV1ChatCompletion) RequestBody(body router.R
ToolResult: &awsbedrock.ToolResultBlock{
Content: []*awsbedrock.ToolResultContentBlock{
{
Text: &msg.Content,
Text: &text,
},
},
},
Expand Down
8 changes: 4 additions & 4 deletions internal/extproc/translator/openai_awsbedrock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ import (
"bytes"
"encoding/base64"
"encoding/json"
"github.com/envoyproxy/ai-gateway/internal/extproc/router"
extprocv3http "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/ext_proc/v3"
"github.com/google/go-cmp/cmp"
"k8s.io/utils/ptr"
"strconv"
"strings"
"testing"

"github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream"
extprocv3http "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/ext_proc/v3"
extprocv3 "github.com/envoyproxy/go-control-plane/envoy/service/ext_proc/v3"
"github.com/google/go-cmp/cmp"
"github.com/stretchr/testify/require"
"k8s.io/utils/ptr"

"github.com/envoyproxy/ai-gateway/internal/apischema/awsbedrock"
"github.com/envoyproxy/ai-gateway/internal/apischema/openai"
"github.com/envoyproxy/ai-gateway/internal/extproc/router"
)

func TestNewOpenAIToAWSBedrockTranslator(t *testing.T) {
Expand Down

0 comments on commit 5cd9ad6

Please sign in to comment.