Skip to content

Commit 1ed3f43

Browse files
fix: Admin configuration issue fix (#1676)
1 parent c13b4e3 commit 1ed3f43

File tree

1 file changed

+50
-45
lines changed

1 file changed

+50
-45
lines changed

code/backend/pages/04_Configuration.py

Lines changed: 50 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -410,17 +410,21 @@ def validate_documents():
410410

411411
if st.form_submit_button("Save configuration"):
412412
document_processors = []
413+
should_save = True
413414
if env_helper.AZURE_SEARCH_USE_INTEGRATED_VECTORIZATION is False:
414415
valid = all(
415416
row["document_type"]
416417
and row["chunking_strategy"]
418+
and row["chunking_size"]
419+
and row["chunking_overlap"]
417420
and row["loading_strategy"]
418421
for row in edited_document_processors
419422
)
420423
if not valid:
421424
st.error(
422425
"Please ensure all fields are selected and not left blank in Document processing configuration."
423426
)
427+
should_save = False
424428
document_processors = list(
425429
map(
426430
lambda x: {
@@ -440,51 +444,52 @@ def validate_documents():
440444
edited_document_processors,
441445
)
442446
)
443-
current_config = {
444-
"prompts": {
445-
"condense_question_prompt": "", # st.session_state['condense_question_prompt'],
446-
"answering_system_prompt": st.session_state[
447-
"answering_system_prompt"
448-
],
449-
"answering_user_prompt": st.session_state["answering_user_prompt"],
450-
"use_on_your_data_format": st.session_state[
451-
"use_on_your_data_format"
452-
],
453-
"post_answering_prompt": st.session_state["post_answering_prompt"],
454-
"enable_post_answering_prompt": st.session_state[
455-
"enable_post_answering_prompt"
456-
],
457-
"enable_content_safety": st.session_state["enable_content_safety"],
458-
"ai_assistant_type": st.session_state["ai_assistant_type"],
459-
"conversational_flow": st.session_state["conversational_flow"],
460-
},
461-
"messages": {
462-
"post_answering_filter": st.session_state[
463-
"post_answering_filter_message"
464-
]
465-
},
466-
"example": {
467-
"documents": st.session_state["example_documents"],
468-
"user_question": st.session_state["example_user_question"],
469-
"answer": st.session_state["example_answer"],
470-
},
471-
"document_processors": document_processors,
472-
"logging": {
473-
"log_user_interactions": st.session_state["log_user_interactions"],
474-
"log_tokens": st.session_state["log_tokens"],
475-
},
476-
"orchestrator": {"strategy": st.session_state["orchestrator_strategy"]},
477-
"integrated_vectorization_config": (
478-
integrated_vectorization_config
479-
if env_helper.AZURE_SEARCH_USE_INTEGRATED_VECTORIZATION
480-
else None
481-
),
482-
"enable_chat_history": st.session_state["enable_chat_history"],
483-
}
484-
ConfigHelper.save_config_as_active(current_config)
485-
st.success(
486-
"Configuration saved successfully! Please restart the chat service for these changes to take effect."
487-
)
447+
if should_save:
448+
current_config = {
449+
"prompts": {
450+
"condense_question_prompt": "", # st.session_state['condense_question_prompt'],
451+
"answering_system_prompt": st.session_state[
452+
"answering_system_prompt"
453+
],
454+
"answering_user_prompt": st.session_state["answering_user_prompt"],
455+
"use_on_your_data_format": st.session_state[
456+
"use_on_your_data_format"
457+
],
458+
"post_answering_prompt": st.session_state["post_answering_prompt"],
459+
"enable_post_answering_prompt": st.session_state[
460+
"enable_post_answering_prompt"
461+
],
462+
"enable_content_safety": st.session_state["enable_content_safety"],
463+
"ai_assistant_type": st.session_state["ai_assistant_type"],
464+
"conversational_flow": st.session_state["conversational_flow"],
465+
},
466+
"messages": {
467+
"post_answering_filter": st.session_state[
468+
"post_answering_filter_message"
469+
]
470+
},
471+
"example": {
472+
"documents": st.session_state["example_documents"],
473+
"user_question": st.session_state["example_user_question"],
474+
"answer": st.session_state["example_answer"],
475+
},
476+
"document_processors": document_processors,
477+
"logging": {
478+
"log_user_interactions": st.session_state["log_user_interactions"],
479+
"log_tokens": st.session_state["log_tokens"],
480+
},
481+
"orchestrator": {"strategy": st.session_state["orchestrator_strategy"]},
482+
"integrated_vectorization_config": (
483+
integrated_vectorization_config
484+
if env_helper.AZURE_SEARCH_USE_INTEGRATED_VECTORIZATION
485+
else None
486+
),
487+
"enable_chat_history": st.session_state["enable_chat_history"],
488+
}
489+
ConfigHelper.save_config_as_active(current_config)
490+
st.success(
491+
"Configuration saved successfully! Please restart the chat service for these changes to take effect."
492+
)
488493

489494
with st.popover(":red[Reset configuration to defaults]"):
490495

0 commit comments

Comments
 (0)