@@ -310,7 +310,6 @@ def prepare_model_args(request_body, request_headers):
310310 "template_system_message" : app_settings .azure_openai .template_system_message
311311 })
312312
313-
314313 model_args_clean = copy .deepcopy (model_args )
315314 if model_args_clean .get ("extra_body" ):
316315 secret_params = [
@@ -356,7 +355,6 @@ async def send_chat_request(request_body, request_headers):
356355 for message in messages :
357356 if message .get ("role" ) != "tool" :
358357 filtered_messages .append (message )
359-
360358 track_event_if_configured ("MessagesFiltered" , {
361359 "original_count" : len (messages ),
362360 "filtered_count" : len (filtered_messages )
@@ -410,7 +408,7 @@ async def generate():
410408 completionChunk , history_metadata , apim_request_id
411409 )
412410 track_event_if_configured ("StreamChatRequestInitialized" , {
413- "apim_request_id" : apim_request_id
411+ "apim_request_id" : apim_request_id
414412 })
415413
416414 return generate ()
@@ -753,8 +751,8 @@ async def list_conversations():
753751 cosmos_conversation_client = init_cosmosdb_client ()
754752 if not cosmos_conversation_client :
755753 track_event_if_configured ("CosmosDBNotConfigured" , {
756- "user_id" : user_id ,
757- "error" : "CosmosDB is not configured or not working"
754+ "user_id" : user_id ,
755+ "error" : "CosmosDB is not configured or not working"
758756 })
759757 raise Exception ("CosmosDB is not configured or not working" )
760758
@@ -763,17 +761,17 @@ async def list_conversations():
763761 await cosmos_conversation_client .cosmosdb_client .close ()
764762 if not isinstance (conversations , list ):
765763 track_event_if_configured ("NoConversationsFound" , {
766- "user_id" : user_id ,
767- "status" : "No conversations found"
768- })
764+ "user_id" : user_id ,
765+ "status" : "No conversations found"
766+ })
769767 return jsonify ({"error" : f"No conversations for { user_id } were found" }), 404
770768
771769 # return the conversation ids
772770 track_event_if_configured ("ConversationsListed" , {
773- "user_id" : user_id ,
774- "conversation_count" : len (conversations ),
775- "status" : "success"
776- })
771+ "user_id" : user_id ,
772+ "conversation_count" : len (conversations ),
773+ "status" : "success"
774+ })
777775 return jsonify (conversations ), 200
778776
779777
@@ -797,9 +795,9 @@ async def get_conversation():
797795 cosmos_conversation_client = init_cosmosdb_client ()
798796 if not cosmos_conversation_client :
799797 track_event_if_configured ("CosmosDBNotConfigured" , {
800- "user_id" : user_id ,
801- "error" : "CosmosDB is not configured or not working"
802- })
798+ "user_id" : user_id ,
799+ "error" : "CosmosDB is not configured or not working"
800+ })
803801 raise Exception ("CosmosDB is not configured or not working" )
804802
805803 # get the conversation object and the related messages from cosmos
@@ -809,10 +807,10 @@ async def get_conversation():
809807 # return the conversation id and the messages in the bot frontend format
810808 if not conversation :
811809 track_event_if_configured ("ConversationNotFound" , {
812- "user_id" : user_id ,
813- "conversation_id" : conversation_id ,
814- "error" : "Conversation not found or access denied"
815- })
810+ "user_id" : user_id ,
811+ "conversation_id" : conversation_id ,
812+ "error" : "Conversation not found or access denied"
813+ })
816814 return (
817815 jsonify (
818816 {
@@ -843,11 +841,11 @@ async def get_conversation():
843841 ]
844842
845843 track_event_if_configured ("ConversationRead" , {
846- "user_id" : user_id ,
847- "conversation_id" : conversation_id ,
848- "message_count" : len (messages ),
849- "status" : "success"
850- })
844+ "user_id" : user_id ,
845+ "conversation_id" : conversation_id ,
846+ "message_count" : len (messages ),
847+ "status" : "success"
848+ })
851849 await cosmos_conversation_client .cosmosdb_client .close ()
852850 return jsonify ({"conversation_id" : conversation_id , "messages" : messages }), 200
853851
0 commit comments