Skip to content

Commit

Permalink
fix:修复basic auth
Browse files Browse the repository at this point in the history
  • Loading branch information
huangyanming committed Mar 8, 2023
1 parent 001c024 commit f102fe5
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
> 详情参考官方详细[参数示例](https://beta.openai.com/examples)
# 更新记录
* 修改为默认不开启代理。2023-03-06
* 增加代理配置,解决国内无法使用。2023-03-04
- [x] feat: 增加docker-compose.yaml。2023-03-08
- [x] fix: 修复basic auth 。 2023-03-08
- [x] feat:修改为默认不开启代理。2023-03-06
- [x] feat:增加代理配置,解决国内无法使用。2023-03-04

# 项目功能
* 请求openai增加代理(防墙)
Expand Down Expand Up @@ -95,7 +97,7 @@ $ docker run -itd --name chatgpt-web --restart=always \
-e AUTH_USER= \
-e AUTH_PASSWORD= \
-p 8080:8080 \
--add-host="host.docker.internal:host-gateway"
--add-host="host.docker.internal:host-gateway" \
qingshui869413421/chatgpt-web:latest
```

Expand All @@ -115,6 +117,9 @@ $ docker run -itd --name chatgpt-web -v `pwd`/config.json:/app/config.json -p 80

其中配置文件参考下边的配置文件说明。

# 使用docker-docompose 运行

``docker compose up -d``


# 配置文件说明
Expand Down
23 changes: 23 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# docker-compose.yml
version: '3.3'

services:
chatgpt-web:
build: ./ # dockerfile所在目录
environment:
TZ: Asia/Shanghai
APIKEY: "your api key" #APIKEY
MODEL: "gpt-3.5-turbo-0301" #模型
BOT_DESC: "你是一个AI助手,我需要你模拟一名温柔贴心的女朋友来回答我的问题." #ai设定
MAX_TOKENS: 512
TEMPREATURE: 0.9
TOP_P: 1
FREQ: 0.0
PROXY: "http://host.docker.internal:10809" #代理地址
AUTH_USER: "" #认证用户
AUTH_PASSWORD: "" #认证密码
restart: always
ports:
- 8080:8080
extra_hosts:
- host.docker.internal:host-gateway
6 changes: 4 additions & 2 deletions routes/web.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package routes

import (
"fmt"
. "github.com/869413421/chatgpt-web/app/http/controllers"
"github.com/869413421/chatgpt-web/app/middlewares"
"github.com/869413421/chatgpt-web/config"
Expand All @@ -15,10 +16,11 @@ func RegisterWebRoutes(router *gin.Engine) {
router.Use(middlewares.Cors())

cnf := config.LoadConfig()
fmt.Println(cnf)
if len(cnf.AuthUser) > 0 {
gin.BasicAuth(gin.Accounts{
router.Use(gin.BasicAuth(gin.Accounts{
cnf.AuthUser: cnf.AuthPassword,
})
}))
}
router.GET("/", chatController.Index)
router.POST("/completion", chatController.Completion)
Expand Down

0 comments on commit f102fe5

Please sign in to comment.