1010from sqlalchemy import and_ , select
1111from starlette .responses import JSONResponse
1212
13- from apps .chat .curd .chat import delete_chat_with_user , get_chart_data_with_user , get_chat_predict_data_with_user , list_chats , get_chat_with_records , create_chat , rename_chat , \
13+ from 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 , \
1415 delete_chat , get_chat_chart_data , get_chat_predict_data , get_chat_with_records_with_data , get_chat_record_by_id , \
15- format_json_data , format_json_list_data , get_chart_config , list_recent_questions ,get_chat as get_chat_exec , rename_chat_with_user
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
1618from apps .chat .models .chat_model import CreateChat , ChatRecord , RenameChat , ChatQuestion , AxisObj , QuickCommand , \
1719 ChatInfo , Chat , ChatFinishStep
1820from apps .chat .task .llm import LLMService
@@ -69,6 +71,7 @@ def inner():
6971
7072 return await asyncio.to_thread(inner) """
7173
74+
7275@router .get ("/record/{chat_record_id}/data" , summary = f"{ PLACEHOLDER_PREFIX } get_chart_data" )
7376async def chat_record_data (session : SessionDep , current_user : CurrentUser , chat_record_id : int ):
7477 def inner ():
@@ -81,7 +84,8 @@ def inner():
8184@router .get ("/record/{chat_record_id}/predict_data" , summary = f"{ PLACEHOLDER_PREFIX } get_chart_predict_data" )
8285async def chat_predict_data (session : SessionDep , current_user : CurrentUser , chat_record_id : int ):
8386 def inner ():
84- data = get_chat_predict_data_with_user (chat_record_id = chat_record_id , session = session , current_user = current_user )
87+ data = get_chat_predict_data_with_user (chat_record_id = chat_record_id , session = session ,
88+ current_user = current_user )
8589 return format_json_list_data (data )
8690
8791 return await asyncio .to_thread (inner )
@@ -102,6 +106,7 @@ async def rename(session: SessionDep, chat: RenameChat):
102106 detail=str(e)
103107 ) """
104108
109+
105110@router .post ("/rename" , response_model = str , summary = f"{ PLACEHOLDER_PREFIX } rename_chat" )
106111@system_log (LogConfig (
107112 operation_type = OperationType .UPDATE ,
@@ -117,6 +122,7 @@ async def rename(session: SessionDep, current_user: CurrentUser, chat: RenameCha
117122 detail = str (e )
118123 )
119124
125+
120126""" @router.delete("/{chart_id}/{brief}", response_model=str, summary=f"{PLACEHOLDER_PREFIX}delete_chat")
121127@system_log(LogConfig(
122128 operation_type=OperationType.DELETE,
@@ -133,6 +139,7 @@ async def delete(session: SessionDep, chart_id: int, brief: str):
133139 detail=str(e)
134140 ) """
135141
142+
136143@router .delete ("/{chart_id}/{brief}" , response_model = str , summary = f"{ PLACEHOLDER_PREFIX } delete_chat" )
137144@system_log (LogConfig (
138145 operation_type = OperationType .DELETE ,
@@ -149,6 +156,7 @@ async def delete(session: SessionDep, current_user: CurrentUser, chart_id: int,
149156 detail = str (e )
150157 )
151158
159+
152160@router .post ("/start" , response_model = ChatInfo , summary = f"{ PLACEHOLDER_PREFIX } start_chat" )
153161@require_permissions (permission = SqlbotPermission (type = 'ds' , keyExpression = "create_chat_obj.datasource" ))
154162@system_log (LogConfig (
@@ -172,9 +180,11 @@ async def start_chat(session: SessionDep, current_user: CurrentUser, create_chat
172180 module = OperationModules .CHAT ,
173181 result_id_expr = "id"
174182))
175- async def start_chat (session : SessionDep , current_user : CurrentUser , current_assistant : CurrentAssistant , create_chat_obj : CreateChat = CreateChat (origin = 2 )):
183+ async def start_chat (session : SessionDep , current_user : CurrentUser , current_assistant : CurrentAssistant ,
184+ create_chat_obj : CreateChat = CreateChat (origin = 2 )):
176185 try :
177- return create_chat (session , current_user , create_chat_obj , create_chat_obj and create_chat_obj .datasource , current_assistant )
186+ return create_chat (session , current_user , create_chat_obj , create_chat_obj and create_chat_obj .datasource ,
187+ current_assistant )
178188 except Exception as e :
179189 raise HTTPException (
180190 status_code = 500 ,
@@ -213,7 +223,7 @@ def _err(_e: Exception):
213223
214224@router .get ("/recent_questions/{datasource_id}" , response_model = List [str ],
215225 summary = f"{ PLACEHOLDER_PREFIX } get_recommend_questions" )
216- #@require_permissions(permission=SqlbotPermission(type='ds', keyExpression="datasource_id"))
226+ # @require_permissions(permission=SqlbotPermission(type='ds', keyExpression="datasource_id"))
217227async def recommend_questions (session : SessionDep , current_user : CurrentUser ,
218228 datasource_id : int = Path (..., description = f"{ PLACEHOLDER_PREFIX } ds_id" )):
219229 return list_recent_questions (session = session , current_user = current_user , datasource_id = datasource_id )
@@ -442,8 +452,8 @@ def _err(_e: Exception):
442452
443453
444454@router .get ("/record/{chat_record_id}/excel/export/{chat_id}" , summary = f"{ PLACEHOLDER_PREFIX } export_chart_data" )
445- @system_log (LogConfig (operation_type = OperationType .EXPORT ,module = OperationModules .CHAT ,resource_id_expr = "chat_id" ,))
446- async def export_excel (session : SessionDep , current_user : CurrentUser , chat_record_id : int ,chat_id : int , trans : Trans ):
455+ @system_log (LogConfig (operation_type = OperationType .EXPORT , module = OperationModules .CHAT , resource_id_expr = "chat_id" , ))
456+ async def export_excel (session : SessionDep , current_user : CurrentUser , chat_record_id : int , chat_id : int , trans : Trans ):
447457 chat_record = session .get (ChatRecord , chat_record_id )
448458 if not chat_record :
449459 raise HTTPException (
0 commit comments