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
e6f925b0
Commit
e6f925b0
authored
Aug 15, 2024
by
张会鑫
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
飞哥提交
parent
90f4c8a8
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
12 deletions
+14
-12
sensitive.py
dbgpt/app/apps/vadmin/word/schemas/sensitive.py
+1
-0
similar.py
dbgpt/app/apps/vadmin/word/schemas/similar.py
+1
-0
views.py
dbgpt/app/apps/vadmin/word/views.py
+12
-12
No files found.
dbgpt/app/apps/vadmin/word/schemas/sensitive.py
View file @
e6f925b0
...
@@ -21,6 +21,7 @@ class SensitiveSchemas(BaseModel):
...
@@ -21,6 +21,7 @@ class SensitiveSchemas(BaseModel):
class
SensitiveInDic
(
SensitiveSchemas
):
class
SensitiveInDic
(
SensitiveSchemas
):
model_config
=
ConfigDict
(
from_attributes
=
True
)
model_config
=
ConfigDict
(
from_attributes
=
True
)
id
:
int
word_name
:
str
|
None
=
""
word_name
:
str
|
None
=
""
class
SensitiveIn
(
SensitiveSchemas
):
class
SensitiveIn
(
SensitiveSchemas
):
...
...
dbgpt/app/apps/vadmin/word/schemas/similar.py
View file @
e6f925b0
...
@@ -24,6 +24,7 @@ class SimilarInDic(SimilarSchemas):
...
@@ -24,6 +24,7 @@ class SimilarInDic(SimilarSchemas):
"""
"""
创建近义词
创建近义词
"""
"""
id
:
int
word_name
:
str
word_name
:
str
similar_name
:
str
|
None
=
""
similar_name
:
str
|
None
=
""
...
...
dbgpt/app/apps/vadmin/word/views.py
View file @
e6f925b0
...
@@ -24,7 +24,7 @@ router = APIRouter()
...
@@ -24,7 +24,7 @@ router = APIRouter()
# 同义词管理
# 同义词管理
###########################################################
###########################################################
@
router
.
get
(
"/get_similars"
,
summary
=
"获取同义词列表"
)
@
router
.
get
(
"/get_similars"
,
summary
=
"获取同义词列表"
)
async
def
get_similars
(
para
:
SimilarParams
=
Depends
(),
auth
:
Auth
=
Depends
(
Ope
nAuth
())):
async
def
get_similars
(
para
:
SimilarParams
=
Depends
(),
auth
:
Auth
=
Depends
(
FullAdmi
nAuth
())):
v_schema
=
schemas
.
similar
.
SimilarInDic
v_schema
=
schemas
.
similar
.
SimilarInDic
datas
,
count
=
await
crud
.
SimilarDal
(
auth
.
db
)
.
get_datas
(
datas
,
count
=
await
crud
.
SimilarDal
(
auth
.
db
)
.
get_datas
(
**
para
.
dict
(),
**
para
.
dict
(),
...
@@ -34,7 +34,7 @@ async def get_similars(para: SimilarParams = Depends(), auth: Auth = Depends(Ope
...
@@ -34,7 +34,7 @@ async def get_similars(para: SimilarParams = Depends(), auth: Auth = Depends(Ope
return
SuccessResponse
(
datas
,
count
=
count
)
return
SuccessResponse
(
datas
,
count
=
count
)
@
router
.
post
(
"/create_similar"
,
summary
=
"创建同义词"
)
@
router
.
post
(
"/create_similar"
,
summary
=
"创建同义词"
)
async
def
create_similar
(
qdata
:
Request
,
auth
:
Auth
=
Depends
(
Ope
nAuth
())):
async
def
create_similar
(
qdata
:
Request
,
auth
:
Auth
=
Depends
(
FullAdmi
nAuth
())):
if
qdata
is
None
:
if
qdata
is
None
:
print
(
'create_similar is None'
)
print
(
'create_similar is None'
)
else
:
else
:
...
@@ -46,19 +46,19 @@ async def create_similar(qdata: Request, auth: Auth = Depends(OpenAuth())):
...
@@ -46,19 +46,19 @@ async def create_similar(qdata: Request, auth: Auth = Depends(OpenAuth())):
return
SuccessResponse
(
await
crud
.
SimilarDal
(
auth
.
db
)
.
create_data
(
data
=
simi_data
))
return
SuccessResponse
(
await
crud
.
SimilarDal
(
auth
.
db
)
.
create_data
(
data
=
simi_data
))
@
router
.
post
(
"/delete_similars"
,
summary
=
"根据id删除同义词"
)
@
router
.
post
(
"/delete_similars"
,
summary
=
"根据id删除同义词"
)
async
def
delete_similars
(
ids
:
IdList
=
Depends
(),
auth
:
Auth
=
Depends
(
Ope
nAuth
())):
async
def
delete_similars
(
ids
:
IdList
=
Depends
(),
auth
:
Auth
=
Depends
(
FullAdmi
nAuth
())):
await
crud
.
SimilarDal
(
auth
.
db
)
.
delete_datas
(
ids
=
ids
.
ids
,
v_soft
=
True
)
await
crud
.
SimilarDal
(
auth
.
db
)
.
delete_datas
(
ids
=
ids
.
ids
,
v_soft
=
True
)
return
SuccessResponse
(
"删除成功"
)
return
SuccessResponse
(
"删除成功"
)
@
router
.
post
(
"/update_similar_byid"
,
summary
=
"根据id修改同义词"
)
@
router
.
post
(
"/update_similar_byid"
,
summary
=
"根据id修改同义词"
)
async
def
update_similar_byid
(
data
:
Request
,
auth
:
Auth
=
Depends
(
Ope
nAuth
())):
async
def
update_similar_byid
(
data
:
Request
,
auth
:
Auth
=
Depends
(
FullAdmi
nAuth
())):
if
data
is
None
:
if
data
is
None
:
print
(
'SimilarIn is None'
)
print
(
'SimilarIn is None'
)
return
ErrorResponse
(
"不能修改当前近义词"
)
return
ErrorResponse
(
"不能修改当前近义词"
)
else
:
else
:
print
(
f
"word_id:{data.query_params['
word_
id']} req词条:{data.query_params['word_name']} req近义词:{data.query_params['similar_name']} "
)
print
(
f
"word_id:{data.query_params['id']} req词条:{data.query_params['word_name']} req近义词:{data.query_params['similar_name']} "
)
data_id
=
data
.
query_params
[
'
word_
id'
]
data_id
=
data
.
query_params
[
'id'
]
sdata
=
SimilarUpdate
sdata
=
SimilarUpdate
sdata
.
word_name
=
data
.
query_params
[
'word_name'
]
sdata
.
word_name
=
data
.
query_params
[
'word_name'
]
...
@@ -74,7 +74,7 @@ async def update_similar_byid(data: Request, auth: Auth = Depends(OpenAuth())):
...
@@ -74,7 +74,7 @@ async def update_similar_byid(data: Request, auth: Auth = Depends(OpenAuth())):
# 敏感词管理
# 敏感词管理
###########################################################
###########################################################
@
router
.
post
(
"/create_sensitive"
,
summary
=
"创建敏感词"
)
@
router
.
post
(
"/create_sensitive"
,
summary
=
"创建敏感词"
)
async
def
create_sensitive
(
qdata
:
Request
,
auth
:
Auth
=
Depends
(
Ope
nAuth
())):
async
def
create_sensitive
(
qdata
:
Request
,
auth
:
Auth
=
Depends
(
FullAdmi
nAuth
())):
if
qdata
is
None
:
if
qdata
is
None
:
print
(
'create_sensitive is None'
)
print
(
'create_sensitive is None'
)
else
:
else
:
...
@@ -85,7 +85,7 @@ async def create_sensitive(qdata: Request, auth: Auth = Depends(OpenAuth())):
...
@@ -85,7 +85,7 @@ async def create_sensitive(qdata: Request, auth: Auth = Depends(OpenAuth())):
return
SuccessResponse
(
await
crud
.
SensitiveDal
(
auth
.
db
)
.
create_data
(
data
=
Sensit_data
))
return
SuccessResponse
(
await
crud
.
SensitiveDal
(
auth
.
db
)
.
create_data
(
data
=
Sensit_data
))
@
router
.
get
(
"/get_sensitives"
,
summary
=
"获取敏感词列表"
)
@
router
.
get
(
"/get_sensitives"
,
summary
=
"获取敏感词列表"
)
async
def
get_sensitives
(
para
:
SensitiveParams
=
Depends
(),
auth
:
Auth
=
Depends
(
Ope
nAuth
())):
async
def
get_sensitives
(
para
:
SensitiveParams
=
Depends
(),
auth
:
Auth
=
Depends
(
FullAdmi
nAuth
())):
v_schema
=
schemas
.
sensitive
.
SensitiveInDic
v_schema
=
schemas
.
sensitive
.
SensitiveInDic
datas
,
count
=
await
crud
.
SensitiveDal
(
auth
.
db
)
.
get_datas
(
datas
,
count
=
await
crud
.
SensitiveDal
(
auth
.
db
)
.
get_datas
(
**
para
.
dict
(),
**
para
.
dict
(),
...
@@ -95,14 +95,14 @@ async def get_sensitives(para: SensitiveParams = Depends(), auth: Auth = Depends
...
@@ -95,14 +95,14 @@ async def get_sensitives(para: SensitiveParams = Depends(), auth: Auth = Depends
return
SuccessResponse
(
datas
,
count
=
count
)
return
SuccessResponse
(
datas
,
count
=
count
)
@
router
.
post
(
"/update_sensitive_byid"
,
summary
=
"根据id修改敏感词"
)
@
router
.
post
(
"/update_sensitive_byid"
,
summary
=
"根据id修改敏感词"
)
async
def
update_sensitive_byid
(
data
:
Request
,
auth
:
Auth
=
Depends
(
Ope
nAuth
())):
async
def
update_sensitive_byid
(
data
:
Request
,
auth
:
Auth
=
Depends
(
FullAdmi
nAuth
())):
if
data
is
None
:
if
data
is
None
:
print
(
'SimilarIn is None'
)
print
(
'SimilarIn is None'
)
return
ErrorResponse
(
"不能修改当前敏感词"
)
return
ErrorResponse
(
"不能修改当前敏感词"
)
else
:
else
:
print
(
f
"word_id:{data.query_params['
word_
id']} req词条:{data.query_params['word_name']} "
)
print
(
f
"word_id:{data.query_params['id']} req词条:{data.query_params['word_name']} "
)
data_id
=
data
.
query_params
[
'
word_
id'
]
data_id
=
data
.
query_params
[
'id'
]
sdata
=
SensitiveUpdate
sdata
=
SensitiveUpdate
sdata
.
word_name
=
data
.
query_params
[
'word_name'
]
sdata
.
word_name
=
data
.
query_params
[
'word_name'
]
...
@@ -114,6 +114,6 @@ async def update_sensitive_byid(data: Request, auth: Auth = Depends(OpenAuth()))
...
@@ -114,6 +114,6 @@ async def update_sensitive_byid(data: Request, auth: Auth = Depends(OpenAuth()))
return
SuccessResponse
(
"修改成功"
)
return
SuccessResponse
(
"修改成功"
)
@
router
.
post
(
"/delete_sensitives"
,
summary
=
"根据id删除敏感词"
)
@
router
.
post
(
"/delete_sensitives"
,
summary
=
"根据id删除敏感词"
)
async
def
delete_sensitives
(
ids
:
IdList
=
Depends
(),
auth
:
Auth
=
Depends
(
Ope
nAuth
())):
async
def
delete_sensitives
(
ids
:
IdList
=
Depends
(),
auth
:
Auth
=
Depends
(
FullAdmi
nAuth
())):
await
crud
.
SensitiveDal
(
auth
.
db
)
.
delete_datas
(
ids
=
ids
.
ids
,
v_soft
=
True
)
await
crud
.
SensitiveDal
(
auth
.
db
)
.
delete_datas
(
ids
=
ids
.
ids
,
v_soft
=
True
)
return
SuccessResponse
(
"删除成功"
)
return
SuccessResponse
(
"删除成功"
)
\ 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