Commit af7ddac3 authored by 于飞's avatar 于飞

铭感词

parent af22fc8a
...@@ -28,7 +28,7 @@ from dbgpt.app.apps.utils.tools import test_password ...@@ -28,7 +28,7 @@ from dbgpt.app.apps.utils.tools import test_password
from . import models, schemas from . import models, schemas
from .params.similar import SimilarParams from .params.similar import SimilarParams
from .schemas.similar import SimilarIn,SimilarUpdate from .schemas.similar import SimilarIn,SimilarUpdate
from .schemas.sensitive import SensitiveIn from .schemas.sensitive import SensitiveIn,SensitiveUpdate
from .models import sensitive from .models import sensitive
from dbgpt.app.apps.config import settings from dbgpt.app.apps.config import settings
...@@ -158,4 +158,15 @@ class SensitiveDal(DalBase): ...@@ -158,4 +158,15 @@ class SensitiveDal(DalBase):
""" """
return list(queryset.all()) return list(queryset.all())
async def update_sensitives(self, ids: [], data: SensitiveUpdate):
"""
修改敏感词
"""
await self.db.execute(
update(self.model).where(self.model.id.in_(ids)).values(
update_datetime=datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
word_name=data.word_name
)
)
...@@ -32,12 +32,8 @@ class SensitiveOut(SensitiveSchemas): ...@@ -32,12 +32,8 @@ class SensitiveOut(SensitiveSchemas):
update_datetime: datetime | None = None update_datetime: datetime | None = None
delete_datetime: datetime | None = None delete_datetime: datetime | None = None
class SensitiveUpdate(BaseModel): class SensitiveUpdate(SensitiveSchemas):
""" """
更新敏感词信息 更新敏感词信息
""" """
word_name: str | None = "" word_name: str | None = ""
is_delete: int | None = 0
create_datetime: datetime | None = None
update_datetime: datetime | None = None
delete_datetime: datetime | None = None
...@@ -10,7 +10,7 @@ from . import schemas, crud, models ...@@ -10,7 +10,7 @@ from . import schemas, crud, models
from dbgpt.app.apps.vadmin.word.models.similar import VadminWordSimilar from dbgpt.app.apps.vadmin.word.models.similar import VadminWordSimilar
from dbgpt.app.apps.vadmin.word.params.similar import SimilarParams from dbgpt.app.apps.vadmin.word.params.similar import SimilarParams
from dbgpt.app.apps.vadmin.word.schemas.similar import SimilarSchemas, SimilarIn,SimilarUpdate from dbgpt.app.apps.vadmin.word.schemas.similar import SimilarSchemas, SimilarIn,SimilarUpdate
from dbgpt.app.apps.vadmin.word.schemas.sensitive import SensitiveSchemas, SensitiveIn from dbgpt.app.apps.vadmin.word.schemas.sensitive import SensitiveSchemas, SensitiveIn,SensitiveUpdate
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
...@@ -59,12 +59,11 @@ async def delete_similars(data: Request, auth: Auth = Depends(OpenAuth())): ...@@ -59,12 +59,11 @@ async def delete_similars(data: Request, auth: Auth = Depends(OpenAuth())):
if data is None: if data is None:
print('SimilarIn is None') print('SimilarIn is None')
return ErrorResponse("不能删除当前近义词") return ErrorResponse("不能删除当前近义词")
"""
else: else:
print(f"req词条:{data.query_params['word_name']} req近义词:{data.query_params['similar_name']} ") print(f"req词条:{data.query_params['word_name']} req近义词:{data.query_params['similar_name']} ")
"""
similarids = [7] data_id = data.query_params['word_id']
similarids = [data_id]
await crud.SimilarDal(auth.db).delete_datas(ids=similarids, v_soft=True) await crud.SimilarDal(auth.db).delete_datas(ids=similarids, v_soft=True)
return SuccessResponse("删除成功") return SuccessResponse("删除成功")
...@@ -74,7 +73,7 @@ async def update_similar_byid(data: Request, auth: Auth = Depends(OpenAuth())): ...@@ -74,7 +73,7 @@ async def update_similar_byid(data: Request, auth: Auth = Depends(OpenAuth())):
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['word_name']} req近义词:{data.query_params['similar_name']} ") print(f"word_id:{data.query_params['word_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['word_id']
...@@ -125,3 +124,35 @@ async def get_sensitives(auth: Auth = Depends(OpenAuth())): ...@@ -125,3 +124,35 @@ async def get_sensitives(auth: Auth = Depends(OpenAuth())):
for row in datas: for row in datas:
print(f"编号:{row.id} 词条:{row.word_name} ") print(f"编号:{row.id} 词条:{row.word_name} ")
return SuccessResponse(jsondatas, count=1) return SuccessResponse(jsondatas, count=1)
@router.post("/update_sensitive_byid", summary="根据id修改敏感词")
async def update_sensitive_byid(data: Request, auth: Auth = Depends(OpenAuth())):
if data is None:
print('SimilarIn is None')
return ErrorResponse("不能修改当前敏感词")
else:
print(f"word_id:{data.query_params['word_id']} req词条:{data.query_params['word_name']} ")
data_id = data.query_params['word_id']
sdata = SensitiveUpdate
sdata.word_name = data.query_params['word_name']
sensitiveids = []
sensitiveids.append(data_id)
await crud.SensitiveDal(auth.db).update_sensitives(sensitiveids, sdata)
return SuccessResponse("修改成功")
@router.post("/delete_sensitives", summary="根据id删除敏感词")
async def delete_sensitives(data: Request, auth: Auth = Depends(OpenAuth())):
if data is None:
print('sensitive request is None')
return ErrorResponse("不能删除当前敏感词")
else:
print(f"req词条:{data.query_params['word_name']} ")
data_id = data.query_params['word_id']
sensitiveids = [data_id]
await crud.SensitiveDal(auth.db).delete_datas(ids=sensitiveids, v_soft=True)
return SuccessResponse("删除成功")
\ No newline at end of file
...@@ -16,24 +16,25 @@ The assistant gives helpful, detailed, professional and polite answers to the us ...@@ -16,24 +16,25 @@ The assistant gives helpful, detailed, professional and polite answers to the us
_DEFAULT_TEMPLATE_ZH = """ 基于以下给出的已知信息, 准守规范约束,专业、简要回答用户的问题. _DEFAULT_TEMPLATE_ZH = """ 基于以下给出的已知信息, 准守规范约束,专业、简要回答用户的问题.
规范约束: 规范约束:
1.如果已知信息包含的图片、链接、表格、代码块等特殊markdown标签格式的信息,确保在答案中包含原文这些图片、链接、表格和代码标签,不要丢弃不要修改,如:图片格式:![image.png](xxx), 链接格式:[xxx](xxx), 表格格式:|xxx|xxx|xxx|, 代码格式:```xxx```. 1.如果已知信息包含的链接、表格、代码块等特殊markdown标签格式的信息,确保在答案中包含原文这链接、表格和代码标签,不要丢弃不要修改,如:链接格式:[xxx](xxx), 表格格式:|xxx|xxx|xxx|, 代码格式:```xxx```.
2.如果无法从提供的内容中获取答案, 请说: "知识库中提供的内容不足以回答此问题" 禁止胡乱编造. 2.不要在答案中包含图片.
3.回答的时候最好按照1.2.3.点进行总结, 并以markdwon格式显示. 3.如果无法从提供的内容中获取答案, 请说: "知识库中提供的内容不足以回答此问题" 禁止胡乱编造.
4.回答的时候最好按照1.2.3.点进行总结, 并以markdwon格式显示.
已知内容: 已知内容:
{context} {context}
问题: 问题:
{question},请使用和用户相同的语言进行回答. {question},请使用和用户相同的语言进行回答..
""" """
_DEFAULT_TEMPLATE_EN = """ Based on the known information below, provide users with professional and concise answers to their questions. _DEFAULT_TEMPLATE_EN = """ 基于以下给出的已知信息, 准守规范约束,专业、简要回答用户的问题.
constraints: 规范约束:
1.Ensure to include original markdown formatting elements such as images, links, tables, or code blocks without alteration in the response if they are present in the provided information. 1.如果已知信息包含的链接、表格、代码块等特殊markdown标签格式的信息,确保在答案中包含原文这链接、表格和代码标签,不要丢弃不要修改,如:链接格式:[xxx](xxx), 表格格式:|xxx|xxx|xxx|, 代码格式:```xxx```.
For example, image format should be ![image.png](xxx), link format [xxx](xxx), table format should be represented with |xxx|xxx|xxx|, and code format with xxx. 2.不要在答案中包含图片.
2.If the information available in the knowledge base is insufficient to answer the question, state clearly: "The content provided in the knowledge base is not enough to answer this question," and avoid making up answers. 3.如果无法从提供的内容中获取答案, 请说: "知识库中提供的内容不足以回答此问题" 禁止胡乱编造.
3.When responding, it is best to summarize the points in the order of 1, 2, 3, And displayed in markdwon format. 4.回答的时候最好按照1.2.3.点进行总结, 并以markdwon格式显示.
known information: 已知内容:
{context} {context}
question: 问题:
{question},when answering, use the same language as the "user". {question},请使用和用户相同的语言进行回答..
""" """
_DEFAULT_TEMPLATE = ( _DEFAULT_TEMPLATE = (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment