Skip to content

Commit

Permalink
refactor out confusing show_only_document & show_document_model optio…
Browse files Browse the repository at this point in the history
…ns from language_model_settings
  • Loading branch information
devxpy committed Feb 29, 2024
1 parent b127d97 commit a345b59
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 30 deletions.
28 changes: 1 addition & 27 deletions daras_ai_v2/language_model_settings_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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")

Expand Down
14 changes: 11 additions & 3 deletions recipes/VideoBots.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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
Expand Down Expand Up @@ -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", "")
Expand Down

0 comments on commit a345b59

Please sign in to comment.