Coder Social home page Coder Social logo

coze-discord-proxy's Introduction

coze-discord-proxy

coze+discord 代理服务—通过接口调用被coze托管的discord-bot

觉得有点意思的话 别忘了点个🌟

🐞COZE-DISCORD-PROXY交流群

功能

  • 对话支持流式返回
  • 支持文生图(需coze配置DALL·E3插件)返回图片url
  • 支持图生文(需coze配置GPT4V插件)(发送的文本消息中携带图片url即可)
  • 支持创建 discord频道/子频道/线程
  • 支持对话指定 discord频道/子频道/线程 实现对话隔离
  • 支持和openai对齐的接口(v1/chat/completions)(支持文生图/图生文),可集成NextChatone-api

接口文档:

http://<ip>:<port>/swagger/index.html

示例:

如何使用

  1. 打开 discord开发者平台
  2. 创建bot-A,并记录bot专属的tokenid(COZE_BOT_ID),此bot为被coze托管的bot。
  3. 创建bot-B,并记录bot专属的token(BOT_TOKEN),此bot为我们与discord交互的bot。
  4. 两个bot开通对应权限(Send Messages,Read Message History等)并邀请进服务器,记录服务器ID(GUILD_ID) ( 过程不在此赘述)。
  5. 打开 coze官网 创建自己bot。
  6. 创建好后推送,配置discord-bot的token,即bot-A的token,点击完成后在discord的服务器中可看到bot-A在线并可以@使用。
  7. 配置环境变量,并启动本项目。
  8. 访问接口地址即可开始调试。

如何集成one-api

BaseURL 及 密钥(PROXY_SECRET),其它的随便填随便选。

如何集成NextChat

部署

基于 Docker-Compose(All In One) 进行部署

docker-compose pull && docker-compose up -d

docker-compose.yml

version: '3.4'

services:
  coze-discord-proxy:
    image: deanxv/coze-discord-proxy:latest
    container_name: coze-discord-proxy
    restart: always
    ports:
      - "7077:7077"
    volumes:
      - ./data/coze-discord-proxy:/data
    environment:
      - BOT_TOKEN=MTE5OTk2xxxxxxxxxxxxxxrwUrUWNbG63w  # 必须修改为我们主动发送消息的Bot-Token
      - GUILD_ID=119xxxxxxxx796  # 必须修改为两个机器人所在的服务器ID
      - COZE_BOT_ID=119xxxxxxxx7  # 必须修改为由coze托管的机器人ID
      - PROXY_SECRET=123456  # [可选]修改此行为请求头校验的值(前后端统一)
      - CHANNEL_ID=119xxxxxx24  # [可选]默认频道-在使用与openai对齐的接口时(/v1/chat/completions) 消息会默认发送到此频道
      - TZ=Asia/Shanghai

基于 Docker 进行部署

docker run --name coze-discord-proxy -d --restart always \
-p 7077:7077 \
-e BOT_TOKEN="MTE5OTk2xxxxxxxxxxxxxxrwUrUWNbG63w" \
-e GUILD_ID="119xxxxxxxx796" \
-e COZE_BOT_ID="119xxxxxxxx7" \
-e PROXY_SECRET="123456" \
-e CHANNEL_ID="119xxxxxx24" \
-e TZ=Asia/Shanghai \
deanxv/coze-discord-proxy

其中,BOT_TOKEN,GUILD_ID,COZE_BOT_ID,PROXY_SECRET,CHANNEL_ID修改为自己的。

部署到第三方平台

部署到 Zeabur

Zeabur 的服务器在国外,自动解决了网络的问题,同时免费的额度也足够个人使用

点击一键部署:

Deploy on Zeabur

一键部署后 BOT_TOKEN,GUILD_ID,COZE_BOT_ID,PROXY_SECRET,CHANNEL_ID变量也需要替换!

或手动部署:

  1. 首先 fork 一份代码。

  2. 进入 Zeabur,使用github登录,进入控制台。

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

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

  5. 添加环境变量

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

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

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

    PROXY_SECRET:123456 [可选]请求头校验的值(前后端统一),配置此参数后,每次发起请求时请求头加上proxy-secret 参数,即header中添加 proxy-secret:123456

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

    保存。

  6. 选择 Redeploy。

配置

环境变量

  1. BOT_TOKEN:MTE5OTk2xxxxxxxxxxxxxxrwUrUWNbG63w 主动发送消息的Bot-Token
  2. GUILD_ID:119xxxxxxxx796 两个机器人所在的服务器ID
  3. COZE_BOT_ID:119xxxxxxxx7 由coze托管的机器人ID
  4. PROXY_SECRET:123456 [可选]请求头校验的值(前后端统一),配置此参数后,每次发起请求时请求头加上proxy-secret 参数,即header中添加 proxy-secret:123456
  5. CHANNEL_ID:119xxxxxx24 # [可选]默认频道-在使用与openai对齐的接口时(/v1/chat/completions) 消息会默认发送到此频道

⭐ Star History

Star History Chart

其他

Coze 官网 : https://www.coze.com

Discord 开发地址 : https://discord.com/developers/applications

coze-discord-proxy's People

Contributors

deanxv avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.