From c05de035caa2a1b0fedf6c20029c3462dd1681e8 Mon Sep 17 00:00:00 2001 From: Lars Yencken Date: Thu, 19 Sep 2024 08:37:55 +0000 Subject: [PATCH] :bug: Fix insighter case with no subtitle --- apps/wizard/app_pages/datainsight_robot.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/wizard/app_pages/datainsight_robot.py b/apps/wizard/app_pages/datainsight_robot.py index 3ba9f0c0dd4..6e977b9887b 100644 --- a/apps/wizard/app_pages/datainsight_robot.py +++ b/apps/wizard/app_pages/datainsight_robot.py @@ -47,9 +47,10 @@ def get_trajectory_prompt(base_prompt: str, slug: str) -> str: df_s = df.to_csv() title = chart.config["title"] - subtitle = chart.config["subtitle"] + subtitle = chart.config.get("subtitle") + context = f"## {title}\n\n{subtitle}\n\n" if subtitle else f"## {title}n\n" - return f"{base_prompt}\n\n---\n\n## {title}\n\n{subtitle}\n\n{df_s}" + return f"{base_prompt}\n\n---\n\n{context}{df_s}" (tab1, tab2) = st.tabs(["Insight from chart", "Explain raw data"]) @@ -167,6 +168,9 @@ def get_trajectory_prompt(base_prompt: str, slug: str) -> str: help="Introduce the URL to a Grapher URL. Query parameters work!", key="tab2_url", ) + if len(slugs) > 1: + st.warning("More than one slug selected, only the first one will be used") + slug = None if len(slugs) == 0 else slugs[0] with st.expander("Edit the prompt"):