From 74aff6bda278342170f435e26cb72e73e354f269 Mon Sep 17 00:00:00 2001 From: mike dupont Date: Sat, 16 Sep 2023 20:27:37 -0400 Subject: [PATCH] refactored --- src/introspector/concepts.py | 29 ++++++++++++------- .../streamlitio/selector/list_input.py | 20 +++++++++++++ 2 files changed, 38 insertions(+), 11 deletions(-) create mode 100644 src/introspector/modules/streamlitio/selector/list_input.py diff --git a/src/introspector/concepts.py b/src/introspector/concepts.py index 7cb0e17..0960775 100644 --- a/src/introspector/concepts.py +++ b/src/introspector/concepts.py @@ -1,14 +1,21 @@ -from .app_args import get_concept_id,params,app_args -from .columns import col_concept import streamlit as st +from .modules.streamlitio.selector.list_input import list_input +from .app_args import params,app_args +from .columns import col_concept + +concept_choices = ["python", "streamlit", "clarifai"] # Replace with your actual choices + def get_concept_id(): return app_args['concept_id'] -def get_inputs(): - with col_concept: - app_args["concept_id"] = st.text_input( - "Concept ID", - key = "concept_id", - help = "Concept id to search for" , - value = params.get("concept_id","python") - ) - return get_concept_id() + +def get_concept(): + # Replace this part with your desired input logic + app_args["mode"] = list_input( + "Select a Concept", + concept_choices, + key="concept-choice", + default_value=params.get("concept_id", "python") + ) + + get_concept_id() + diff --git a/src/introspector/modules/streamlitio/selector/list_input.py b/src/introspector/modules/streamlitio/selector/list_input.py new file mode 100644 index 0000000..b3fee74 --- /dev/null +++ b/src/introspector/modules/streamlitio/selector/list_input.py @@ -0,0 +1,20 @@ +import streamlit as st + +def list_input(title, choices, key, default_value): + opt_index = 0 + if default_value in choices: + opt_index = choices.index(default_value) + + selected_choice = st.selectbox( + title, + choices, + key=key, + index=opt_index, + ) + + return selected_choice +``` + +Now, you can use this `list_input` function to create list-based inputs. Here's how you can use it for your `get_concept` function: + +```python