@@ -13,13 +13,14 @@ import (
1313 "strings"
1414 "time"
1515
16+ "google.golang.org/genai"
17+
1618 "github.com/envoyproxy/ai-gateway/internal/apischema/gcp"
1719 "github.com/envoyproxy/ai-gateway/internal/apischema/openai"
1820 "github.com/envoyproxy/ai-gateway/internal/internalapi"
1921 "github.com/envoyproxy/ai-gateway/internal/json"
2022 "github.com/envoyproxy/ai-gateway/internal/metrics"
2123 "github.com/envoyproxy/ai-gateway/internal/tracing/tracingapi"
22- "google.golang.org/genai"
2324)
2425
2526// NewImageGenerationOpenAIToGCPVertexAITranslator implements [Factory] for OpenAI to GCP Vertex AI
@@ -41,7 +42,7 @@ type openAIToGCPVertexAIImageGenerationTranslator struct {
4142 isImagenModel bool
4243}
4344
44- func (o * openAIToGCPVertexAIImageGenerationTranslator ) RequestBody (original []byte , openAIReq * openai.ImageGenerationRequest , forceBodyMutation bool ) (
45+ func (o * openAIToGCPVertexAIImageGenerationTranslator ) RequestBody (_ []byte , openAIReq * openai.ImageGenerationRequest , _ bool ) (
4546 newHeaders []internalapi.Header , newBody []byte , err error ,
4647) {
4748 o .requestModel = cmp .Or (o .modelNameOverride , openAIReq .Model )
@@ -58,15 +59,15 @@ func (o *openAIToGCPVertexAIImageGenerationTranslator) RequestBody(original []by
5859 return
5960 }
6061 newBody , err = json .Marshal (imgGenReq )
61- path = buildGCPModelPathSuffix (gcpModelPublisherGoogle , string ( o .requestModel ) , gcpMethodPredict )
62+ path = buildGCPModelPathSuffix (gcpModelPublisherGoogle , o .requestModel , gcpMethodPredict )
6263 } else {
6364 var geminiReq * gcp.GenerateContentRequest
6465 geminiReq , err = openAIToGeminiRequest (openAIReq )
6566 if err != nil {
6667 return
6768 }
6869 newBody , err = json .Marshal (geminiReq )
69- path = buildGCPModelPathSuffix (gcpModelPublisherGoogle , string ( o .requestModel ) , gcpMethodGenerateContent )
70+ path = buildGCPModelPathSuffix (gcpModelPublisherGoogle , o .requestModel , gcpMethodGenerateContent )
7071 }
7172 if err != nil {
7273 err = fmt .Errorf ("failed to encode request: %w" , err )
@@ -148,7 +149,7 @@ func openAIToImagenRequest(req *openai.ImageGenerationRequest) (*gcp.ImagePredic
148149 {Prompt : req .Prompt },
149150 },
150151 Parameters : & gcp.ImageParameters {
151- SampleCount : int ( cmp .Or (req .N , 1 ) ),
152+ SampleCount : cmp .Or (req .N , 1 ),
152153 AspectRatio : aspectRatio ,
153154 SampleImageSize : sampleImageSize ,
154155 OutputOptions : outputOptions ,
@@ -183,7 +184,7 @@ func openAIToGeminiRequest(req *openai.ImageGenerationRequest) (*gcp.GenerateCon
183184 },
184185 },
185186 GenerationConfig : & genai.GenerationConfig {
186- CandidateCount : int32 (cmp .Or (req .N , 1 )),
187+ CandidateCount : int32 (cmp .Or (req .N , 1 )), //nolint:gosec
187188 },
188189 }, nil
189190}
@@ -254,9 +255,9 @@ func geminiToOpenAIResponse(resp *genai.GenerateContentResponse, tokenUsage *met
254255 InputTokens : int (inputTokens ),
255256 OutputTokens : int (outputTokens ),
256257 }
257- tokenUsage .SetInputTokens (uint32 (inputTokens ))
258- tokenUsage .SetOutputTokens (uint32 (outputTokens ))
259- tokenUsage .SetTotalTokens (uint32 (totalTokens ))
258+ tokenUsage .SetInputTokens (uint32 (inputTokens )) //nolint:gosec
259+ tokenUsage .SetOutputTokens (uint32 (outputTokens )) //nolint:gosec
260+ tokenUsage .SetTotalTokens (uint32 (totalTokens )) //nolint:gosec
260261 }
261262
262263 return & openai.ImageGenerationResponse {
0 commit comments