Skip to content

Commit

Permalink
refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
mike dupont committed Sep 17, 2023
1 parent a41c94e commit 74aff6b
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 11 deletions.
29 changes: 18 additions & 11 deletions src/introspector/concepts.py
Original file line number Diff line number Diff line change
@@ -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()

20 changes: 20 additions & 0 deletions src/introspector/modules/streamlitio/selector/list_input.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 74aff6b

Please sign in to comment.