Skip to content

Commit 1249abf

Browse files
fix: fixed config save issue (#1421)
1 parent 69d0e98 commit 1249abf

File tree

1 file changed

+72
-86
lines changed

1 file changed

+72
-86
lines changed

code/backend/pages/04_Configuration.py

Lines changed: 72 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -391,96 +391,82 @@ def validate_documents():
391391
st.checkbox("Log tokens", key="log_tokens")
392392

393393
if st.form_submit_button("Save configuration"):
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."
394+
document_processors = []
395+
if env_helper.AZURE_SEARCH_USE_INTEGRATED_VECTORIZATION is False:
396+
valid = all(
397+
row["document_type"]
398+
and row["chunking_strategy"]
399+
and row["loading_strategy"]
400+
for row in edited_document_processors
404401
)
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-
],
402+
if not valid:
403+
st.error(
404+
"Please ensure all fields are selected and not left blank in Document processing configuration."
405+
)
406+
document_processors = list(
407+
map(
408+
lambda x: {
409+
"document_type": x["document_type"],
410+
"chunking": {
411+
"strategy": x["chunking_strategy"],
412+
"size": x["chunking_size"],
413+
"overlap": x["chunking_overlap"],
422414
},
423-
edited_document_processors,
424-
)
415+
"loading": {
416+
"strategy": x["loading_strategy"],
417+
},
418+
"use_advanced_image_processing": x[
419+
"use_advanced_image_processing"
420+
],
421+
},
422+
edited_document_processors,
425423
)
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."
483424
)
425+
current_config = {
426+
"prompts": {
427+
"condense_question_prompt": "", # st.session_state['condense_question_prompt'],
428+
"answering_system_prompt": st.session_state[
429+
"answering_system_prompt"
430+
],
431+
"answering_user_prompt": st.session_state["answering_user_prompt"],
432+
"use_on_your_data_format": st.session_state[
433+
"use_on_your_data_format"
434+
],
435+
"post_answering_prompt": st.session_state["post_answering_prompt"],
436+
"enable_post_answering_prompt": st.session_state[
437+
"enable_post_answering_prompt"
438+
],
439+
"enable_content_safety": st.session_state["enable_content_safety"],
440+
"ai_assistant_type": st.session_state["ai_assistant_type"],
441+
"conversational_flow": st.session_state["conversational_flow"],
442+
},
443+
"messages": {
444+
"post_answering_filter": st.session_state[
445+
"post_answering_filter_message"
446+
]
447+
},
448+
"example": {
449+
"documents": st.session_state["example_documents"],
450+
"user_question": st.session_state["example_user_question"],
451+
"answer": st.session_state["example_answer"],
452+
},
453+
"document_processors": document_processors,
454+
"logging": {
455+
"log_user_interactions": st.session_state["log_user_interactions"],
456+
"log_tokens": st.session_state["log_tokens"],
457+
},
458+
"orchestrator": {"strategy": st.session_state["orchestrator_strategy"]},
459+
"integrated_vectorization_config": (
460+
integrated_vectorization_config
461+
if env_helper.AZURE_SEARCH_USE_INTEGRATED_VECTORIZATION
462+
else None
463+
),
464+
"enable_chat_history": st.session_state["enable_chat_history"],
465+
}
466+
ConfigHelper.save_config_as_active(current_config)
467+
st.success(
468+
"Configuration saved successfully! Please restart the chat service for these changes to take effect."
469+
)
484470

485471
with st.popover(":red[Reset configuration to defaults]"):
486472

0 commit comments

Comments
 (0)