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
1885b978
Commit
1885b978
authored
Apr 07, 2026
by
zhangxingmin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
push
parent
95a346f4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
10 deletions
+15
-10
yd-ai-api/src/main/java/com/yd/ai/api/service/impl/ApiAiStreamServiceImpl.java
+15
-10
No files found.
yd-ai-api/src/main/java/com/yd/ai/api/service/impl/ApiAiStreamServiceImpl.java
View file @
1885b978
...
@@ -46,28 +46,33 @@ public class ApiAiStreamServiceImpl implements ApiAiStreamService {
...
@@ -46,28 +46,33 @@ public class ApiAiStreamServiceImpl implements ApiAiStreamService {
}
catch
(
BusinessException
e
)
{
}
catch
(
BusinessException
e
)
{
int
code
=
e
.
getCode
();
int
code
=
e
.
getCode
();
if
(
code
==
ResultCode
.
SENSITIVE_WORDS_EXIST
.
getCode
())
{
if
(
code
==
ResultCode
.
SENSITIVE_WORDS_EXIST
.
getCode
())
{
// 禁用类型敏感词:返回
温馨提示语,不调用大模型
// 禁用类型敏感词:返回
提示语
log
.
info
(
"检测到禁用敏感词,返回提示语
,question: {}"
,
question
);
log
.
info
(
"检测到禁用敏感词,返回提示语
"
);
String
tipMsg
=
"抱歉,您输入的内容包含敏感词汇,无法为您提供服务。请调整后重新提问。"
;
String
tipMsg
=
"抱歉,您输入的内容包含敏感词汇,无法为您提供服务。请调整后重新提问。"
;
return
Flux
.
just
(
ServerSentEvent
.
builder
(
tipMsg
).
build
());
return
Flux
.
just
(
ServerSentEvent
.
builder
(
tipMsg
).
build
());
}
else
if
(
code
==
ResultCode
.
SENSITIVE_TZ_WORDS_EXIST
.
getCode
())
{
}
else
if
(
code
==
ResultCode
.
SENSITIVE_TZ_WORDS_EXIST
.
getCode
())
{
// 通知类型敏感词:发送企业微信通知
后继续抛出异常,让前端处理
产品列表
// 通知类型敏感词:发送企业微信通知
,然后返回一个特殊事件告知前端展示
产品列表
log
.
info
(
"检测到通知类型敏感词,发送企业微信通知
,question: {}"
,
question
);
log
.
info
(
"检测到通知类型敏感词,发送企业微信通知
"
);
AuthUserDto
authUserDto
=
SecurityUtil
.
getCurrentLoginUser
();
AuthUserDto
authUserDto
=
SecurityUtil
.
getCurrentLoginUser
();
String
userName
=
authUserDto
.
getUsername
();
String
userName
=
authUserDto
.
getUsername
();
String
params
=
"{\"customerName\":\""
+
userName
+
"\"}"
;
String
params
=
"{\"customerName\":\""
+
userName
+
"\"}"
;
ApiSendRequest
request
=
new
ApiSendRequest
();
ApiSendRequest
request
=
new
ApiSendRequest
();
request
.
setChannelBizId
(
"wecom_default"
);
request
.
setChannelBizId
(
"wecom_default"
);
request
.
set
Channel
BizId
(
"tpl_wecom_order"
);
request
.
set
Template
BizId
(
"tpl_wecom_order"
);
request
.
setReceiver
(
"zxm|Sweet"
);
request
.
setReceiver
(
"zxm|Sweet"
);
request
.
setParams
(
params
);
request
.
setParams
(
params
);
apiNotificationTaskFeignClient
.
send
(
request
);
apiNotificationTaskFeignClient
.
send
(
request
);
// 抛出异常,前端根据code=50002调用产品列表接口
throw
new
BusinessException
(
e
.
getCode
(),
e
.
getMsg
());
// 返回 SSE 事件,event 类型为 sensitive_notification,前端根据此事件调用产品列表接口
}
else
{
return
Flux
.
just
(
// 其他异常继续抛出
ServerSentEvent
.<
String
>
builder
()
throw
e
;
.
event
(
"sensitive_notification"
)
.
data
(
"show_products"
)
.
build
()
);
}
}
// 其他异常继续抛出
throw
e
;
}
}
// 正常调用大模型流式接口
// 正常调用大模型流式接口
...
...
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