Skip to content

Commit

Permalink
remove unuseful code
Browse files Browse the repository at this point in the history
  • Loading branch information
diemus committed Mar 27, 2023
1 parent 1374384 commit 63f7104
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions pkg/azure/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"fmt"
"github.com/tidwall/gjson"
"io"
"io/ioutil"
"log"
"net/http"
Expand Down Expand Up @@ -89,18 +88,18 @@ func NewOpenAIReverseProxy() *httputil.ReverseProxy {
log.Printf("proxying request [%s] %s -> %s", model, originURL, req.URL.String())
}
return &httputil.ReverseProxy{Director: director, ModifyResponse: func(response *http.Response) error {
if response.Header.Get("Content-Type") == "text/event-stream" {
//BUGFIX: try to fix the difference between azure and openai, Azure's response is missing a \n
//see https://github.com/Chanzhaoyu/chatgpt-web/issues/831
body := response.Body
r, w := io.Pipe()
response.Body = r
go func() {
defer w.Close()
io.Copy(w, body)
fmt.Fprint(w, "\n")
}()
}
//if response.Header.Get("Content-Type") == "text/event-stream" {
// //BUGFIX: try to fix the difference between azure and openai, Azure's response is missing a \n
// //see https://github.com/Chanzhaoyu/chatgpt-web/issues/831
// body := response.Body
// r, w := io.Pipe()
// response.Body = r
// go func() {
// defer w.Close()
// io.Copy(w, body)
// fmt.Fprint(w, "\n")
// }()
//}
return nil
}}
}
Expand All @@ -112,6 +111,3 @@ func GetDeploymentByModel(model string) string {
// This is a fallback strategy in case the model is not found in the AzureOpenAIModelMapper
return fallbackModelMapper.ReplaceAllString(model, "")
}

type Copier struct {
}

0 comments on commit 63f7104

Please sign in to comment.