@@ -333,14 +333,14 @@ def validate_documents():
333333 lambda x : {
334334 "document_type" : x .document_type ,
335335 "chunking_strategy" : (
336- x .chunking .chunking_strategy .value if x .chunking else None
336+ x .chunking .chunking_strategy .value if x .chunking else "layout"
337337 ),
338338 "chunking_size" : x .chunking .chunk_size if x .chunking else None ,
339339 "chunking_overlap" : (
340340 x .chunking .chunk_overlap if x .chunking else None
341341 ),
342342 "loading_strategy" : (
343- x .loading .loading_strategy .value if x .loading else None
343+ x .loading .loading_strategy .value if x .loading else "layout"
344344 ),
345345 "use_advanced_image_processing" : x .use_advanced_image_processing ,
346346 },
@@ -391,74 +391,96 @@ def validate_documents():
391391 st .checkbox ("Log tokens" , key = "log_tokens" )
392392
393393 if st .form_submit_button ("Save configuration" ):
394- document_processors = (
395- list (
396- map (
397- lambda x : {
398- "document_type" : x ["document_type" ],
399- "chunking" : {
400- "strategy" : x ["chunking_strategy" ],
401- "size" : x ["chunking_size" ],
402- "overlap" : x ["chunking_overlap" ],
403- },
404- "loading" : {
405- "strategy" : x ["loading_strategy" ],
394+ valid = all (
395+ row ["document_type" ]
396+ and row ["chunking_strategy" ]
397+ and row ["loading_strategy" ]
398+ for row in edited_document_processors
399+ )
400+
401+ if not valid :
402+ st .error (
403+ "Please ensure all fields are selected and not left blank in Document processing configuration."
404+ )
405+ else :
406+ document_processors = (
407+ list (
408+ map (
409+ lambda x : {
410+ "document_type" : x ["document_type" ],
411+ "chunking" : {
412+ "strategy" : x ["chunking_strategy" ],
413+ "size" : x ["chunking_size" ],
414+ "overlap" : x ["chunking_overlap" ],
415+ },
416+ "loading" : {
417+ "strategy" : x ["loading_strategy" ],
418+ },
419+ "use_advanced_image_processing" : x [
420+ "use_advanced_image_processing"
421+ ],
406422 },
407- "use_advanced_image_processing" : x [
408- "use_advanced_image_processing"
409- ],
410- },
411- edited_document_processors ,
423+ edited_document_processors ,
424+ )
412425 )
426+ if env_helper .AZURE_SEARCH_USE_INTEGRATED_VECTORIZATION is False
427+ else []
428+ )
429+ current_config = {
430+ "prompts" : {
431+ "condense_question_prompt" : "" , # st.session_state['condense_question_prompt'],
432+ "answering_system_prompt" : st .session_state [
433+ "answering_system_prompt"
434+ ],
435+ "answering_user_prompt" : st .session_state [
436+ "answering_user_prompt"
437+ ],
438+ "use_on_your_data_format" : st .session_state [
439+ "use_on_your_data_format"
440+ ],
441+ "post_answering_prompt" : st .session_state [
442+ "post_answering_prompt"
443+ ],
444+ "enable_post_answering_prompt" : st .session_state [
445+ "enable_post_answering_prompt"
446+ ],
447+ "enable_content_safety" : st .session_state [
448+ "enable_content_safety"
449+ ],
450+ "ai_assistant_type" : st .session_state ["ai_assistant_type" ],
451+ "conversational_flow" : st .session_state ["conversational_flow" ],
452+ },
453+ "messages" : {
454+ "post_answering_filter" : st .session_state [
455+ "post_answering_filter_message"
456+ ]
457+ },
458+ "example" : {
459+ "documents" : st .session_state ["example_documents" ],
460+ "user_question" : st .session_state ["example_user_question" ],
461+ "answer" : st .session_state ["example_answer" ],
462+ },
463+ "document_processors" : document_processors ,
464+ "logging" : {
465+ "log_user_interactions" : st .session_state [
466+ "log_user_interactions"
467+ ],
468+ "log_tokens" : st .session_state ["log_tokens" ],
469+ },
470+ "orchestrator" : {
471+ "strategy" : st .session_state ["orchestrator_strategy" ]
472+ },
473+ "integrated_vectorization_config" : (
474+ integrated_vectorization_config
475+ if env_helper .AZURE_SEARCH_USE_INTEGRATED_VECTORIZATION
476+ else None
477+ ),
478+ "enable_chat_history" : st .session_state ["enable_chat_history" ],
479+ }
480+ ConfigHelper .save_config_as_active (current_config )
481+ st .success (
482+ "Configuration saved successfully! Please restart the chat service for these changes to take effect."
413483 )
414- if env_helper .AZURE_SEARCH_USE_INTEGRATED_VECTORIZATION is False
415- else []
416- )
417- current_config = {
418- "prompts" : {
419- "condense_question_prompt" : "" , # st.session_state['condense_question_prompt'],
420- "answering_system_prompt" : st .session_state [
421- "answering_system_prompt"
422- ],
423- "answering_user_prompt" : st .session_state ["answering_user_prompt" ],
424- "use_on_your_data_format" : st .session_state [
425- "use_on_your_data_format"
426- ],
427- "post_answering_prompt" : st .session_state ["post_answering_prompt" ],
428- "enable_post_answering_prompt" : st .session_state [
429- "enable_post_answering_prompt"
430- ],
431- "enable_content_safety" : st .session_state ["enable_content_safety" ],
432- "ai_assistant_type" : st .session_state ["ai_assistant_type" ],
433- "conversational_flow" : st .session_state ["conversational_flow" ],
434- },
435- "messages" : {
436- "post_answering_filter" : st .session_state [
437- "post_answering_filter_message"
438- ]
439- },
440- "example" : {
441- "documents" : st .session_state ["example_documents" ],
442- "user_question" : st .session_state ["example_user_question" ],
443- "answer" : st .session_state ["example_answer" ],
444- },
445- "document_processors" : document_processors ,
446- "logging" : {
447- "log_user_interactions" : st .session_state ["log_user_interactions" ],
448- "log_tokens" : st .session_state ["log_tokens" ],
449- },
450- "orchestrator" : {"strategy" : st .session_state ["orchestrator_strategy" ]},
451- "integrated_vectorization_config" : (
452- integrated_vectorization_config
453- if env_helper .AZURE_SEARCH_USE_INTEGRATED_VECTORIZATION
454- else None
455- ),
456- "enable_chat_history" : st .session_state ["enable_chat_history" ],
457- }
458- ConfigHelper .save_config_as_active (current_config )
459- st .success (
460- "Configuration saved successfully! Please restart the chat service for these changes to take effect."
461- )
462484
463485 with st .popover (":red[Reset configuration to defaults]" ):
464486
0 commit comments