Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yd-ai
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xingmin
yd-ai
Commits
e2ae91a5
Commit
e2ae91a5
authored
Apr 23, 2026
by
zhangxingmin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
push
parent
af716593
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
3 deletions
+5
-3
yd-ai-api/src/main/java/com/yd/ai/api/service/impl/ApiAiStreamServiceImpl.java
+5
-3
No files found.
yd-ai-api/src/main/java/com/yd/ai/api/service/impl/ApiAiStreamServiceImpl.java
View file @
e2ae91a5
...
...
@@ -40,7 +40,7 @@ public class ApiAiStreamServiceImpl implements ApiAiStreamService {
*/
@Override
public
Flux
<
ServerSentEvent
<
String
>>
streamChat
(
String
question
)
{
// 敏感词校验
// 敏感词校验
(此部分代码保持不变)
try
{
apiSensitiveWordDetailService
.
checkWord
(
question
);
}
catch
(
BusinessException
e
)
{
...
...
@@ -111,8 +111,10 @@ public class ApiAiStreamServiceImpl implements ApiAiStreamService {
})
.
map
(
result
->
{
String
delta
=
result
.
getOutput
().
getChoices
().
get
(
0
).
getMessage
().
getContent
();
// 注意:不要对 delta 做额外处理,保持原样以保留 Markdown 格式
return
ServerSentEvent
.
builder
(
delta
).
build
();
// ===== 核心修复:在 delta 后追加换行符 =====
// 为了确保 Markdown 格式(特别是表格)不被破坏,我们强制在 delta 后追加一个换行符。
// 这确保了流式片段在拼接后,能够保留正确的换行结构。
return
ServerSentEvent
.
builder
(
delta
+
"\n"
).
build
();
})
.
onErrorResume
(
e
->
{
log
.
error
(
"流式响应处理出错: {}"
,
e
.
getMessage
());
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment