chrissoria commited on
Commit
5d9deaa
·
1 Parent(s): 13d9cb9

Trigger verbosity check on Add More click; fix disabled button styling

Browse files
Files changed (2) hide show
  1. app.py +25 -32
  2. theme.py +15 -0
app.py CHANGED
@@ -1704,38 +1704,31 @@ with col_input:
1704
  if cat_value.strip():
1705
  categories_entered.append(cat_value.strip())
1706
 
1707
- add_col, check_col = st.columns(2)
1708
- with add_col:
1709
- if st.session_state.category_count < MAX_CATEGORIES:
1710
- if st.button("+ Add More", use_container_width=True):
1711
- st.session_state.category_count += 1
1712
- st.rerun()
1713
- with check_col:
1714
- if st.button(
1715
- "Check categories",
1716
- use_container_width=True,
1717
- disabled=not categories_entered,
1718
- help="Use the selected model to flag categories that lack a description or example (1 API call).",
1719
- ):
1720
- actual_api_key, provider = get_api_key(model, model_tier, api_key)
1721
- if not actual_api_key:
1722
- st.error(f"{provider} API key not configured")
1723
- else:
1724
- with st.spinner("Checking categories…"):
1725
- try:
1726
- verbosity_result = catllm.check_category_verbosity(
1727
- categories_entered,
1728
- api_key=actual_api_key,
1729
- user_model=model,
1730
- model_source=get_model_source(model),
1731
- )
1732
- st.session_state.verbosity_check = {
1733
- 'categories': list(categories_entered),
1734
- 'result': verbosity_result,
1735
- }
1736
- except Exception as e:
1737
- st.error(f"Verbosity check failed: {e}")
1738
- st.rerun()
1739
 
1740
  if categories_entered and has_other_category and not has_other_category(categories_entered):
1741
  st.warning(
 
1704
  if cat_value.strip():
1705
  categories_entered.append(cat_value.strip())
1706
 
1707
+ if st.session_state.category_count < MAX_CATEGORIES:
1708
+ if st.button("+ Add More", use_container_width=True):
1709
+ # Run a verbosity check on what's been entered so far so the
1710
+ # user gets feedback as they iteratively build their categories.
1711
+ if categories_entered:
1712
+ actual_api_key, provider = get_api_key(model, model_tier, api_key)
1713
+ if actual_api_key:
1714
+ with st.spinner("Checking categories…"):
1715
+ try:
1716
+ verbosity_result = catllm.check_category_verbosity(
1717
+ categories_entered,
1718
+ api_key=actual_api_key,
1719
+ user_model=model,
1720
+ model_source=get_model_source(model),
1721
+ )
1722
+ st.session_state.verbosity_check = {
1723
+ 'categories': list(categories_entered),
1724
+ 'result': verbosity_result,
1725
+ }
1726
+ except Exception:
1727
+ # Don't block the user from adding a category if the
1728
+ # verbosity check fails (e.g., transient API error).
1729
+ pass
1730
+ st.session_state.category_count += 1
1731
+ st.rerun()
 
 
 
 
 
 
 
1732
 
1733
  if categories_entered and has_other_category and not has_other_category(categories_entered):
1734
  st.warning(
theme.py CHANGED
@@ -178,6 +178,21 @@ html, body,
178
  transform: translateY(1px) !important;
179
  }
180
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181
  .stButton > button[kind="primary"],
182
  .stFormSubmitButton > button[kind="primary"] {
183
  background: var(--teal) !important;
 
178
  transform: translateY(1px) !important;
179
  }
180
 
181
+ /* Disabled state — keep dark surface, dim the text (overrides Streamlit
182
+ default white-on-white that's unreadable in dark mode). */
183
+ .stButton > button:disabled,
184
+ .stDownloadButton > button:disabled,
185
+ .stFormSubmitButton > button:disabled,
186
+ .stButton > button[disabled],
187
+ .stDownloadButton > button[disabled],
188
+ .stFormSubmitButton > button[disabled] {
189
+ background: var(--bg-2) !important;
190
+ color: var(--text-3) !important;
191
+ border-color: var(--hairline) !important;
192
+ box-shadow: none !important;
193
+ cursor: not-allowed !important;
194
+ }
195
+
196
  .stButton > button[kind="primary"],
197
  .stFormSubmitButton > button[kind="primary"] {
198
  background: var(--teal) !important;