Skip to content

Commit

Permalink
enhance: proxy settings
Browse files Browse the repository at this point in the history
  • Loading branch information
0xJacky committed Oct 7, 2024
1 parent 957d475 commit 00fb755
Show file tree
Hide file tree
Showing 15 changed files with 439 additions and 347 deletions.
9 changes: 3 additions & 6 deletions api/openai/openai.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"github.com/0xJacky/Nginx-UI/api"
"github.com/0xJacky/Nginx-UI/internal/chatbot"
"github.com/0xJacky/Nginx-UI/internal/transport"
"github.com/0xJacky/Nginx-UI/settings"
"github.com/gin-gonic/gin"
"github.com/pkg/errors"
Expand Down Expand Up @@ -53,7 +54,7 @@ func MakeChatCompletionRequest(c *gin.Context) {
config := openai.DefaultConfig(settings.OpenAISettings.Token)

if settings.OpenAISettings.Proxy != "" {
proxyUrl, err := url.Parse(settings.OpenAISettings.Proxy)
t, err := transport.NewTransport(transport.WithProxy(settings.OpenAISettings.Proxy))
if err != nil {
c.Stream(func(w io.Writer) bool {
c.SSEvent("message", gin.H{
Expand All @@ -64,12 +65,8 @@ func MakeChatCompletionRequest(c *gin.Context) {
})
return
}
transport := &http.Transport{
Proxy: http.ProxyURL(proxyUrl),
TLSClientConfig: &tls.Config{InsecureSkipVerify: settings.ServerSettings.InsecureSkipVerify},
}
config.HTTPClient = &http.Client{
Transport: transport,
Transport: t,
}
}

Expand Down
52 changes: 26 additions & 26 deletions app/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
},
"dependencies": {
"vitepress": "^1.3.4",
"vue": "^3.5.6"
"vue": "^3.5.11"
},
"devDependencies": {
"@types/node": "^20.16.5",
"@types/node": "^22.7.4",
"less": "^4.2.0"
},
"license": "AGPL-3.0",
Expand Down
Loading

0 comments on commit 00fb755

Please sign in to comment.