Skip to content

Commit

Permalink
Do away with columns to avoid misalignment
Browse files Browse the repository at this point in the history
  • Loading branch information
PGijsbers committed Jul 11, 2024
1 parent 2e44fd2 commit 2f126ee
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 35 deletions.
Binary file removed .DS_Store
Binary file not shown.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ chroma_db/
*.sqlite3
*.pkl
*.pyc
*.DS_store
*.DS_Store
*.ipynb_checkpoints
*.csv
serving/data/
Expand All @@ -16,4 +16,4 @@ tools/data/*
*checkpoint*
*.pid
tools/data/
tools/data/*
tools/data/*
49 changes: 16 additions & 33 deletions tools/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,48 +81,31 @@ def load_label_data() -> dict[int, list[str]]:


topic_queries = load_csv("data/LLM Evaluation - Topic Queries.csv")
topics = topic_queries['Topic']
print(topics)

title_left, title_right = st.columns(spec=2, gap="medium")
with title_left:
st.write("## Query")

with title_right:
st.write("## Is it relevant?")

topics = topic_queries['Topic'].tolist()
st.write("## For each query, is this dataset relevant?")

def update_relevancy(var, topic):
print(st.session_state[var], topic)
if st.session_state[var] and topic not in st.session_state[UNSAVED_DATA][did]:
st.session_state[UNSAVED_DATA][did].append(topic)
if not st.session_state[var] and topic in st.session_state[UNSAVED_DATA][did]:
st.session_state[UNSAVED_DATA][did].remove(topic)


with st.container(height=400):
query_left, relevant_right = st.columns(spec=2)

with query_left:
for topic in topics:
st.write(topic)

with relevant_right:
for i, topic in enumerate(topics):
def update_this_relevancy(var_, topic_):
"""Helper function to bind the variables to scope."""
return lambda: update_relevancy(f"q{var_}", topic_)

# We need to use the on_change callbacks instead of the regular
# return values, because state needs to be up-to-date *before*
# the next render pass.
st.checkbox(
label=f"q{i}",
label_visibility="hidden",
value=(topic in st.session_state[UNSAVED_DATA][did]),
key=f"q{i}",
on_change=update_this_relevancy(i, topic),
)
for i, topic in enumerate(topics):
def update_this_relevancy(var_, topic_):
"""Helper function to bind the variables to scope."""
return lambda: update_relevancy(f"q{var_}", topic_)

# We need to use the on_change callbacks instead of the regular
# return values, because state needs to be up-to-date *before*
# the next render pass.
st.checkbox(
label=topic,
value=(topic in st.session_state[UNSAVED_DATA][did]),
key=f"q{i}",
on_change=update_this_relevancy(i, topic),
)


unsaved_changes = (st.session_state[UNSAVED_DATA] != st.session_state[LOADED_DATA])
Expand Down

0 comments on commit 2f126ee

Please sign in to comment.