Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

提供一个Zeabur部署的多频道方案 #30

Closed
gordonchanfz opened this issue Feb 4, 2024 · 3 comments
Closed

提供一个Zeabur部署的多频道方案 #30

gordonchanfz opened this issue Feb 4, 2024 · 3 comments
Labels
documentation Improvements or additions to documentation

Comments

@gordonchanfz
Copy link

gordonchanfz commented Feb 4, 2024

机器人部署(实现会话隔离)

手动部署:

  1. 首先 fork 一份代码,修改Dockerfile文件(或者将原文件备份,再新增Dockerfile文件)
FROM deanxv/coze-discord-proxy:latest

RUN mkdir -p /app/coze-discord-proxy/data/config && chmod 777 /app/coze-discord-proxy/data/config
RUN printf '%s' "$BOT_CONFIG" | sed 's/\\/"/g' > /app/coze-discord-proxy/data/config/bot_config.json

WORKDIR /app/coze-discord-proxy/data
EXPOSE 7077

ENTRYPOINT ["/coze-discord-proxy"]
  1. 进入 Zeabur,使用github登录,进入控制台。

  2. 在 Service -> Add Service,选择 Git(第一次使用需要先授权),选择你 fork 的仓库。

  3. Deploy 会自动开始,先取消。

  4. 添加环境变量

    BOT_TOKEN:MTE5OTk2xxxxxxxxxxxxxxrwUrUWNbG63w 主动发送消息的Bot-Token

    GUILD_ID:119xxxxxxxx796 两个机器人所在的服务器ID

    COZE_BOT_ID:119xxxxxxxx7 由coze托管的机器人ID

    CHANNEL_ID:119xxxxxx24 # 默认频道-在使用与openai对齐的接口时(/v1/chat/completions) 消息会默认发送到此频道

    PROXY_SECRET:123456 [可选]接口密钥-修改此行为请求头校验的值(多个请以,分隔),配置此参数后,每次发起请求时请求头加上proxy-secret
    参数,即header中添加 proxy-secret:123,456,789

    BOT_CONFIG:

     [
        {
             "proxySecret": "123",
             "cozeBotId": "12***************31",
             "model": ["gpt-3.5","gpt-3.5-16k"], 
             "channelId": "12***************56"
        },
        {
             "proxySecret": "456",
             "cozeBotId": "12***************64",
             "model": ["gpt-4","gpt-4-16k"],
             "channelId": "12***************78"
        },
        {
             "proxySecret": "789",
             "cozeBotId": "12***************12",
             "model": ["dall-e-3"],
             "channelId": "12***************24"
        }
     ]
    

image

  1. Redeploy。
  2. 在Networking中public生成一个域名,然后可以与漂亮国沟通了。

image

  1. 部署好,可以先自测,下面接口测试命令:

    curl -X 'POST' \
    'https://your.zeabur.app/api/chat' \
    -H 'accept: application/json' \
    -H 'proxy-secret: your key' \
    -H 'Content-Type: application/json' \
    -d '{
    "channelId": "your channelId",
    "model": "dall-e-3",
    "content": "画一只猪",
    "stream": true
    }'
    curl -X 'POST' \
     'https://your.zeabur.app/v1/chat/completions' \
     -H 'accept: application/json' \
     -H 'Authorization: your key' \
     -H 'Content-Type: application/json' \
     -d '{
     "channelId": "your channelId",
     "model": "gpt-4",
     "messages": [
       {
         "content": "鲁迅和周树人是两个人?",
         "role": "user"
       }
     ],
    "stream": true
    }'

image

@gordonchanfz gordonchanfz added the bug Something isn't working label Feb 4, 2024
@deanxv
Copy link
Owner

deanxv commented Feb 4, 2024

已在文档中标识,感谢!

@deanxv deanxv closed this as completed Feb 4, 2024
@deanxv deanxv added documentation Improvements or additions to documentation and removed bug Something isn't working labels Feb 4, 2024
@mullyong
Copy link

mullyong commented Mar 7, 2024

fork仓库最新代码导致该方法报错
[FATAL] 2024/03/07 - 07:54:47 | [Error parsing JSON: json: cannot unmarshal string into Go struct field BotConfig.model of type []string]

fz68 added a commit to fz68/coze-discord-proxy that referenced this issue Mar 27, 2024
@JasonLeeForOnly
Copy link

感谢热佬。
你这个是根据PROXY_SECRET指到对应的bot上去,但是目前key一般都是比较固定的,能否根据model区分呀。
另外,想咨询下。他这个请求次数是按照bot计算,还是bot owner计算啊,我一个人创建很多个bot也能获得很多倍的请求次数吗?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

4 participants