Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
db_gpt
Project
Project
Details
Activity
Releases
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
linyangyang
db_gpt
Commits
af31c91a
Commit
af31c91a
authored
Sep 12, 2024
by
于飞
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
敏感词加载修改---多添加一个接口
parent
b2a61834
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
3 deletions
+9
-3
keywordsviews.py
dbgpt/app/apps/vadmin/keywordsviews.py
+9
-3
No files found.
dbgpt/app/apps/vadmin/keywordsviews.py
View file @
af31c91a
...
...
@@ -32,15 +32,15 @@ async def get_spacy_keywords(dialogue: ConversationVo = Body(), auth: Auth = Dep
print
(
'----------------begin---------------->'
)
# 从数据库中加载 并且初始化敏感词-->到内存中
await
mydfafiter
.
parse_from_db
(
auth
.
db
)
#
await mydfafiter.parse_from_db(auth.db)
#先判断敏感词
dfa_result
,
is_sensitive
=
mydfafiter
.
filter
(
dialogue
.
user_input
,
"*"
)
dfa_result
,
is_sensitive
,
matched_sensitives
=
mydfafiter
.
filter
(
dialogue
.
user_input
,
"*"
)
print
(
dfa_result
)
if
is_sensitive
:
print
(
'用户输入有敏感词'
)
result
=
{
'code'
:
200
,
'message'
:
'success'
,
'data'
:
[{
'type'
:
3
,
'word_name'
:
'111'
,
'is_sensitive'
:
1
,
'user_input'
:
dfa_result
}]}
result
=
{
'code'
:
200
,
'message'
:
'success'
,
'data'
:
[{
'type'
:
3
,
'word_name'
:
matched_sensitives
,
'is_sensitive'
:
1
,
'user_input'
:
dfa_result
}]}
return
SuccessResponse
(
result
)
#返回type=3
#没有敏感词的时候,查找是否有相关图片 或者 视频
...
...
@@ -86,6 +86,12 @@ async def get_spacy_keywords(dialogue: ConversationVo = Body(), auth: Auth = Dep
print
(
f
"-----没有找到需要查询的内容:---->"
)
return
ErrorResponse
(
"没有找到需要查询的内容"
)
@
router
.
get
(
"/load_parse_from_db"
,
summary
=
"加载敏感词"
)
async
def
load_parse_from_db
(
auth
:
Auth
=
Depends
(
OpenAuth
())):
# 从数据库中加载 并且初始化敏感词-->到内存中
await
mydfafiter
.
parse_from_db
(
auth
.
db
)
return
SuccessResponse
(
"sensitive load OK"
)
...
...
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