19
19
from application .serializers .chat_serializers import ChatSerializers , ChatRecordSerializer
20
20
from application .swagger_api .chat_api import ChatApi , VoteApi , ChatRecordApi , ImproveApi , ChatRecordImproveApi , \
21
21
ChatClientHistoryApi , OpenAIChatApi
22
+ from application .views import get_application_operation_object
22
23
from common .auth import TokenAuth , has_permissions , OpenAIKeyAuth
23
24
from common .constants .authentication_type import AuthenticationType
24
25
from common .constants .permission_constants import Permission , Group , Operate , \
@@ -178,7 +179,8 @@ class Operate(APIView):
178
179
dynamic_tag = keywords .get ('application_id' ))],
179
180
compare = CompareConstants .AND ),
180
181
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' )))
182
184
def delete (self , request : Request , application_id : str , chat_id : str ):
183
185
return result .success (
184
186
ChatSerializers .Operate (
@@ -201,7 +203,6 @@ class ClientChatHistoryPage(APIView):
201
203
[lambda r , keywords : Permission (group = Group .APPLICATION , operate = Operate .USE ,
202
204
dynamic_tag = keywords .get ('application_id' ))])
203
205
)
204
- @log (menu = 'Application/Conversation Log' , operate = "Get client conversation list by paging" )
205
206
def get (self , request : Request , application_id : str , current_page : int , page_size : int ):
206
207
return result .success (ChatSerializers .ClientChatHistory (
207
208
data = {'client_id' : request .auth .client_id , 'application_id' : application_id }).page (
@@ -221,7 +222,8 @@ class Operate(APIView):
221
222
dynamic_tag = keywords .get ('application_id' ))],
222
223
compare = CompareConstants .AND ),
223
224
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' )))
225
227
def delete (self , request : Request , application_id : str , chat_id : str ):
226
228
return result .success (
227
229
ChatSerializers .Operate (
@@ -239,7 +241,8 @@ def delete(self, request: Request, application_id: str, chat_id: str):
239
241
dynamic_tag = keywords .get ('application_id' ))],
240
242
compare = CompareConstants .AND ),
241
243
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' )))
243
246
def put (self , request : Request , application_id : str , chat_id : str ):
244
247
return result .success (
245
248
ChatSerializers .Operate (
@@ -261,7 +264,6 @@ class Page(APIView):
261
264
[lambda r , keywords : Permission (group = Group .APPLICATION , operate = Operate .USE ,
262
265
dynamic_tag = keywords .get ('application_id' ))])
263
266
)
264
- @log (menu = 'Application/Conversation Log' , operate = "Get the conversation list by page" )
265
267
def get (self , request : Request , application_id : str , current_page : int , page_size : int ):
266
268
return result .success (ChatSerializers .Query (
267
269
data = {** query_params_to_single_dict (request .query_params ), 'application_id' : application_id ,
@@ -287,7 +289,6 @@ class Operate(APIView):
287
289
[lambda r , keywords : Permission (group = Group .APPLICATION , operate = Operate .USE ,
288
290
dynamic_tag = keywords .get ('application_id' ))])
289
291
)
290
- @log (menu = 'Application/Conversation Log' , operate = "Get conversation record details" )
291
292
def get (self , request : Request , application_id : str , chat_id : str , chat_record_id : str ):
292
293
return result .success (ChatRecordSerializer .Operate (
293
294
data = {'application_id' : application_id ,
@@ -306,7 +307,6 @@ def get(self, request: Request, application_id: str, chat_id: str, chat_record_i
306
307
[lambda r , keywords : Permission (group = Group .APPLICATION , operate = Operate .USE ,
307
308
dynamic_tag = keywords .get ('application_id' ))])
308
309
)
309
- @log (menu = 'Application/Conversation Log' , operate = "Get a list of conversation records" )
310
310
def get (self , request : Request , application_id : str , chat_id : str ):
311
311
return result .success (ChatRecordSerializer .Query (
312
312
data = {'application_id' : application_id ,
@@ -328,7 +328,6 @@ class Page(APIView):
328
328
[lambda r , keywords : Permission (group = Group .APPLICATION , operate = Operate .USE ,
329
329
dynamic_tag = keywords .get ('application_id' ))])
330
330
)
331
- @log (menu = 'Application/Conversation Log' , operate = "Get the conversation history list by page" )
332
331
def get (self , request : Request , application_id : str , chat_id : str , current_page : int , page_size : int ):
333
332
return result .success (ChatRecordSerializer .Query (
334
333
data = {'application_id' : application_id ,
@@ -352,7 +351,8 @@ class Vote(APIView):
352
351
[lambda r , keywords : Permission (group = Group .APPLICATION , operate = Operate .USE ,
353
352
dynamic_tag = keywords .get ('application_id' ))])
354
353
)
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' )))
356
356
def put (self , request : Request , application_id : str , chat_id : str , chat_record_id : str ):
357
357
return result .success (ChatRecordSerializer .Vote (
358
358
data = {'vote_status' : request .data .get ('vote_status' ), 'chat_id' : chat_id ,
@@ -373,7 +373,6 @@ class ChatRecordImprove(APIView):
373
373
[lambda r , keywords : Permission (group = Group .APPLICATION , operate = Operate .USE ,
374
374
dynamic_tag = keywords .get ('application_id' ))]
375
375
))
376
- @log (menu = 'Application/Conversation Log' , operate = "Get the list of marked paragraphs" )
377
376
def get (self , request : Request , application_id : str , chat_id : str , chat_record_id : str ):
378
377
return result .success (ChatRecordSerializer .ChatRecordImprove (
379
378
data = {'chat_id' : chat_id , 'chat_record_id' : chat_record_id }).get ())
@@ -401,7 +400,8 @@ class Improve(APIView):
401
400
'dataset_id' ))],
402
401
compare = CompareConstants .AND
403
402
), 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' )))
405
405
def put (self , request : Request , application_id : str , chat_id : str , chat_record_id : str , dataset_id : str ,
406
406
document_id : str ):
407
407
return result .success (ChatRecordSerializer .Improve (
@@ -427,7 +427,8 @@ def put(self, request: Request, application_id: str, chat_id: str, chat_record_i
427
427
'dataset_id' ))],
428
428
compare = CompareConstants .AND
429
429
), 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' )))
431
432
def post (self , request : Request , application_id : str , dataset_id : str ):
432
433
return result .success (ChatRecordSerializer .PostImprove ().post_improve (request .data ))
433
434
@@ -453,7 +454,8 @@ class Operate(APIView):
453
454
'dataset_id' ))],
454
455
compare = CompareConstants .AND
455
456
), 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' )))
457
459
def delete (self , request : Request , application_id : str , chat_id : str , chat_record_id : str ,
458
460
dataset_id : str ,
459
461
document_id : str , paragraph_id : str ):
0 commit comments