1111from starlette .responses import JSONResponse
1212
1313from apps .chat .curd .chat import delete_chat_with_user , get_chart_data_with_user , get_chat_predict_data_with_user , \
14- list_chats , get_chat_with_records , create_chat , rename_chat , \
15- delete_chat , get_chat_chart_data , get_chat_predict_data , get_chat_with_records_with_data , get_chat_record_by_id , \
16- format_json_data , format_json_list_data , get_chart_config , list_recent_questions , get_chat as get_chat_exec , \
17- rename_chat_with_user , get_chat_log_history , get_chart_data_with_user_live
14+ list_chats , get_chat_with_records , create_chat , get_chat_chart_data , get_chat_predict_data , \
15+ get_chat_with_records_with_data , get_chat_record_by_id , \
16+ format_json_data , format_json_list_data , get_chart_config , list_recent_questions , rename_chat_with_user , \
17+ get_chat_log_history , get_chart_data_with_user_live
1818from apps .chat .models .chat_model import CreateChat , ChatRecord , RenameChat , ChatQuestion , AxisObj , QuickCommand , \
19- ChatInfo , Chat , ChatFinishStep , ChatQuestionBase
19+ ChatInfo , Chat , ChatFinishStep , ChatQuestionBase , SimpleChat
2020from apps .chat .task .llm import LLMService
2121from apps .swagger .i18n import PLACEHOLDER_PREFIX
2222from apps .system .schemas .permission import SqlbotPermission , require_permissions
23+ from common .audit .models .log_model import OperationType , OperationModules
24+ from common .audit .schemas .logger_decorator import LogConfig , system_log
2325from common .core .deps import CurrentAssistant , SessionDep , CurrentUser , Trans
2426from common .utils .command_utils import parse_quick_command
2527from common .utils .data_format import DataFormat
26- from common .audit .models .log_model import OperationType , OperationModules
27- from common .audit .schemas .logger_decorator import LogConfig , system_log
2828
2929router = APIRouter (tags = ["Data Q&A" ], prefix = "/chat" )
3030
@@ -116,22 +116,6 @@ def inner():
116116 return await asyncio .to_thread (inner )
117117
118118
119- """ @router.post("/rename", response_model=str, summary=f"{PLACEHOLDER_PREFIX}rename_chat")
120- @system_log(LogConfig(
121- operation_type=OperationType.UPDATE,
122- module=OperationModules.CHAT,
123- resource_id_expr="chat.id"
124- ))
125- async def rename(session: SessionDep, chat: RenameChat):
126- try:
127- return rename_chat(session=session, rename_object=chat)
128- except Exception as e:
129- raise HTTPException(
130- status_code=500,
131- detail=str(e)
132- ) """
133-
134-
135119@router .post ("/rename" , response_model = str , summary = f"{ PLACEHOLDER_PREFIX } rename_chat" )
136120@system_log (LogConfig (
137121 operation_type = OperationType .UPDATE ,
@@ -148,31 +132,14 @@ async def rename(session: SessionDep, current_user: CurrentUser, chat: RenameCha
148132 )
149133
150134
151- """ @router.delete("/{chart_id}/{brief}", response_model=str, summary=f"{PLACEHOLDER_PREFIX}delete_chat")
152- @system_log(LogConfig(
153- operation_type=OperationType.DELETE,
154- module=OperationModules.CHAT,
155- resource_id_expr="chart_id",
156- remark_expr="brief"
157- ))
158- async def delete(session: SessionDep, chart_id: int, brief: str):
159- try:
160- return delete_chat(session=session, chart_id=chart_id)
161- except Exception as e:
162- raise HTTPException(
163- status_code=500,
164- detail=str(e)
165- ) """
166-
167-
168- @router .delete ("/{chart_id}/{brief}" , response_model = str , summary = f"{ PLACEHOLDER_PREFIX } delete_chat" )
135+ @router .delete ("/{chart_id}" , response_model = str , summary = f"{ PLACEHOLDER_PREFIX } delete_chat" )
169136@system_log (LogConfig (
170137 operation_type = OperationType .DELETE ,
171138 module = OperationModules .CHAT ,
172139 resource_id_expr = "chart_id" ,
173- remark_expr = "brief"
140+ remark_expr = "chat. brief"
174141))
175- async def delete (session : SessionDep , current_user : CurrentUser , chart_id : int , brief : str ):
142+ async def delete (session : SessionDep , current_user : CurrentUser , chart_id : int , chat : SimpleChat ):
176143 try :
177144 return delete_chat_with_user (session = session , current_user = current_user , chart_id = chart_id )
178145 except Exception as e :
0 commit comments