Skip to content

Commit

Permalink
[BERTopic] Bugfix: config not saved when changing page
Browse files Browse the repository at this point in the history
  • Loading branch information
grosjeang committed Jan 21, 2025
1 parent 31647c9 commit f949612
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions bertrend/demos/demos_utils/parameters_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,21 @@ def display_bertopic_hyperparameters():

# BERTopic model parameters
with st.expander("BERTopic Model Settings", expanded=False):
# Get BERTopic default configuration
with open(BERTOPIC_DEFAULT_CONFIG_PATH, "r") as f:
# Load default parameter the first time
toml_txt = f.read()
# If BERTopic config is already in session state, use it
if "bertopic_config" in st.session_state:
toml_txt = st.session_state["bertopic_config"]
# Else get BERTopic default configuration
else:
with open(BERTOPIC_DEFAULT_CONFIG_PATH, "r") as f:
# Load default parameter the first time
toml_txt = f.read()

# Add code editor to edit the config file
st.write(INFO_ICON + " CTRL + Enter to update")
config_editor = code_editor(toml_txt, lang="toml")
config_editor = code_editor(
toml_txt,
lang="toml",
)

# If code is edited, update config
if config_editor["text"] != "":
Expand Down

0 comments on commit f949612

Please sign in to comment.