Skip to content

Commit

Permalink
Merge pull request #452 from WolframResearch/bugfix/disable-tools-for…
Browse files Browse the repository at this point in the history
…-palm

Disable tools for PaLM by default
  • Loading branch information
rhennigan authored Nov 13, 2023
2 parents 3f256c6 + 5c84c89 commit 1b5e117
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
19 changes: 10 additions & 9 deletions Source/Chatbook/SendChat.wl
Original file line number Diff line number Diff line change
Expand Up @@ -1299,15 +1299,15 @@ autoMaxContextTokens // endDefinition;

autoMaxContextTokens0 // beginDefinition;
autoMaxContextTokens0[ name_String ] := autoMaxContextTokens0 @ StringSplit[ name, "-"|Whitespace ];
autoMaxContextTokens0[ { ___, "gpt", "4", "vision", ___ } ] := 2^17;
autoMaxContextTokens0[ { ___, "gpt", "4", "turbo" , ___ } ] := 2^17;
autoMaxContextTokens0[ { ___, "claude", "2" , ___ } ] := 10^5;
autoMaxContextTokens0[ { ___, "16k" , ___ } ] := 2^14;
autoMaxContextTokens0[ { ___, "32k" , ___ } ] := 2^15;
autoMaxContextTokens0[ { ___, "gpt", "4" , ___ } ] := 2^13;
autoMaxContextTokens0[ { ___, "gpt", "3.5" , ___ } ] := 2^12;
autoMaxContextTokens0[ { ___, "gpt", "4", "vision" , ___ } ] := 2^17;
autoMaxContextTokens0[ { ___, "gpt", "4", "turbo" , ___ } ] := 2^17;
autoMaxContextTokens0[ { ___, "claude", "2" , ___ } ] := 10^5;
autoMaxContextTokens0[ { ___, "16k" , ___ } ] := 2^14;
autoMaxContextTokens0[ { ___, "32k" , ___ } ] := 2^15;
autoMaxContextTokens0[ { ___, "gpt", "4" , ___ } ] := 2^13;
autoMaxContextTokens0[ { ___, "gpt", "3.5" , ___ } ] := 2^12;
autoMaxContextTokens0[ { ___, "chat", "bison", "001", ___ } ] := 20000;
autoMaxContextTokens0[ _List ] := 2^12;
autoMaxContextTokens0[ _List ] := 2^12;
autoMaxContextTokens0 // endDefinition;

(* ::**************************************************************************************************************:: *)
Expand Down Expand Up @@ -1388,7 +1388,8 @@ getNamedLLMEvaluator // endDefinition;
(*FIXME: move to Tools.wl *)
toolsEnabledQ[ KeyValuePattern[ "ToolsEnabled" -> enabled: True|False ] ] := enabled;
toolsEnabledQ[ KeyValuePattern[ "Model" -> model_ ] ] := toolsEnabledQ @ toModelName @ model;
toolsEnabledQ[ model_String ] := ! TrueQ @ StringStartsQ[ model, "gpt-3", IgnoreCase -> True ];
toolsEnabledQ[ "chat-bison-001" ] := False;
toolsEnabledQ[ model_String ] := ! TrueQ @ StringContainsQ[ model, "gpt-3", IgnoreCase -> True ];
toolsEnabledQ[ ___ ] := False;

(* ::**************************************************************************************************************:: *)
Expand Down
7 changes: 6 additions & 1 deletion Source/Chatbook/ToolManager.wl
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ toolModelWarning[ scope_, True ] := "";
toolModelWarning[ scope_, False ] := $toolsDisabledWarning;
toolModelWarning[ scope_, enabled_ ] := toolModelWarning[ scope, enabled, currentChatSettings[ scope, "Model" ] ];
toolModelWarning[ scope_, enabled_, model_? toolsEnabledQ ] := "";
toolModelWarning[ scope_, enabled_, model_String ] := toolModelWarning0[ scope, model ];
toolModelWarning[ scope_, enabled_, model_ ] := toolModelWarning0[ scope, model ];
toolModelWarning // endDefinition;


Expand All @@ -598,6 +598,11 @@ toolModelWarning0[ scope_, model_String ] := Enclose[
throwInternalFailure[ toolModelWarning0[ scope, model ], ## ] &
];

toolModelWarning0[ scope_, model: Except[ _String ] ] :=
With[ { name = toModelName @ model },
toolModelWarning0[ scope, name ] /; StringQ @ name
];

toolModelWarning0 // endDefinition;

(* ::**************************************************************************************************************:: *)
Expand Down

0 comments on commit 1b5e117

Please sign in to comment.