1919from application .serializers .chat_serializers import ChatSerializers , ChatRecordSerializer
2020from application .swagger_api .chat_api import ChatApi , VoteApi , ChatRecordApi , ImproveApi , ChatRecordImproveApi , \
2121 ChatClientHistoryApi , OpenAIChatApi
22+ from application .views import get_application_operation_object
2223from common .auth import TokenAuth , has_permissions , OpenAIKeyAuth
2324from common .constants .authentication_type import AuthenticationType
2425from common .constants .permission_constants import Permission , Group , Operate , \
@@ -178,7 +179,8 @@ class Operate(APIView):
178179 dynamic_tag = keywords .get ('application_id' ))],
179180 compare = CompareConstants .AND ),
180181 compare = CompareConstants .AND )
181- @log (menu = 'Application/Conversation Log' , operate = "Delete a conversation" )
182+ @log (menu = 'Application/Conversation Log' , operate = "Delete a conversation" ,
183+ get_operation_object = lambda r , k : get_application_operation_object (k .get ('application_id' )))
182184 def delete (self , request : Request , application_id : str , chat_id : str ):
183185 return result .success (
184186 ChatSerializers .Operate (
@@ -201,7 +203,6 @@ class ClientChatHistoryPage(APIView):
201203 [lambda r , keywords : Permission (group = Group .APPLICATION , operate = Operate .USE ,
202204 dynamic_tag = keywords .get ('application_id' ))])
203205 )
204- @log (menu = 'Application/Conversation Log' , operate = "Get client conversation list by paging" )
205206 def get (self , request : Request , application_id : str , current_page : int , page_size : int ):
206207 return result .success (ChatSerializers .ClientChatHistory (
207208 data = {'client_id' : request .auth .client_id , 'application_id' : application_id }).page (
@@ -221,7 +222,8 @@ class Operate(APIView):
221222 dynamic_tag = keywords .get ('application_id' ))],
222223 compare = CompareConstants .AND ),
223224 compare = CompareConstants .AND )
224- @log (menu = 'Application/Conversation Log' , operate = "Client deletes conversation" )
225+ @log (menu = 'Application/Conversation Log' , operate = "Client deletes conversation" ,
226+ get_operation_object = lambda r , k : get_application_operation_object (k .get ('application_id' )))
225227 def delete (self , request : Request , application_id : str , chat_id : str ):
226228 return result .success (
227229 ChatSerializers .Operate (
@@ -239,7 +241,8 @@ def delete(self, request: Request, application_id: str, chat_id: str):
239241 dynamic_tag = keywords .get ('application_id' ))],
240242 compare = CompareConstants .AND ),
241243 compare = CompareConstants .AND )
242- @log (menu = 'Application/Conversation Log' , operate = "Client modifies dialogue summary" )
244+ @log (menu = 'Application/Conversation Log' , operate = "Client modifies dialogue summary" ,
245+ get_operation_object = lambda r , k : get_application_operation_object (k .get ('application_id' )))
243246 def put (self , request : Request , application_id : str , chat_id : str ):
244247 return result .success (
245248 ChatSerializers .Operate (
@@ -261,7 +264,6 @@ class Page(APIView):
261264 [lambda r , keywords : Permission (group = Group .APPLICATION , operate = Operate .USE ,
262265 dynamic_tag = keywords .get ('application_id' ))])
263266 )
264- @log (menu = 'Application/Conversation Log' , operate = "Get the conversation list by page" )
265267 def get (self , request : Request , application_id : str , current_page : int , page_size : int ):
266268 return result .success (ChatSerializers .Query (
267269 data = {** query_params_to_single_dict (request .query_params ), 'application_id' : application_id ,
@@ -287,7 +289,6 @@ class Operate(APIView):
287289 [lambda r , keywords : Permission (group = Group .APPLICATION , operate = Operate .USE ,
288290 dynamic_tag = keywords .get ('application_id' ))])
289291 )
290- @log (menu = 'Application/Conversation Log' , operate = "Get conversation record details" )
291292 def get (self , request : Request , application_id : str , chat_id : str , chat_record_id : str ):
292293 return result .success (ChatRecordSerializer .Operate (
293294 data = {'application_id' : application_id ,
@@ -306,7 +307,6 @@ def get(self, request: Request, application_id: str, chat_id: str, chat_record_i
306307 [lambda r , keywords : Permission (group = Group .APPLICATION , operate = Operate .USE ,
307308 dynamic_tag = keywords .get ('application_id' ))])
308309 )
309- @log (menu = 'Application/Conversation Log' , operate = "Get a list of conversation records" )
310310 def get (self , request : Request , application_id : str , chat_id : str ):
311311 return result .success (ChatRecordSerializer .Query (
312312 data = {'application_id' : application_id ,
@@ -328,7 +328,6 @@ class Page(APIView):
328328 [lambda r , keywords : Permission (group = Group .APPLICATION , operate = Operate .USE ,
329329 dynamic_tag = keywords .get ('application_id' ))])
330330 )
331- @log (menu = 'Application/Conversation Log' , operate = "Get the conversation history list by page" )
332331 def get (self , request : Request , application_id : str , chat_id : str , current_page : int , page_size : int ):
333332 return result .success (ChatRecordSerializer .Query (
334333 data = {'application_id' : application_id ,
@@ -352,7 +351,8 @@ class Vote(APIView):
352351 [lambda r , keywords : Permission (group = Group .APPLICATION , operate = Operate .USE ,
353352 dynamic_tag = keywords .get ('application_id' ))])
354353 )
355- @log (menu = 'Application/Conversation Log' , operate = "Like, Dislike" )
354+ @log (menu = 'Application/Conversation Log' , operate = "Like, Dislike" ,
355+ get_operation_object = lambda r , k : get_application_operation_object (k .get ('application_id' )))
356356 def put (self , request : Request , application_id : str , chat_id : str , chat_record_id : str ):
357357 return result .success (ChatRecordSerializer .Vote (
358358 data = {'vote_status' : request .data .get ('vote_status' ), 'chat_id' : chat_id ,
@@ -373,7 +373,6 @@ class ChatRecordImprove(APIView):
373373 [lambda r , keywords : Permission (group = Group .APPLICATION , operate = Operate .USE ,
374374 dynamic_tag = keywords .get ('application_id' ))]
375375 ))
376- @log (menu = 'Application/Conversation Log' , operate = "Get the list of marked paragraphs" )
377376 def get (self , request : Request , application_id : str , chat_id : str , chat_record_id : str ):
378377 return result .success (ChatRecordSerializer .ChatRecordImprove (
379378 data = {'chat_id' : chat_id , 'chat_record_id' : chat_record_id }).get ())
@@ -401,7 +400,8 @@ class Improve(APIView):
401400 'dataset_id' ))],
402401 compare = CompareConstants .AND
403402 ), compare = CompareConstants .AND )
404- @log (menu = 'Application/Conversation Log' , operate = "Annotation" )
403+ @log (menu = 'Application/Conversation Log' , operate = "Annotation" ,
404+ get_operation_object = lambda r , k : get_application_operation_object (k .get ('application_id' )))
405405 def put (self , request : Request , application_id : str , chat_id : str , chat_record_id : str , dataset_id : str ,
406406 document_id : str ):
407407 return result .success (ChatRecordSerializer .Improve (
@@ -427,7 +427,8 @@ def put(self, request: Request, application_id: str, chat_id: str, chat_record_i
427427 'dataset_id' ))],
428428 compare = CompareConstants .AND
429429 ), compare = CompareConstants .AND )
430- @log (menu = 'Application/Conversation Log' , operate = "Add to Knowledge Base" )
430+ @log (menu = 'Application/Conversation Log' , operate = "Add to Knowledge Base" ,
431+ get_operation_object = lambda r , k : get_application_operation_object (k .get ('application_id' )))
431432 def post (self , request : Request , application_id : str , dataset_id : str ):
432433 return result .success (ChatRecordSerializer .PostImprove ().post_improve (request .data ))
433434
@@ -453,7 +454,8 @@ class Operate(APIView):
453454 'dataset_id' ))],
454455 compare = CompareConstants .AND
455456 ), compare = CompareConstants .AND )
456- @log (menu = 'Application/Conversation Log' , operate = "Delete a Annotation" )
457+ @log (menu = 'Application/Conversation Log' , operate = "Delete a Annotation" ,
458+ get_operation_object = lambda r , k : get_application_operation_object (k .get ('application_id' )))
457459 def delete (self , request : Request , application_id : str , chat_id : str , chat_record_id : str ,
458460 dataset_id : str ,
459461 document_id : str , paragraph_id : str ):
0 commit comments