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

Commit

Permalink
[#][README.md] 迁移
Browse files Browse the repository at this point in the history
  • Loading branch information
NahidaLing committed Feb 13, 2024
1 parent bf8c4ea commit 8c32564
Showing 1 changed file with 4 additions and 124 deletions.
128 changes: 4 additions & 124 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ _觉得有点用的话 别忘了点个🌟_
- [X] 支持和`openai`对齐的图像生成接口(`v1/images/generations`)
- [X] 突破Discord Bot 2k字消息长度上限
- [X] 定时活跃机器人 自定义活跃间隔 避免bot因为太久未互动而离线
- [ ] 导入此jar进行二次开发 [::80%]
- [X] API IP白名单
- [ ] 导入此jar进行二次开发
- [ ] WebUI
- [ ] 多个Bot 负载均衡
- [ ] Token计数
Expand Down Expand Up @@ -187,130 +188,9 @@ Keepalive_sendMessage: "keepalive"

## API文档

调用方式: GET `http://地址:端口/终结点?key1=value1&key2=value2` POST `http://地址:端口/终结点` `{"key1":"value1","key2":"value2"}`
已迁移到新的地方了 点击下方跳转

终结点无需区分大小写

<br>

终结点:`/` 根目录

参数:无

返回:Int code 状态码 固定200 | String message 信息 固定内容 | data {Int now 当前时间 10位时间戳} 数据

<br>

终结点:`/Ping` 检查服务是否活着

参数:无

返回:Int code 状态码 固定200 | String message 信息 固定Pong!

<br>

终结点:`/api/CreateConversation` 创建对话

参数:<可选>String name 创建的子频道名称 也可以用于之后调用(如果没开启 `Disable_Name_Cache` 的话)

返回:Int code 状态码 200为成功 | String message 信息 额外说明 | data {String conversation_id 频道ID 即使开启 `Disable_Name_Cache` 也能用作日后调用对话,String conversation_name 频道名称 如果参数 `name` 为空则随机生成} 数据

<br>

终结点:`/api/Chat` 聊天

参数:String name 名称 | String prompt 提示词 | <可选>String image 图片(经过base64编码过的png图片数据)

返回:Int code 状态码 200为成功 | String message 信息 额外说明 | data {String prompt bot生成的文本,String[] files bot生成/找到的图片} 数据

<br>

终结点:`/api/ChatStream` 聊天

参数:String name 名称 | String prompt 提示词 | <可选>String image 图片(经过base64编码过的png图片数据)

返回:

中途:Int code 状态码 200为成功 | String message 信息 固定为`生成中` | data {String prompt_all bot生成的文本,String prompt_new bot新生成的文本,String[] files bot生成/找到的图片,Boolean done 是否完成 固定false} 数据

完成:Int code 状态码 200为成功 | String message 信息 | data {String prompt_all bot生成的文本,String prompt_new bot新生成的文本 为空,String[] files bot生成/找到的图片,Boolean done 是否完成 固定true} 数据

`````
curl --no-buffer "http://127.0.0.1:8092/api/ChatStream?name=1201576967368085686&prompt=1"
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>

终结点:`/api/GetLatestMessage` 获取上一次对话消息(常用于聊天中途连接丢失获取消息内容)

参数:String name 名称

返回:Int code 状态码 200为成功 | String message 信息 额外说明 | data {Boolean status 是否找到,String prompt bot生成的文本,String[] files bot生成/找到的图片} 数据

<br>

终结点:`/api/ConversationIsFound` 对话是否存在

参数:String name 名称

返回:Int code 状态码 200为成功 | String message 信息 额外说明 | data {Boolean status 是否存在,String conversation_id 频道ID 即使开启 `Disable_Name_Cache` 也能用作日后调用对话,String conversation_name 频道名称} 数据

<br>

终结点:`/api/DeleteConversation` 删除对话

参数:String name 名称

返回:Int code 状态码 200为成功 | String message 信息 额外说明 | data {Boolean status 是否成功} 数据

<br>

终结点:`/api/RenameConversation` 对话改名 如果你开启 `Disable_Name_Cache` 那么只能改Discord子频道名称

参数:String name 名称 | String new_name 新名称

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

<br>

终结点:`/api/keepalive` 执行keepalive任务

参数:无

返回:Int code 状态码 200为成功 | String message 信息 额外说明

<br>


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

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

## Api-key

确保安全性 您还可以通过配置文件开启安全访问

之后你需要在header或者请求参数中添加`key`属性才能访问

````
D:\GITHUB\coze-discord-bridge\build\libs>curl --get --data-urlencode "prompt=___启动" "http://127.0.0.1:8092/api/Chat?name=xxxxxxxxxxx
{"code":403,"message":"无权访问本服务"}
D:\GITHUB\coze-discord-bridge\build\libs>curl --get --data-urlencode "prompt=___启动" "http://127.0.0.1:8092/api/Chat?name=xxxxxxxxxxx&key=nya_
{"code":200,"data":{"files":[],"prompt":"哦,明白啦!如果你是在寻求帮助来启动《___》游戏,......"},"message":"成功!"}
````
[传送门](https://github.com/catx-feitu/Coze-Discord-Bridge/wiki/HTTP-API-%E7%BB%88%E7%BB%93%E7%82%B9%E5%88%97%E8%A1%A8)

## 结尾

Expand Down

0 comments on commit 8c32564

Please sign in to comment.