From a345b59d4a3b307c816eb29592fac561495c29e7 Mon Sep 17 00:00:00 2001 From: Dev Aggarwal Date: Thu, 29 Feb 2024 19:07:30 +0530 Subject: [PATCH] refactor out confusing show_only_document & show_document_model options from language_model_settings --- .../language_model_settings_widgets.py | 28 +------------------ recipes/VideoBots.py | 14 ++++++++-- 2 files changed, 12 insertions(+), 30 deletions(-) diff --git a/daras_ai_v2/language_model_settings_widgets.py b/daras_ai_v2/language_model_settings_widgets.py index 0990ed793..278fc1293 100644 --- a/daras_ai_v2/language_model_settings_widgets.py +++ b/daras_ai_v2/language_model_settings_widgets.py @@ -6,23 +6,7 @@ from daras_ai_v2.language_model import LargeLanguageModels -def language_model_settings( - show_selector=True, show_document_model=False, show_only_document=False -): - from recipes.VideoBots import VideoBotsPage - - if show_only_document: - doc_model_descriptions = azure_form_recognizer_models() - st.selectbox( - f"{field_desc(VideoBotsPage.RequestModel, 'document_model')}", - key="document_model", - options=[None, *doc_model_descriptions], - format_func=lambda x: ( - f"{doc_model_descriptions[x]} ({x})" if x else "———" - ), - ) - return - +def language_model_settings(show_selector=True): st.write("##### 🔠 Language Model Settings") if show_selector: @@ -32,16 +16,6 @@ def language_model_settings( key="selected_model", use_selectbox=True, ) - if show_document_model: - doc_model_descriptions = azure_form_recognizer_models() - st.selectbox( - f"###### {field_title_desc(VideoBotsPage.RequestModel, 'document_model')}", - key="document_model", - options=[None, *doc_model_descriptions], - format_func=lambda x: ( - f"{doc_model_descriptions[x]} ({x})" if x else "———" - ), - ) st.checkbox("Avoid Repetition", key="avoid_repetition") diff --git a/recipes/VideoBots.py b/recipes/VideoBots.py index 03cfad8f7..c9706df49 100644 --- a/recipes/VideoBots.py +++ b/recipes/VideoBots.py @@ -20,6 +20,7 @@ ) from daras_ai_v2.azure_doc_extract import ( azure_form_recognizer, + azure_form_recognizer_models, ) from daras_ai_v2.base import BasePage, MenuTabs from daras_ai_v2.bot_integration_widgets import ( @@ -32,9 +33,8 @@ document_uploader, ) from daras_ai_v2.enum_selector_widget import enum_multiselect -from daras_ai_v2.exceptions import UserError -from daras_ai_v2.field_render import field_title_desc from daras_ai_v2.enum_selector_widget import enum_selector +from daras_ai_v2.exceptions import UserError from daras_ai_v2.field_render import field_title_desc, field_desc from daras_ai_v2.functions import LLMTools from daras_ai_v2.glossary import glossary_input, validate_glossary_document @@ -389,7 +389,15 @@ def render_form_v2(self): st.session_state.get("document_model"), ), ): - language_model_settings(show_only_document=True) + doc_model_descriptions = azure_form_recognizer_models() + st.selectbox( + f"{field_desc(self.RequestModel, 'document_model')}", + key="document_model", + options=[None, *doc_model_descriptions], + format_func=lambda x: ( + f"{doc_model_descriptions[x]} ({x})" if x else "———" + ), + ) def validate_form_v2(self): input_glossary = st.session_state.get("input_glossary_document", "")