Skip to content

Commit

Permalink
host should be set outside translator
Browse files Browse the repository at this point in the history
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
  • Loading branch information
mathetake committed Dec 6, 2024
1 parent 86ce149 commit 33c5c41
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
6 changes: 1 addition & 5 deletions internal/extproc/translator/openai_openai.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"log/slog"

corev3 "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
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"

Expand Down Expand Up @@ -47,10 +46,7 @@ func (o *openAIToOpenAITranslatorV1ChatCompletion) RequestBody(body *extprocv3.H
ResponseBodyMode: extprocv3http.ProcessingMode_STREAMED,
}
}
headerMutation = &extprocv3.HeaderMutation{
SetHeaders: []*corev3.HeaderValueOption{{Header: &corev3.HeaderValue{Key: "host", Value: "api.openai.com"}}},
}
return headerMutation, nil, override, req.Model, nil
return nil, nil, override, req.Model, nil
}

// ResponseBody implements [Translator.ResponseBody].
Expand Down
5 changes: 1 addition & 4 deletions internal/extproc/translator/openai_openai_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ func TestOpenAIToOpenAITranslatorV1ChatCompletionRequestBody(t *testing.T) {
require.Nil(t, mode)
}

require.NotNil(t, hm)
require.Len(t, hm.SetHeaders, 1)
require.Equal(t, "host", hm.SetHeaders[0].Header.Key)
require.Equal(t, "api.openai.com", hm.SetHeaders[0].Header.Value)
require.Nil(t, hm)
})
}
})
Expand Down

0 comments on commit 33c5c41

Please sign in to comment.