Skip to content

Commit

Permalink
feat: 添加stream模式的支持 (eryajf#230)
Browse files Browse the repository at this point in the history
  • Loading branch information
eryajf committed May 24, 2023
1 parent 05116ce commit 1061178
Show file tree
Hide file tree
Showing 9 changed files with 350 additions and 144 deletions.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<p align='center'>
😀企联AI共创计划正式开启😀
</p>

<p align='center'>
https://fork-way.feishu.cn/docx/Gvztd1iVXoXOsVxF2ujcnPPenDf
</p>
Expand All @@ -46,8 +46,8 @@
查看更多内容: https://connect-ai.forkway.cn

企业客户咨询:13995928702(River)


<p> 🌉 基于GO语言实现的钉钉集成ChatGPT机器人 🌉</p>

[![Auth](https://img.shields.io/badge/Auth-eryajf-ff69b4)](https://github.com/eryajf)
Expand Down Expand Up @@ -101,14 +101,14 @@ AIGC的热潮正在各行各业掀起巨大的变革,我们看到各大社群
- A奖励:小队完成度奖励,鼓励小队长参与项目,能够在指定时间内完成课题规定的基本内容,队长应获得一定的奖励。
- B奖励:项目优秀度奖励,根据项目复杂度、组内配合度、产品创意度,以及期中和期末用户体验打分,评选出部分优秀项目的队长和核心队员,并给予相应奖励。
- C奖励:成员活跃度奖励,考虑到设计和测试身份的特殊性,无法单独带领项目。因此,我们将评选出优秀设计师和优秀测试反馈员,以表彰他们在项目中的积极参与和贡献。

做出下面奖励安排
- A奖励项目完成度:京东E卡300 * 10
- B奖励项目优秀度:
- 杰出奖: iPhone14 * 1 + 京东E卡300 * 3
- 优秀奖: PS5 * 1 + 京东E卡300 * 3
- C奖励成员活跃度:京东E卡300 * 4

我们队员有
- [EX-chatGPT](https://github.com/circlestarzero/EX-chatGPT)[ChatPaper的维护者](https://github.com/kaixindelele/ChatPaper)-->[cc](https://github.com/circlestarzero)
- [钉钉GPT的维护者](https://github.com/eryajf/chatgpt-dingtalk)-->[eryajf](https://github.com/eryajf)
Expand Down Expand Up @@ -222,7 +222,7 @@ $ docker run -itd --name chatgpt -p 8090:8090 \
-e DEFAULT_MODE="单聊" -e MAX_REQUEST=0 -e PORT=8090 \
-e SERVICE_URL="你当前服务外网可访问的URL" -e CHAT_TYPE="0" \
-e ALLOW_GROUPS=a,b -e ALLOW_OUTGOING_GROUPS=a,b -e ALLOW_USERS=a,b -e DENY_USERS=a,b -e VIP_USERS=a,b -e ADMIN_USERS=a,b -e APP_SECRETS="xxx,yyy" \
-e SENSITIVE_WORDS="aa,bb" \
-e SENSITIVE_WORDS="aa,bb" -e RUN_MODE="http" \
-e AZURE_ON="false" -e AZURE_API_VERSION="" -e AZURE_RESOURCE_NAME="" \
-e AZURE_DEPLOYMENT_NAME="" -e AZURE_OPENAI_TOKEN="" \
-e DINGTALK_CREDENTIALS="your_client_id1:secret1,your_client_id2:secret2" \
Expand Down Expand Up @@ -486,6 +486,8 @@ $ go run main.go
log_level: "info"
# openai api_key
api_key: "xxxxxxxxx"
# 运行模式,http 或者 stream ,当前默认为http,等stream全面开放之后,这个模式将会是默认的启动模式
run_mode: "http"
# 如果你使用官方的接口地址 https://api.openai.com,则留空即可,如果你想指定请求url的地址,可通过这个参数进行配置,注意需要带上 http 协议
base_url: ""
# 指定模型,默认为 gpt-3.5-turbo , 可选参数有: "gpt-4-0314", "gpt-4", "gpt-3.5-turbo-0301", "gpt-3.5-turbo",如果使用gpt-4,请确认自己是否有接口调用白名单
Expand Down
2 changes: 2 additions & 0 deletions config.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
log_level: "info"
# openai api_key
api_key: "xxxxxxxxx"
# 运行模式,http 或者 stream ,当前默认为http,等stream全面开放之后,这个模式将会是默认的启动模式
run_mode: "http"
# 如果你使用官方的接口地址 https://api.openai.com,则留空即可,如果你想指定请求url的地址,可通过这个参数进行配置,注意需要带上 http 协议
base_url: ""
# 指定模型,默认为 gpt-3.5-turbo , 可选参数有: "gpt-4-0314", "gpt-4", "gpt-3.5-turbo-0301", "gpt-3.5-turbo",如果使用gpt-4,请确认自己是否有接口调用白名单
Expand Down
9 changes: 9 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ type Configuration struct {
LogLevel string `yaml:"log_level"`
// gpt apikey
ApiKey string `yaml:"api_key"`
// 运行模式
RunMode string `yaml:"run_mode"`
// 请求的 URL 地址
BaseURL string `yaml:"base_url"`
// 使用模型
Expand Down Expand Up @@ -97,6 +99,10 @@ func LoadConfig() *Configuration {
if apiKey != "" {
config.ApiKey = apiKey
}
runMode := os.Getenv("RUN_MODE")
if runMode != "" {
config.RunMode = runMode
}
baseURL := os.Getenv("BASE_URL")
if baseURL != "" {
config.BaseURL = baseURL
Expand Down Expand Up @@ -216,6 +222,9 @@ func LoadConfig() *Configuration {
if config.LogLevel == "" {
config.LogLevel = "info"
}
if config.RunMode == "" {
config.LogLevel = "http"
}
if config.Model == "" {
config.Model = "gpt-3.5-turbo"
}
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ services:
environment:
LOG_LEVEL: "info" # 应用的日志级别 info/debug
APIKEY: xxxxxx # 你的 api_key
RUN_MODE: "" # 运行模式,http 或者 stream ,当前默认为http,等stream全面开放之后,这个模式将会是默认的启动模式
BASE_URL: "" # 如果你使用官方的接口地址 https://api.openai.com,则留空即可,如果你想指定请求url的地址,可通过这个参数进行配置,注意需要带上 http 协议
MODEL: "gpt-3.5-turbo" # 指定模型,默认为 gpt-3.5-turbo , 可选参数有: "gpt-4-0314", "gpt-4", "gpt-3.5-turbo-0301", "gpt-3.5-turbo",如果使用gpt-4,请确认自己是否有接口调用白名单
SESSION_TIMEOUT: 600 # 会话超时时间,默认600秒,在会话时间内所有发送给机器人的信息会作为上下文
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
github.com/gin-gonic/gin v1.9.0
github.com/glebarez/sqlite v1.7.0
github.com/go-resty/resty/v2 v2.7.0
github.com/open-dingtalk/dingtalk-stream-sdk-go v0.0.1
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/sashabaranov/go-openai v1.6.1
github.com/solywsh/chatgpt v0.0.14
Expand Down Expand Up @@ -34,6 +35,7 @@ require (
github.com/goccy/go-json v0.10.0 // indirect
github.com/google/pprof v0.0.0-20230406165453-00490a63f317 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/json-iterator/go v1.1.12 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ github.com/google/pprof v0.0.0-20230406165453-00490a63f317 h1:hFhpt7CTmR3DX+b4R1
github.com/google/pprof v0.0.0-20230406165453-00490a63f317/go.mod h1:79YE0hCXdHag9sBkw2o+N/YnZtTkXi0UT9Nnixa5eYk=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/ianlancetaylor/demangle v0.0.0-20220319035150-800ac71e25c2/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
Expand Down Expand Up @@ -99,6 +101,8 @@ github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s=
github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8=
github.com/muesli/termenv v0.15.1 h1:UzuTb/+hhlBugQz28rpzey4ZuKcZ03MeKsoG7IJZIxs=
github.com/muesli/termenv v0.15.1/go.mod h1:HeAQPTzpfs016yGtA4g00CsdYnVLJvxsS4ANqrZs2sQ=
github.com/open-dingtalk/dingtalk-stream-sdk-go v0.0.1 h1:F7c4ZWg5FuL0giOVg0slzPmYLwbuQqTjsu5BkUL6VEU=
github.com/open-dingtalk/dingtalk-stream-sdk-go v0.0.1/go.mod h1:ln3IqPYYocZbYvl9TAOrG/cxGR9xcn4pnZRLdCTEGEU=
github.com/pandodao/tokenizer-go v0.2.0 h1:NhfI8fGvQkDld2cZCag6NEU3pJ/ugU9zoY1R/zi9YCs=
github.com/pandodao/tokenizer-go v0.2.0/go.mod h1:t6qFbaleKxbv0KNio2XUN/mfGM5WKv4haPXDQWVDG00=
github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=
Expand Down
Loading

0 comments on commit 1061178

Please sign in to comment.