fix: qwen stream issue (#1564)

This commit is contained in:
Se7en
2024-12-03 13:10:47 +08:00
committed by GitHub
parent d6094974c2
commit e705a0344f
2 changed files with 5 additions and 5 deletions

View File

@@ -134,7 +134,7 @@ type TransformRequestBodyHandler interface {
}
// TransformRequestBodyHeadersHandler allows to transform request headers based on the request body.
// Some providers (e.g. baidu, gemini) transform request headers (e.g., path) based on the request body (e.g., model).
// Some providers (e.g. gemini) transform request headers (e.g., path) based on the request body (e.g., model).
type TransformRequestBodyHeadersHandler interface {
TransformRequestBodyHeaders(ctx wrapper.HttpContext, apiName ApiName, body []byte, headers http.Header, log wrapper.Log) ([]byte, error)
}

View File

@@ -158,11 +158,11 @@ func (m *qwenProvider) onChatCompletionRequestBody(ctx wrapper.HttpContext, body
streaming := request.Stream
if streaming {
_ = proxywasm.ReplaceHttpRequestHeader("Accept", "text/event-stream")
_ = proxywasm.ReplaceHttpRequestHeader("X-DashScope-SSE", "enable")
headers.Set("Accept", "text/event-stream")
headers.Set("X-DashScope-SSE", "enable")
} else {
_ = proxywasm.ReplaceHttpRequestHeader("Accept", "*/*")
_ = proxywasm.RemoveHttpRequestHeader("X-DashScope-SSE")
headers.Set("Accept", "*/*")
headers.Del("X-DashScope-SSE")
}
return m.buildQwenTextGenerationRequest(ctx, request, streaming)