@@ -188,9 +188,7 @@ async def ask(auth_claims: dict[str, Any]):
188
188
try :
189
189
approach : Approach = cast (Approach , current_app .config [CONFIG_ASK_APPROACH ])
190
190
r = await approach .run (
191
- request_json ["messages" ],
192
- context = context ,
193
- session_state = request_json .get ("session_state" ),
191
+ request_json ["messages" ], context = context , session_state = request_json .get ("session_state" )
194
192
)
195
193
return jsonify (r )
196
194
except Exception as error :
@@ -331,10 +329,7 @@ async def speech():
331
329
+ "#"
332
330
+ current_app .config [CONFIG_SPEECH_SERVICE_TOKEN ].token
333
331
)
334
- speech_config = SpeechConfig (
335
- auth_token = auth_token ,
336
- region = current_app .config [CONFIG_SPEECH_SERVICE_LOCATION ],
337
- )
332
+ speech_config = SpeechConfig (auth_token = auth_token , region = current_app .config [CONFIG_SPEECH_SERVICE_LOCATION ])
338
333
speech_config .speech_synthesis_voice_name = current_app .config [CONFIG_SPEECH_SERVICE_VOICE ]
339
334
speech_config .speech_synthesis_output_format = SpeechSynthesisOutputFormat .Audio16Khz32KBitRateMonoMp3
340
335
synthesizer = SpeechSynthesizer (speech_config = speech_config , audio_config = None )
@@ -344,9 +339,7 @@ async def speech():
344
339
elif result .reason == ResultReason .Canceled :
345
340
cancellation_details = result .cancellation_details
346
341
current_app .logger .error (
347
- "Speech synthesis canceled: %s %s" ,
348
- cancellation_details .reason ,
349
- cancellation_details .error_details ,
342
+ "Speech synthesis canceled: %s %s" , cancellation_details .reason , cancellation_details .error_details
350
343
)
351
344
raise Exception ("Speech synthesis canceled. Check logs for details." )
352
345
else :
@@ -370,22 +363,11 @@ async def upload(auth_claims: dict[str, Any]):
370
363
adls_manager : AdlsBlobManager = current_app .config [CONFIG_USER_BLOB_MANAGER ]
371
364
file_url = await adls_manager .upload_blob (file , file .filename , user_oid )
372
365
ingester : UploadUserFileStrategy = current_app .config [CONFIG_INGESTER ]
373
- await ingester .add_file (
374
- File (content = file , url = file_url , acls = {"oids" : [user_oid ]}),
375
- user_oid = user_oid ,
376
- )
366
+ await ingester .add_file (File (content = file , url = file_url , acls = {"oids" : [user_oid ]}), user_oid = user_oid )
377
367
return jsonify ({"message" : "File uploaded successfully" }), 200
378
368
except Exception as error :
379
369
current_app .logger .error ("Error uploading file: %s" , error )
380
- return (
381
- jsonify (
382
- {
383
- "message" : "Error uploading file, check server logs for details." ,
384
- "status" : "failed" ,
385
- }
386
- ),
387
- 500 ,
388
- )
370
+ return jsonify ({"message" : "Error uploading file, check server logs for details." , "status" : "failed" }), 500
389
371
390
372
391
373
@bp .post ("/delete_uploaded" )
@@ -505,17 +487,15 @@ async def setup_clients():
505
487
# ManagedIdentityCredential should use AZURE_CLIENT_ID if set in env, but its not working for some reason,
506
488
# so we explicitly pass it in as the client ID here. This is necessary for user-assigned managed identities.
507
489
current_app .logger .info (
508
- "Setting up Azure credential using ManagedIdentityCredential with client_id %s" ,
509
- AZURE_CLIENT_ID ,
490
+ "Setting up Azure credential using ManagedIdentityCredential with client_id %s" , AZURE_CLIENT_ID
510
491
)
511
492
azure_credential = ManagedIdentityCredential (client_id = AZURE_CLIENT_ID )
512
493
else :
513
494
current_app .logger .info ("Setting up Azure credential using ManagedIdentityCredential" )
514
495
azure_credential = ManagedIdentityCredential ()
515
496
elif AZURE_TENANT_ID :
516
497
current_app .logger .info (
517
- "Setting up Azure credential using AzureDeveloperCliCredential with tenant_id %s" ,
518
- AZURE_TENANT_ID ,
498
+ "Setting up Azure credential using AzureDeveloperCliCredential with tenant_id %s" , AZURE_TENANT_ID
519
499
)
520
500
azure_credential = AzureDeveloperCliCredential (tenant_id = AZURE_TENANT_ID , process_timeout = 60 )
521
501
else :
@@ -535,9 +515,7 @@ async def setup_clients():
535
515
credential = azure_credential ,
536
516
)
537
517
agent_client = KnowledgeAgentRetrievalClient (
538
- endpoint = AZURE_SEARCH_ENDPOINT ,
539
- agent_name = AZURE_SEARCH_AGENT ,
540
- credential = azure_credential ,
518
+ endpoint = AZURE_SEARCH_ENDPOINT , agent_name = AZURE_SEARCH_AGENT , credential = azure_credential
541
519
)
542
520
543
521
# Set up the global blob storage manager (used for global content/images, but not user uploads)
@@ -622,9 +600,7 @@ async def setup_clients():
622
600
openai_deployment = AZURE_OPENAI_CHATGPT_DEPLOYMENT if OPENAI_HOST == OpenAIHost .AZURE else None ,
623
601
)
624
602
search_info = await setup_search_info (
625
- search_service = AZURE_SEARCH_SERVICE ,
626
- index_name = AZURE_SEARCH_INDEX ,
627
- azure_credential = azure_credential ,
603
+ search_service = AZURE_SEARCH_SERVICE , index_name = AZURE_SEARCH_INDEX , azure_credential = azure_credential
628
604
)
629
605
text_embeddings_service = setup_embeddings_service (
630
606
azure_credential = azure_credential ,
0 commit comments