Skip to content

Commit

Permalink
fixed typo and refactored document uploader
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderGi committed Sep 27, 2023
1 parent 40c7b25 commit a5d5771
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 28 deletions.
42 changes: 15 additions & 27 deletions daras_ai_v2/doc_search_settings_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,21 @@ def document_uploader(
if st.checkbox("Enter Custom URLs", key=checkbox_key):
if not custom_key in st.session_state:
st.session_state[custom_key] = "\n".join(documents)
if accept_multiple_files:
text_value = st.text_area(
label,
key=custom_key,
label_visibility="collapsed",
height=150,
style={
"whiteSpace": "pre",
"overflowWrap": "normal",
"overflowX": "scroll",
"fontFamily": "monospace",
"fontSize": "0.9rem",
},
)
else:
text_value = st.text_input(
label,
label_visibility="collapsed",
key=custom_key,
style={
"whiteSpace": "pre",
"overflowWrap": "normal",
"overflowX": "scroll",
"fontFamily": "monospace",
"fontSize": "0.9rem",
},
)
fn = st.text_area if accept_multiple_files else st.text_input
kwargs = dict(height=150) if accept_multiple_files else {}
text_value = fn(
label,
key=custom_key,
label_visibility="collapsed",
style={
"whiteSpace": "pre",
"overflowWrap": "normal",
"overflowX": "scroll",
"fontFamily": "monospace",
"fontSize": "0.9rem",
},
**kwargs,
)
st.session_state[key] = text_value.strip().splitlines()
else:
st.session_state.pop(custom_key, None)
Expand Down
2 changes: 1 addition & 1 deletion daras_ai_v2/glossary.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def glossary_input(
glossary_url = document_uploader(
label=label,
key=key,
accept=["csv", "xlsx", "xls", "gsheet", "ods", "tsv"],
accept=[".csv", ".xlsx", ".xls", ".gsheet", ".ods", ".tsv"],
accept_multiple_files=False,
)
st.caption(
Expand Down

0 comments on commit a5d5771

Please sign in to comment.