Skip to content

Commit 2a09469

Browse files
authored
Merge pull request #987 from WolframResearch/feature/more-usage-reduction
Avoid excessively large context lengths in regular chat notebooks
2 parents 8242697 + 0b59347 commit 2a09469

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Source/Chatbook/Settings.wl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ $autoSettingKeyDependencies = <|
407407
"HandlerFunctionsKeys" -> "EnableLLMServices",
408408
"HybridToolMethod" -> { "Model", "ToolsEnabled" },
409409
"MaxCellStringLength" -> { "Model", "MaxContextTokens" },
410-
"MaxContextTokens" -> "Model",
410+
"MaxContextTokens" -> { "Authentication", "Model" },
411411
"MaxOutputCellStringLength" -> "MaxCellStringLength",
412412
"MaxTokens" -> "Model",
413413
"Multimodal" -> { "EnableLLMServices", "Model" },
@@ -621,7 +621,7 @@ styleStopTokens // endDefinition;
621621
chooseMaxCellStringLength // beginDefinition;
622622
chooseMaxCellStringLength[ as_Association ] := chooseMaxCellStringLength[ as, as[ "MaxContextTokens" ] ];
623623
chooseMaxCellStringLength[ as_, Infinity ] := Infinity;
624-
chooseMaxCellStringLength[ as_, tokens: $$size ] := Ceiling[ $defaultMaxCellStringLength * tokens / 2^13 ];
624+
chooseMaxCellStringLength[ as_, tokens: $$size ] := Ceiling[ $defaultMaxCellStringLength * tokens / 2^14 ];
625625
chooseMaxCellStringLength // endDefinition;
626626

627627
(* ::**************************************************************************************************************:: *)
@@ -637,6 +637,7 @@ chooseMaxOutputCellStringLength // endDefinition;
637637
(*autoMaxContextTokens*)
638638
autoMaxContextTokens // beginDefinition;
639639
autoMaxContextTokens[ as_? ollamaQ ] := serviceMaxContextTokens @ as;
640+
autoMaxContextTokens[ as_Association? llmKitQ ] := Min[ 2^16, autoMaxContextTokens[ as, as[ "Model" ] ] ];
640641
autoMaxContextTokens[ as_Association ] := autoMaxContextTokens[ as, as[ "Model" ] ];
641642
autoMaxContextTokens[ as_, model_ ] := autoMaxContextTokens[ as, model, toModelName @ model ];
642643
autoMaxContextTokens[ _, _, name_String ] := autoMaxContextTokens0 @ name;

0 commit comments

Comments
 (0)