Skip to content

Commit

Permalink
sean tweaks of copilot settings
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderGi committed Feb 2, 2024
1 parent 24cf032 commit 4c94061
Show file tree
Hide file tree
Showing 7 changed files with 167 additions and 102 deletions.
1 change: 0 additions & 1 deletion daras_ai_v2/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1298,7 +1298,6 @@ def _render_input_col(self):
self.render_form_v2()
with st.expander("⚙️ Settings"):
self.render_settings()
st.write("---")
submitted = self.render_submit_button()
with st.div(style={"textAlign": "right"}):
st.caption(
Expand Down
7 changes: 7 additions & 0 deletions daras_ai_v2/doc_search_settings_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import gooey_ui as st
from daras_ai_v2 import settings
from daras_ai_v2.asr import AsrModels, google_translate_language_selector
from daras_ai_v2.prompt_vars import prompt_vars_widget
from daras_ai_v2.enum_selector_widget import enum_selector
from daras_ai_v2.search_ref import CitationStyles

Expand Down Expand Up @@ -104,6 +105,9 @@ def doc_search_settings(
key="query_instructions",
height=300,
)
prompt_vars_widget(
"query_instructions",
)
if keyword_instructions_allowed:
st.text_area(
"""
Expand All @@ -114,6 +118,9 @@ def doc_search_settings(
key="keyword_instructions",
height=300,
)
prompt_vars_widget(
"keyword_instructions",
)

dense_weight_ = DocSearchRequest.__fields__["dense_weight"]
st.slider(
Expand Down
20 changes: 20 additions & 0 deletions daras_ai_v2/field_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,23 @@ def field_title_desc(model: typing.Type[BaseModel], name: str) -> str:
[field.field_info.title, field.field_info.description or ""],
)
)


def field_title(model: typing.Type[BaseModel], name: str) -> str:
field = model.__fields__[name]
return "\n".join(
filter(
None,
[field.field_info.title],
)
)


def field_desc(model: typing.Type[BaseModel], name: str) -> str:
field = model.__fields__[name]
return "\n".join(
filter(
None,
[field.field_info.description or ""],
)
)
18 changes: 16 additions & 2 deletions daras_ai_v2/language_model_settings_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,27 @@
from daras_ai_v2.azure_doc_extract import azure_form_recognizer_models

from daras_ai_v2.enum_selector_widget import enum_selector
from daras_ai_v2.field_render import field_title_desc
from daras_ai_v2.field_render import field_title_desc, field_desc
from daras_ai_v2.language_model import LargeLanguageModels


def language_model_settings(show_selector=True, show_document_model=False):
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

st.write("##### 🔠 Language Model Settings")

if show_selector:
Expand Down
5 changes: 4 additions & 1 deletion daras_ai_v2/prompt_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,14 @@ def prompt_vars_widget(*keys: str, variables_key: str = "variables"):
if not (template_vars or err):
return

st.write("##### ⌥ Variables")
st.write("###### ⌥ Variables")
old_state = st.session_state.get(variables_key, {})
new_state = {}
for name in sorted(template_vars):
if name in st.session_state:
st.write(
f"⚠️ `{name}` is a reserved variable name. If you meant to create a custom variable, please use a different name."
)
continue
var_key = f"__{variables_key}_{name}"
st.session_state.setdefault(var_key, old_state.get(name, ""))
Expand Down
13 changes: 7 additions & 6 deletions daras_ai_v2/text_to_speech_settings_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,13 @@ class TextToSpeechProviders(Enum):
}


def text_to_speech_settings(page):
st.write(
"""
##### 🗣️ Voice Settings
"""
)
def text_to_speech_settings(page, show_label=True):
if show_label:
st.write(
"""
##### 🗣️ Voice Settings
"""
)

col1, col2 = st.columns(2)
with col1:
Expand Down
Loading

0 comments on commit 4c94061

Please sign in to comment.