Skip to content

Commit

Permalink
Enable a tool when installing it
Browse files Browse the repository at this point in the history
  • Loading branch information
rhennigan committed Jan 24, 2024
1 parent db5e8c8 commit d3fcda2
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions Source/Chatbook/ResourceInstaller.wl
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ resourceInstall // endDefinition;
(*postInstall*)
postInstall // beginDefinition;
postInstall[ "Prompt", info_ ] := addToVisiblePersonas @ resourceName @ info;
postInstall[ "LLMTool", info_ ] := enableTool @ resourceName @ info;
postInstall[ rtype_, info_ ] := Null;
postInstall // endDefinition;

Expand All @@ -490,19 +491,33 @@ postInstall // endDefinition;
(*addToVisiblePersonas*)
addToVisiblePersonas // beginDefinition;

addToVisiblePersonas[ name_String ] := Set[
CurrentValue[ $FrontEnd, { PrivateFrontEndOptions, "InterfaceSettings", "Chatbook", "VisiblePersonas" } ],
addToVisiblePersonas[ name_String ] := CurrentChatSettings[ $FrontEnd, "VisiblePersonas" ] =
Union @ Append[
Replace[
CurrentValue[ $FrontEnd, { PrivateFrontEndOptions, "InterfaceSettings", "Chatbook", "VisiblePersonas" } ],
CurrentChatSettings[ $FrontEnd, "VisiblePersonas" ],
Except[ _List ] :> { }
],
name
]
];
];

addToVisiblePersonas // endDefinition;

(* ::**************************************************************************************************************:: *)
(* ::Subsubsubsection::Closed:: *)
(*enableTool*)
enableTool // beginDefinition;

enableTool[ name_String ] := CurrentChatSettings[ $FrontEnd, "ToolSelectionType" ] =
Append[
Replace[
Association @ CurrentChatSettings[ $FrontEnd, "ToolSelectionType" ],
Except[ _? AssociationQ ] :> <| |>
],
name -> All
];

enableTool // endDefinition;

(* ::**************************************************************************************************************:: *)
(* ::Subsubsection::Closed:: *)
(*resourceInstallLocation*)
Expand Down

0 comments on commit d3fcda2

Please sign in to comment.