Skip to content

Commit 21ffcd8

Browse files
fix: Configuration tab "Reset configuration to Defaults" confuses the user whether it is button or dropdown. (#1196)
1 parent 8655ef6 commit 21ffcd8

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

code/backend/pages/04_Configuration.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from batch.utilities.helpers.config.config_helper import ConfigHelper
99
from azure.core.exceptions import ResourceNotFoundError
1010
from batch.utilities.helpers.config.assistant_strategy import AssistantStrategy
11+
1112
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
1213
env_helper: EnvHelper = EnvHelper()
1314

@@ -95,10 +96,14 @@ def validate_answering_user_prompt():
9596
def config_legal_assistant_prompt():
9697
if st.session_state["ai_assistant_type"] == AssistantStrategy.LEGAL_ASSISTANT.value:
9798
st.success("Legal Assistant Prompt")
98-
st.session_state["answering_user_prompt"] = ConfigHelper.get_default_legal_assistant()
99+
st.session_state["answering_user_prompt"] = (
100+
ConfigHelper.get_default_legal_assistant()
101+
)
99102
else:
100103
st.success("Default Assistant Prompt")
101-
st.session_state["answering_user_prompt"] = ConfigHelper.get_default_assistant_prompt()
104+
st.session_state["answering_user_prompt"] = (
105+
ConfigHelper.get_default_assistant_prompt()
106+
)
102107

103108

104109
def validate_post_answering_prompt():
@@ -374,7 +379,7 @@ def validate_documents():
374379
"enable_post_answering_prompt"
375380
],
376381
"enable_content_safety": st.session_state["enable_content_safety"],
377-
"ai_assistant_type": st.session_state["ai_assistant_type"]
382+
"ai_assistant_type": st.session_state["ai_assistant_type"],
378383
},
379384
"messages": {
380385
"post_answering_filter": st.session_state[
@@ -404,9 +409,16 @@ def validate_documents():
404409
)
405410

406411
with st.popover(":red[Reset configuration to defaults]"):
412+
413+
# Close button with a custom class
414+
if st.button("X", key="close_popup", help="Close popup"):
415+
st.session_state["popup_open"] = False
416+
st.rerun()
417+
407418
st.write(
408419
"**Resetting the configuration cannot be reversed, proceed with caution!**"
409420
)
421+
410422
st.text_input('Enter "reset" to proceed', key="reset_configuration")
411423
if st.button(
412424
":red[Reset]", disabled=st.session_state["reset_configuration"] != "reset"

code/backend/pages/common.css

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
11
#MainMenu {visibility: hidden;}
22
footer {visibility: hidden;}
33
header {visibility: hidden;}
4-
.st-emotion-cache-1kyxreq{width:100%}
4+
[data-testid="baseButton-secondary"] svg{display: none;}
5+
[data-testid="stPopoverBody"] button{float: right;}
6+
[data-testid="stSidebar"] {z-index: 999;}
7+
[data-testid="stPopoverBody"] .stTooltipIcon [data-testid="baseButton-secondary"] p{
8+
font-weight: bold;
9+
}
10+
[data-testid="stPopoverBody"] .stTooltipIcon {
11+
position: absolute;
12+
right: 0;
13+
margin-top: 0.3rem;
14+
}
15+
[data-testid="stPopoverBody"] [data-testid="stVerticalBlock"]{
16+
width: 520px;
17+
}
18+
[data-testid="stPopoverBody"] .stTooltipIcon [data-testid="baseButton-secondary"]{
19+
border: none;
20+
z-index: 1;
21+
}
522

623
.stTextArea{width: 100% !important;}
724
@media screen and (-ms-high-contrast: active), (forced-colors: active) {

0 commit comments

Comments
 (0)