Skip to content
This repository has been archived by the owner on Jul 4, 2024. It is now read-only.

Commit

Permalink
无留言
Browse files Browse the repository at this point in the history
  • Loading branch information
NekoCurit committed Jan 31, 2024
1 parent 4000446 commit b85b6a3
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 19 deletions.
Empty file added Dockerfile
Empty file.
53 changes: 37 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,36 @@ _觉得有点用的话 别忘了点个🌟_

</div>

## 简介
## 截图

其实这个项目灵感来源于Github上的其它项目..
![image](https://github.com/catx-feitu/Coze-Discord-Bridge/assets/108512490/285d33e5-6898-4324-8f9c-8842f3a3912c)

但是考虑到要在Windows VPS上部署~以及作者技术不行~
## 留言

因此就做出来了这个
没有特殊需求不会/很少维护

## 截图
作者本身来自Minecraft挂圈 是圈子内很少见不魔怔 不圈钱的高层用户

![image](https://github.com/catx-feitu/Coze-Discord-Bridge/assets/108512490/285d33e5-6898-4324-8f9c-8842f3a3912c)
因为一些不可抗拒等等问题 需要回去一趟

如果有能力 你也可以通过提交pr来继续维护项目

## 功能

注:是最新源代码里支持的功能 不是Release里的 要看Release的往前翻Commit api文档 配置文件同样

- [X] HTTP/HTTPS API支持
- [X] 支持文生图(需`coze`配置`DALL·E3`/`DALL·E2`插件)返回图片url
- [X] 支持图生文(需`coze`配置`GPT4V`插件)(发送的文本消息中携带图片url即可)
- [X] 支持图生文(需`coze`配置`GPT4V`插件)(发送的文本消息中携带图片url/自己上传base64图片)
- [x] 支持对话隔离
- [X] 对话支持流式返回
- [ ] 支持和`openai`对齐的接口(`v1/chat/completions`)
- [X] 支持和`openai`对齐的对话接口(`v1/chat/completions`)
- [X] 支持和`openai`对齐的图像生成接口(`v1/images/generations`)
- [ ] 突破Discord Bot 2k字消息长度上限
- [ ] WebUI
- [ ] 多个Bot 负载均衡

大饼很甜,苦了的只是猫猫

## 你需要的东西

Expand Down Expand Up @@ -151,7 +159,7 @@ ps:Changelog必填 随便写即可 如果你有强迫症的话那..不太建议.

![image](https://github.com/catx-feitu/Coze-Discord-Bridge/assets/108512490/fac6a998-c32b-4a39-aef3-f8a00b1ab65f)

4.再次运行 `java -jar CozeDiscordBridge-xxxxxx.jar` 如下显示则正常
4.再次运行 `java -jar CozeDiscordBridge-xxxxxx.jar` 如下显示则正常 如果您是使用的是Windows且控制台编码为GBK 请先执行`chcp 65001`

![image](https://github.com/catx-feitu/Coze-Discord-Bridge/assets/108512490/803bfe60-39d5-42d5-b1b3-7aaf932a2808)

Expand Down Expand Up @@ -216,13 +224,19 @@ ps:第一次启动报错 `读取 cache_names.json 失败` 正常 直接忽略即

`````
curl --no-buffer "http://127.0.0.1:8092/api/ChatStream?name=1201576967368085686&prompt=1"
{"code":200,"data":{"done":false,"files":[],"prompt_all":"Ah, I see you've signaled me with a \"1\". How","prompt_new":"Ah, I see you've signaled me with a \"1\". How"},"message":"生成中.."}
{"code":200,"data":{"done":false,"files":[],"prompt_all":"Ah, I see you've signaled me with a \"1\". How can","prompt_new":" can"},"message":"生成中.."}
{"code":200,"data":{"done":false,"files":[],"prompt_all":"Ah, I see you've signaled me with a \"1\". How can I assist","prompt_new":" I assist"},"message":"生成中.."}
{"code":200,"data":{"done":false,"files":[],"prompt_all":"Ah, I see you've signaled me with a \"1\". How can I assist you","prompt_new":" you"},"message":"生成中.."}
{"code":200,"data":{"done":false,"files":[],"prompt_all":"Ah, I see you've signaled me with a \"1\". How can I assist you today? If you have any questions or there's something you'd like to share, please go ahead","prompt_new":" today? If you have any questions or there's something you'd like to share, please go ahead"},"message":"生成中.."}
{"code":200,"data":{"done":false,"files":[],"prompt_all":"Ah, I see you've signaled me with a \"1\". How can I assist you today? If you have any questions or there's something you'd like to share, please go ahead!","prompt_new":"!"},"message":"生成中.."}
{"code":200,"data":{"done":true,"files":[],"prompt_all":"Ah, I see you've signaled me with a \"1\". How can I assist you today? If you have any questions or there's something you'd like to share, please go ahead!","prompt_new":""},"message":"成功!"}
data: {"code":200,"data":{"done":false,"files":[],"prompt_all":"Ah, I see you've signaled me with a \"1\". How","prompt_new":"Ah, I see you've signaled me with a \"1\". How"},"message":"生成中.."}
data: {"code":200,"data":{"done":false,"files":[],"prompt_all":"Ah, I see you've signaled me with a \"1\". How can","prompt_new":" can"},"message":"生成中.."}
data: {"code":200,"data":{"done":false,"files":[],"prompt_all":"Ah, I see you've signaled me with a \"1\". How can I assist","prompt_new":" I assist"},"message":"生成中.."}
data: {"code":200,"data":{"done":false,"files":[],"prompt_all":"Ah, I see you've signaled me with a \"1\". How can I assist you","prompt_new":" you"},"message":"生成中.."}
data: {"code":200,"data":{"done":false,"files":[],"prompt_all":"Ah, I see you've signaled me with a \"1\". How can I assist you today? If you have any questions or there's something you'd like to share, please go ahead","prompt_new":" today? If you have any questions or there's something you'd like to share, please go ahead"},"message":"生成中.."}
data:{"code":200,"data":{"done":false,"files":[],"prompt_all":"Ah, I see you've signaled me with a \"1\". How can I assist you today? If you have any questions or there's something you'd like to share, please go ahead!","prompt_new":"!"},"message":"生成中.."}
data: {"code":200,"data":{"done":true,"files":[],"prompt_all":"Ah, I see you've signaled me with a \"1\". How can I assist you today? If you have any questions or there's something you'd like to share, please go ahead!","prompt_new":""},"message":"成功!"}
`````

<br>
Expand Down Expand Up @@ -256,6 +270,13 @@ curl --no-buffer "http://127.0.0.1:8092/api/ChatStream?name=1201576967368085686&
参数:String name 名称 | String new_name 新名称

返回:Int code 状态码 200为成功 | String message 信息 额外说明 | data {Boolean status 是否成功,String conversation_id 频道ID,String conversation_name 频道名称} 数据

<br>

终结点:`/v1/xxxx` OpenAI官方接口适配

仅适配了部分 具体请参照[OpenAI官方文档](https://platform.openai.com/docs/introduction)

## Api-key

确保安全性 您还可以通过配置文件开启安全访问
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public ResponseType handle(HandleType Handle) {
json_data.put("done", false);
json.put("data", json_data);

os.write((json.toJSONString() + "\r\n").getBytes(StandardCharsets.UTF_8));
os.write(("data: " + json.toJSONString() + "\n\n").getBytes(StandardCharsets.UTF_8));
os.flush();
OldMessage = Reply.TextMessage;
}
Expand All @@ -143,10 +143,11 @@ public ResponseType handle(HandleType Handle) {
json_data.put("files", Reply.Files);
json_data.put("done", true);
json.put("data", json_data);
os.write((json.toJSONString() + "\r\n").getBytes(StandardCharsets.UTF_8));
os.write(("data: " + json.toJSONString() + "\n\n").getBytes(StandardCharsets.UTF_8));
os.flush();
Handle.HttpExchange.sendResponseHeaders(200, 0);
Handle.HttpExchange.close();
return Response;
} catch (Exception ignored) { }
} else {
Response.code = 502;
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/catx/feitu/coze_discord_bridge/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ public static void main(String[] args) {
logger.info("Coze-Discord-Bridge 初始化完毕,正在登录Discord...");
// 程序退出前执行
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
Discord.api.disconnect();
if (Discord.api != null) {
Discord.api.disconnect();
}
}));
// Discord 登录
Discord.discord_init();
Expand Down

0 comments on commit b85b6a3

Please sign in to comment.