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
675d08ad
Commit
675d08ad
authored
Aug 15, 2024
by
林洋洋
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev_1.0.0' of
http://gitlab.solr.com.cn:10000/linyangyang/db_gpt
into dev_1.0.0
parents
3016d7a4
e6f925b0
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
29 additions
and
38 deletions
+29
-38
.gitignore
.gitignore
+2
-0
crud.py
dbgpt/app/apps/vadmin/media/crud.py
+5
-7
media.py
dbgpt/app/apps/vadmin/media/schemas/media.py
+3
-3
views.py
dbgpt/app/apps/vadmin/media/views.py
+1
-1
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
+16
-27
No files found.
.gitignore
View file @
675d08ad
...
@@ -155,6 +155,8 @@ logswebserver.log.*
...
@@ -155,6 +155,8 @@ logswebserver.log.*
# Ignore for now
# Ignore for now
thirdparty
thirdparty
/file/**
#web
#web
# dependencies
# dependencies
/web/node_modules
/web/node_modules
...
...
dbgpt/app/apps/vadmin/media/crud.py
View file @
675d08ad
...
@@ -43,9 +43,8 @@ class MediaDal(DalBase):
...
@@ -43,9 +43,8 @@ class MediaDal(DalBase):
await
self
.
db
.
execute
(
sql
)
await
self
.
db
.
execute
(
sql
)
async
def
get_count_by_groupIds
(
self
,
ids
:
list
)
->
int
:
async
def
get_count_by_groupIds
(
self
,
ids
:
list
)
->
int
:
async
with
Session
()
as
session
:
stmt
=
select
(
func
.
count
(
self
.
model
.
id
))
.
where
(
self
.
model
.
group_id
.
in_
(
ids
))
stmt
=
select
(
func
.
count
(
self
.
model
.
id
))
.
where
(
self
.
model
.
group_id
.
in_
(
ids
))
result
=
await
session
.
execute
(
stmt
)
result
=
await
self
.
db
.
execute
(
stmt
)
count
=
result
.
scalar
()
count
=
result
.
scalar
()
return
count
return
count
...
@@ -80,7 +79,6 @@ class QuestionDal(DalBase):
...
@@ -80,7 +79,6 @@ class QuestionDal(DalBase):
await
self
.
db
.
execute
(
sql
)
await
self
.
db
.
execute
(
sql
)
class
CorrelationDal
(
DalBase
):
class
CorrelationDal
(
DalBase
):
def
__init__
(
self
,
db
:
AsyncSession
):
def
__init__
(
self
,
db
:
AsyncSession
):
...
...
dbgpt/app/apps/vadmin/media/schemas/media.py
View file @
675d08ad
...
@@ -36,9 +36,9 @@ class GroupOut(Group):
...
@@ -36,9 +36,9 @@ class GroupOut(Group):
class
Question
(
BaseModel
):
class
Question
(
BaseModel
):
title
:
str
title
:
str
|
None
=
None
key_word
:
str
key_word
:
str
|
None
=
None
answer
:
str
answer
:
str
|
None
=
None
group_id
:
int
|
None
=
0
group_id
:
int
|
None
=
0
...
...
dbgpt/app/apps/vadmin/media/views.py
View file @
675d08ad
...
@@ -56,7 +56,7 @@ async def group_del(ids: IdList = Depends(), auth: Auth = Depends(FullAdminAuth(
...
@@ -56,7 +56,7 @@ async def group_del(ids: IdList = Depends(), auth: Auth = Depends(FullAdminAuth(
media_counts
=
await
crud
.
MediaDal
(
auth
.
db
)
.
get_count_by_groupIds
(
ids
.
ids
)
media_counts
=
await
crud
.
MediaDal
(
auth
.
db
)
.
get_count_by_groupIds
(
ids
.
ids
)
if
media_counts
>
0
:
if
media_counts
>
0
:
return
ErrorResponse
(
"分组内不为空,无法删除"
)
return
ErrorResponse
(
"分组内不为空,无法删除"
)
#
await crud.GroupDal(auth.db).delete_datas(ids.ids, v_soft=True)
await
crud
.
GroupDal
(
auth
.
db
)
.
delete_datas
(
ids
.
ids
,
v_soft
=
True
)
return
SuccessResponse
(
"删除成功"
)
return
SuccessResponse
(
"删除成功"
)
...
...
dbgpt/app/apps/vadmin/word/schemas/sensitive.py
View file @
675d08ad
...
@@ -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 @
675d08ad
...
@@ -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 @
675d08ad
...
@@ -15,6 +15,8 @@ from dbgpt.app.apps.vadmin.word.params.sensitive import SensitiveParams
...
@@ -15,6 +15,8 @@ from dbgpt.app.apps.vadmin.word.params.sensitive import SensitiveParams
from
dbgpt.app.apps.vadmin.word
import
crud
from
dbgpt.app.apps.vadmin.word
import
crud
from
fastapi.encoders
import
jsonable_encoder
from
fastapi.encoders
import
jsonable_encoder
from
...core.dependencies
import
IdList
router
=
APIRouter
()
router
=
APIRouter
()
...
@@ -22,7 +24,7 @@ router = APIRouter()
...
@@ -22,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
(),
...
@@ -32,7 +34,7 @@ async def get_similars(para: SimilarParams = Depends(), auth: Auth = Depends(Ope
...
@@ -32,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
:
...
@@ -44,24 +46,19 @@ async def create_similar(qdata: Request, auth: Auth = Depends(OpenAuth())):
...
@@ -44,24 +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
(
data
:
Request
,
auth
:
Auth
=
Depends
(
OpenAuth
())):
async
def
delete_similars
(
ids
:
IdList
=
Depends
(),
auth
:
Auth
=
Depends
(
FullAdminAuth
())):
if
data
is
None
:
await
crud
.
SimilarDal
(
auth
.
db
)
.
delete_datas
(
ids
=
ids
.
ids
,
v_soft
=
True
)
return
ErrorResponse
(
"删除同义词请求参数为空!"
)
data_id
=
data
.
query_params
[
'word_id'
]
similarids
=
[
data_id
]
await
crud
.
SimilarDal
(
auth
.
db
)
.
delete_datas
(
ids
=
similarids
,
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'
]
...
@@ -77,7 +74,7 @@ async def update_similar_byid(data: Request, auth: Auth = Depends(OpenAuth())):
...
@@ -77,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
:
...
@@ -88,7 +85,7 @@ async def create_sensitive(qdata: Request, auth: Auth = Depends(OpenAuth())):
...
@@ -88,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
(),
...
@@ -98,14 +95,14 @@ async def get_sensitives(para: SensitiveParams = Depends(), auth: Auth = Depends
...
@@ -98,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'
]
...
@@ -117,14 +114,6 @@ async def update_sensitive_byid(data: Request, auth: Auth = Depends(OpenAuth()))
...
@@ -117,14 +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
(
data
:
Request
,
auth
:
Auth
=
Depends
(
OpenAuth
())):
async
def
delete_sensitives
(
ids
:
IdList
=
Depends
(),
auth
:
Auth
=
Depends
(
FullAdminAuth
())):
if
data
is
None
:
await
crud
.
SensitiveDal
(
auth
.
db
)
.
delete_datas
(
ids
=
ids
.
ids
,
v_soft
=
True
)
print
(
'sensitive request is None'
)
return
ErrorResponse
(
"不能删除当前敏感词"
)
else
:
print
(
f
"word_id:{data.query_params['word_id']} "
)
data_id
=
data
.
query_params
[
'word_id'
]
sensitiveids
=
[
data_id
]
await
crud
.
SensitiveDal
(
auth
.
db
)
.
delete_datas
(
ids
=
sensitiveids
,
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