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
af716593
Commit
af716593
authored
Apr 23, 2026
by
zhangxingmin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
push
parent
1f4a3464
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
0 deletions
+15
-0
yd-ai-api/src/main/java/com/yd/ai/api/service/impl/ApiAiStreamServiceImpl.java
+15
-0
No files found.
yd-ai-api/src/main/java/com/yd/ai/api/service/impl/ApiAiStreamServiceImpl.java
View file @
af716593
...
...
@@ -100,9 +100,23 @@ public class ApiAiStreamServiceImpl implements ApiAiStreamService {
// 将 RxJava Flowable 转为 Reactor Flux
return
Flux
.
from
(
flowable
)
.
filter
(
result
->
{
// 过滤掉空结果或没有内容的事件
return
result
!=
null
&&
result
.
getOutput
()
!=
null
&&
result
.
getOutput
().
getChoices
()
!=
null
&&
!
result
.
getOutput
().
getChoices
().
isEmpty
()
&&
result
.
getOutput
().
getChoices
().
get
(
0
).
getMessage
()
!=
null
&&
result
.
getOutput
().
getChoices
().
get
(
0
).
getMessage
().
getContent
()
!=
null
;
})
.
map
(
result
->
{
String
delta
=
result
.
getOutput
().
getChoices
().
get
(
0
).
getMessage
().
getContent
();
// 注意:不要对 delta 做额外处理,保持原样以保留 Markdown 格式
return
ServerSentEvent
.
builder
(
delta
).
build
();
})
.
onErrorResume
(
e
->
{
log
.
error
(
"流式响应处理出错: {}"
,
e
.
getMessage
());
return
Flux
.
just
(
ServerSentEvent
.
builder
(
"系统繁忙,请稍后重试"
).
build
());
});
}
}
\ No newline at end of file
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