From 432c62db0369aced2d7f11436c41d7dfa5da6714 Mon Sep 17 00:00:00 2001 From: Dev Aggarwal Date: Tue, 17 Dec 2024 11:02:16 +0530 Subject: [PATCH] revert scroll into view behavior match max_tokens for query generator --- daras_ai_v2/base.py | 3 +-- daras_ai_v2/html_spinner_widget.py | 12 ++++++------ daras_ai_v2/query_generator.py | 2 +- daras_ai_v2/variables_widget.py | 2 +- recipes/VideoBots.py | 3 ++- server.py | 4 +++- 6 files changed, 14 insertions(+), 12 deletions(-) diff --git a/daras_ai_v2/base.py b/daras_ai_v2/base.py index 582e3f315..142602018 100644 --- a/daras_ai_v2/base.py +++ b/daras_ai_v2/base.py @@ -45,7 +45,7 @@ from daras_ai_v2.fastapi_tricks import get_route_path from daras_ai_v2.github_tools import github_url_for_file from daras_ai_v2.grid_layout_widget import grid_layout -from daras_ai_v2.html_spinner_widget import html_spinner, scroll_into_view +from daras_ai_v2.html_spinner_widget import html_spinner from daras_ai_v2.manage_api_keys_widget import manage_api_keys from daras_ai_v2.meta_preview_url import meta_preview_url from daras_ai_v2.query_params_util import extract_query_params @@ -1944,7 +1944,6 @@ def on_submit(self): sr = self.create_and_validate_new_run(enable_rate_limits=True) if not sr: return - scroll_into_view(".gooey-spinner-top") self.call_runner_task(sr) return sr diff --git a/daras_ai_v2/html_spinner_widget.py b/daras_ai_v2/html_spinner_widget.py index 3670e7224..db5dc243d 100644 --- a/daras_ai_v2/html_spinner_widget.py +++ b/daras_ai_v2/html_spinner_widget.py @@ -1,9 +1,7 @@ -import json - import gooey_gui as gui -def html_spinner(text: str): +def html_spinner(text: str, scroll_into_view=True): gui.html( # language=HTML f""" @@ -14,6 +12,8 @@ def html_spinner(text: str): """ ) - -def scroll_into_view(selector: str): - gui.js("document.querySelector(%s).scrollIntoView();" % json.dumps(selector)) + if scroll_into_view: + gui.js( + # language=JavaScript + """document.querySelector(".gooey-spinner-top").scrollIntoView()""" + ) diff --git a/daras_ai_v2/query_generator.py b/daras_ai_v2/query_generator.py index f69606160..e56ff6b79 100644 --- a/daras_ai_v2/query_generator.py +++ b/daras_ai_v2/query_generator.py @@ -28,7 +28,7 @@ def generate_final_search_query( return run_language_model( model=request.selected_model, prompt=instructions, - max_tokens=1024, + max_tokens=request.max_tokens, quality=request.quality, temperature=request.sampling_temperature, avoid_repetition=request.avoid_repetition, diff --git a/daras_ai_v2/variables_widget.py b/daras_ai_v2/variables_widget.py index ea24131e0..2725bc7d8 100644 --- a/daras_ai_v2/variables_widget.py +++ b/daras_ai_v2/variables_widget.py @@ -49,7 +49,7 @@ def variables_input( ) pressed_add = False if var_names or allow_add: - with gui.div(className="d-flex align-items-center gap-3 mb-2"): + with gui.div(className="d-flex align-items-center gap-3 mb-2"): gui.write( label, help=f"{description} Learn more.", diff --git a/recipes/VideoBots.py b/recipes/VideoBots.py index 863d7e58a..6a69934ec 100644 --- a/recipes/VideoBots.py +++ b/recipes/VideoBots.py @@ -997,7 +997,8 @@ def search_step(self, request, response, user_input, model): yield "Finding keywords..." k_request = request.copy() # other models dont support JSON mode - k_request.selected_model = LargeLanguageModels.gpt_4_turbo.name + k_request.selected_model = LargeLanguageModels.gpt_4_o.name + k_request.max_tokens = 4096 keyword_query = json.loads( generate_final_search_query( request=k_request, diff --git a/server.py b/server.py index bc89fcfdb..50fbdb5dc 100644 --- a/server.py +++ b/server.py @@ -152,4 +152,6 @@ async def _exc_handler(request: Request, exc: Exception, template_name: str): if __name__ == "__main__": from gooey_gui.core.reloader import runserver - runserver("server:app", port=8080, reload=True, reload_excludes=["models.py"]) + runserver( + "server:app", port=8080, reload=True, reload_excludes=["models.py", "api.py"] + )