@@ -100,6 +100,7 @@ async def run_browser_agent(
100
100
agent_type ,
101
101
llm_provider ,
102
102
llm_model_name ,
103
+ llm_num_ctx ,
103
104
llm_temperature ,
104
105
llm_base_url ,
105
106
llm_api_key ,
@@ -144,6 +145,7 @@ async def run_browser_agent(
144
145
llm = utils .get_llm_model (
145
146
provider = llm_provider ,
146
147
model_name = llm_model_name ,
148
+ num_ctx = llm_num_ctx ,
147
149
temperature = llm_temperature ,
148
150
base_url = llm_base_url ,
149
151
api_key = llm_api_key ,
@@ -435,6 +437,7 @@ async def run_with_stream(
435
437
agent_type ,
436
438
llm_provider ,
437
439
llm_model_name ,
440
+ llm_num_ctx ,
438
441
llm_temperature ,
439
442
llm_base_url ,
440
443
llm_api_key ,
@@ -463,6 +466,7 @@ async def run_with_stream(
463
466
agent_type = agent_type ,
464
467
llm_provider = llm_provider ,
465
468
llm_model_name = llm_model_name ,
469
+ llm_num_ctx = llm_num_ctx ,
466
470
llm_temperature = llm_temperature ,
467
471
llm_base_url = llm_base_url ,
468
472
llm_api_key = llm_api_key ,
@@ -495,6 +499,7 @@ async def run_with_stream(
495
499
agent_type = agent_type ,
496
500
llm_provider = llm_provider ,
497
501
llm_model_name = llm_model_name ,
502
+ llm_num_ctx = llm_num_ctx ,
498
503
llm_temperature = llm_temperature ,
499
504
llm_base_url = llm_base_url ,
500
505
llm_api_key = llm_api_key ,
@@ -627,7 +632,7 @@ async def close_global_browser():
627
632
await _global_browser .close ()
628
633
_global_browser = None
629
634
630
- async def run_deep_search (research_task , max_search_iteration_input , max_query_per_iter_input , llm_provider , llm_model_name , llm_temperature , llm_base_url , llm_api_key , use_vision , use_own_browser , headless ):
635
+ async def run_deep_search (research_task , max_search_iteration_input , max_query_per_iter_input , llm_provider , llm_model_name , llm_num_ctx , llm_temperature , llm_base_url , llm_api_key , use_vision , use_own_browser , headless ):
631
636
from src .utils .deep_research import deep_research
632
637
global _global_agent_state
633
638
@@ -637,6 +642,7 @@ async def run_deep_search(research_task, max_search_iteration_input, max_query_p
637
642
llm = utils .get_llm_model (
638
643
provider = llm_provider ,
639
644
model_name = llm_model_name ,
645
+ num_ctx = llm_num_ctx ,
640
646
temperature = llm_temperature ,
641
647
base_url = llm_base_url ,
642
648
api_key = llm_api_key ,
@@ -740,6 +746,15 @@ def create_ui(config, theme_name="Ocean"):
740
746
allow_custom_value = True , # Allow users to input custom model names
741
747
info = "Select a model from the dropdown or type a custom model name"
742
748
)
749
+ llm_num_ctx = gr .Slider (
750
+ minimum = 2 ** 8 ,
751
+ maximum = 2 ** 16 ,
752
+ value = config ['llm_num_ctx' ],
753
+ step = 1 ,
754
+ label = "Max Context Length" ,
755
+ info = "Controls max context length model needs to handle (less = faster)" ,
756
+ visible = config ['llm_provider' ] == "ollama"
757
+ )
743
758
llm_temperature = gr .Slider (
744
759
minimum = 0.0 ,
745
760
maximum = 2.0 ,
@@ -761,6 +776,17 @@ def create_ui(config, theme_name="Ocean"):
761
776
info = "Your API key (leave blank to use .env)"
762
777
)
763
778
779
+ # Change event to update context length slider
780
+ def update_llm_num_ctx_visibility (llm_provider ):
781
+ return gr .update (visible = llm_provider == "ollama" )
782
+
783
+ # Bind the change event of llm_provider to update the visibility of context length slider
784
+ llm_provider .change (
785
+ fn = update_llm_num_ctx_visibility ,
786
+ inputs = llm_provider ,
787
+ outputs = llm_num_ctx
788
+ )
789
+
764
790
with gr .TabItem ("🌐 Browser Settings" , id = 3 ):
765
791
with gr .Group ():
766
792
with gr .Row ():
@@ -903,7 +929,7 @@ def create_ui(config, theme_name="Ocean"):
903
929
run_button .click (
904
930
fn = run_with_stream ,
905
931
inputs = [
906
- agent_type , llm_provider , llm_model_name , llm_temperature , llm_base_url , llm_api_key ,
932
+ agent_type , llm_provider , llm_model_name , llm_num_ctx , llm_temperature , llm_base_url , llm_api_key ,
907
933
use_own_browser , keep_browser_open , headless , disable_security , window_w , window_h ,
908
934
save_recording_path , save_agent_history_path , save_trace_path , # Include the new path
909
935
enable_recording , task , add_infos , max_steps , use_vision , max_actions_per_step , tool_calling_method
@@ -925,7 +951,7 @@ def create_ui(config, theme_name="Ocean"):
925
951
# Run Deep Research
926
952
research_button .click (
927
953
fn = run_deep_search ,
928
- inputs = [research_task_input , max_search_iteration_input , max_query_per_iter_input , llm_provider , llm_model_name , llm_temperature , llm_base_url , llm_api_key , use_vision , use_own_browser , headless ],
954
+ inputs = [research_task_input , max_search_iteration_input , max_query_per_iter_input , llm_provider , llm_model_name , llm_num_ctx , llm_temperature , llm_base_url , llm_api_key , use_vision , use_own_browser , headless ],
929
955
outputs = [markdown_output_display , markdown_download , stop_research_button , research_button ]
930
956
)
931
957
# Bind the stop button click event after errors_output is defined
@@ -991,7 +1017,7 @@ def list_recordings(save_recording_path):
991
1017
inputs = [config_file_input ],
992
1018
outputs = [
993
1019
agent_type , max_steps , max_actions_per_step , use_vision , tool_calling_method ,
994
- llm_provider , llm_model_name , llm_temperature , llm_base_url , llm_api_key ,
1020
+ llm_provider , llm_model_name , llm_num_ctx , llm_temperature , llm_base_url , llm_api_key ,
995
1021
use_own_browser , keep_browser_open , headless , disable_security , enable_recording ,
996
1022
window_w , window_h , save_recording_path , save_trace_path , save_agent_history_path ,
997
1023
task , config_status
@@ -1002,7 +1028,7 @@ def list_recordings(save_recording_path):
1002
1028
fn = save_current_config ,
1003
1029
inputs = [
1004
1030
agent_type , max_steps , max_actions_per_step , use_vision , tool_calling_method ,
1005
- llm_provider , llm_model_name , llm_temperature , llm_base_url , llm_api_key ,
1031
+ llm_provider , llm_model_name , llm_num_ctx , llm_temperature , llm_base_url , llm_api_key ,
1006
1032
use_own_browser , keep_browser_open , headless , disable_security ,
1007
1033
enable_recording , window_w , window_h , save_recording_path , save_trace_path ,
1008
1034
save_agent_history_path , task ,
0 commit comments