Skip to content
This repository was archived by the owner on Nov 27, 2025. It is now read-only.

Commit 5c11981

Browse files
committed
修复流式响应消息
1 parent 1152684 commit 5c11981

2 files changed

Lines changed: 41 additions & 3 deletions

File tree

README.md

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,38 @@
55
![](https://img.shields.io/github/forks/llm-red-team/jimeng-free-api.svg)
66
![](https://img.shields.io/docker/pulls/vinlic/jimeng-free-api.svg)
77

8-
支持即梦超强图像生成能力(目前官方每日有 60 积分,可生成 60 次),零配置部署,多路 token 支持,自动清理会话痕迹。
8+
支持即梦超强图像生成能力(目前官方每日有 60 积分,可生成 60 次),零配置部署,多路 token 支持。
9+
10+
与 OpenAI 接口完全兼容。
11+
12+
还有以下十个free-api欢迎关注:
13+
14+
Moonshot AI(Kimi.ai)接口转API [kimi-free-api](https://github.com/LLM-Red-Team/kimi-free-api)
15+
16+
阶跃星辰 (跃问StepChat) 接口转API [step-free-api](https://github.com/LLM-Red-Team/step-free-api)
17+
18+
阿里通义 (Qwen) 接口转API [qwen-free-api](https://github.com/LLM-Red-Team/qwen-free-api)
19+
20+
智谱AI (智谱清言) 接口转API [glm-free-api](https://github.com/LLM-Red-Team/glm-free-api)
21+
22+
秘塔AI (Metaso) 接口转API [metaso-free-api](https://github.com/LLM-Red-Team/metaso-free-api)
23+
24+
字节跳动(豆包)接口转API [doubao-free-api](https://github.com/LLM-Red-Team/doubao-free-api)
25+
26+
讯飞星火(Spark)接口转API [spark-free-api](https://github.com/LLM-Red-Team/spark-free-api)
27+
28+
MiniMax(海螺AI)接口转API [hailuo-free-api](https://github.com/LLM-Red-Team/hailuo-free-api)
29+
30+
深度求索(DeepSeek)接口转API [deepseek-free-api](https://github.com/LLM-Red-Team/deepseek-free-api)
31+
32+
聆心智能 (Emohaa) 接口转API [emohaa-free-api](https://github.com/LLM-Red-Team/emohaa-free-api)
933

10-
与 ChatGPT 接口完全兼容。
1134

1235
## 目录
1336

1437
- [免责声明](#免责声明)
1538
- [接入准备](#接入准备)
39+
* [多账号接入](#多账号接入)
1640
- [Docker 部署](#Docker部署)
1741
- [Docker-compose 部署](#Docker-compose部署)
1842
- [Render 部署](#Render部署)
@@ -41,6 +65,14 @@
4165

4266
进入即梦登录账号,然后 F12 打开开发者工具,从 Application > Cookies 中找到`sessionid`的值,这将作为 Authorization 的 Bearer Token 值:`Authorization: Bearer sessionid`
4367

68+
### 多账号接入
69+
70+
你可以通过提供多个账号的sessionid并使用`,`拼接提供:
71+
72+
`Authorization: Bearer sessionid1,sessionid2,sessionid3`
73+
74+
每次请求服务会从中挑选一个。
75+
4476
## Docker 部署
4577

4678
请准备一台具有公网 IP 的服务器并将 8000 端口开放。

src/api/controllers/chat.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@ export async function createCompletionStream(
112112

113113
const stream = new PassThrough();
114114

115+
if (messages.length === 0) {
116+
logger.warn("消息为空,返回空流");
117+
stream.end("data: [DONE]\n\n");
118+
return stream;
119+
}
120+
115121
stream.write(
116122
"data: " +
117123
JSON.stringify({
@@ -131,7 +137,7 @@ export async function createCompletionStream(
131137

132138
generateImages(
133139
model,
134-
messages.reduce((acc, message) => acc + message.content, ""),
140+
messages[messages.length - 1].content,
135141
{ width, height },
136142
refreshToken
137143
)

0 commit comments

Comments
 (0)