From a5d577112b2ec5f35423388ea18ce42a2477c9fd Mon Sep 17 00:00:00 2001 From: Alexander Metzger Date: Tue, 26 Sep 2023 23:28:49 -0700 Subject: [PATCH] fixed typo and refactored document uploader --- daras_ai_v2/doc_search_settings_widgets.py | 42 ++++++++-------------- daras_ai_v2/glossary.py | 2 +- 2 files changed, 16 insertions(+), 28 deletions(-) diff --git a/daras_ai_v2/doc_search_settings_widgets.py b/daras_ai_v2/doc_search_settings_widgets.py index aae097270..91a2f5792 100644 --- a/daras_ai_v2/doc_search_settings_widgets.py +++ b/daras_ai_v2/doc_search_settings_widgets.py @@ -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) diff --git a/daras_ai_v2/glossary.py b/daras_ai_v2/glossary.py index 761d4cf4d..630cbef4a 100644 --- a/daras_ai_v2/glossary.py +++ b/daras_ai_v2/glossary.py @@ -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(