diff --git a/alphastats/gui/pages/05_GPT.py b/alphastats/gui/pages/05_GPT.py index f96c9e04..aeaae9c0 100644 --- a/alphastats/gui/pages/05_GPT.py +++ b/alphastats/gui/pages/05_GPT.py @@ -198,16 +198,21 @@ def select_analysis(): volcano_plot._plot() genes_of_interest_colored = volcano_plot.get_colored_labels() genes_of_interest_colored_df = volcano_plot.get_colored_labels_df() + print(genes_of_interest_colored_df) + + gene_names_colname = st.session_state["loader"].gene_names + prot_ids_colname = st.session_state["loader"].index_column + st.session_state["prot_id_to_gene"] = dict( zip( - genes_of_interest_colored_df["Protein IDs"].tolist(), - genes_of_interest_colored_df["Gene names"].tolist(), + genes_of_interest_colored_df[prot_ids_colname].tolist(), + genes_of_interest_colored_df[gene_names_colname].tolist(), ) ) st.session_state["gene_to_prot_id"] = dict( zip( - genes_of_interest_colored_df["Gene names"].tolist(), - genes_of_interest_colored_df["Protein IDs"].tolist(), + genes_of_interest_colored_df[gene_names_colname].tolist(), + genes_of_interest_colored_df[prot_ids_colname].tolist(), ) ) diff --git a/alphastats/gui/utils/gpt_helper.py b/alphastats/gui/utils/gpt_helper.py index 018d862e..1ae43689 100644 --- a/alphastats/gui/utils/gpt_helper.py +++ b/alphastats/gui/utils/gpt_helper.py @@ -745,16 +745,21 @@ def send_message_save_thread(client: openai.OpenAI, message: str) -> Optional[li thread_id=st.session_state["thread_id"], assistant_id=st.session_state["assistant"].id, ) - - plots = wait_for_run_completion(client, st.session_state["thread_id"], run.id) - + try: + plots = wait_for_run_completion(client, st.session_state["thread_id"], run.id) + except KeyError as e: + print(e) + plots = None messages = client.beta.threads.messages.list( thread_id=st.session_state["thread_id"] ) st.session_state.messages = [] for num, message in enumerate(messages.data[::-1]): role = message.role - content = message.content[0].text.value + if message.content: + content = message.content[0].text.value + else: + content = "Sorry, I was unable to process this message. Try again or change your request." st.session_state.messages.append({"role": role, "content": content}) if not plots: return diff --git a/alphastats/loader/SpectronautLoader.py b/alphastats/loader/SpectronautLoader.py index c9632075..da813bf3 100644 --- a/alphastats/loader/SpectronautLoader.py +++ b/alphastats/loader/SpectronautLoader.py @@ -38,7 +38,7 @@ def __init__( self.confidence_column = None self.filter_columns = [] self.evidence_df = None - self.gene_names = None + self.gene_names = gene_names_column self._read_spectronaut_file(file=file, sep=sep)