Skip to content

Commit

Permalink
Merge pull request #1035 from WolframResearch/bugfix/more-serializati…
Browse files Browse the repository at this point in the history
…on-rules

More serialization rules
  • Loading branch information
rhennigan authored Jan 21, 2025
2 parents 9ac4277 + ec8e8b5 commit 98ae65e
Show file tree
Hide file tree
Showing 10 changed files with 469 additions and 89 deletions.
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"Deinitialization",
"Demi",
"Dirtiable",
"Docu",
"dpkg",
"EFAIL",
"ENDARGUMENTS",
Expand Down Expand Up @@ -79,6 +80,7 @@
"Subsubsubsection",
"Subsubsubsubsection",
"Subsubtitle",
"Subsuperscript",
"tabletags",
"tavily",
"textbf",
Expand Down
Binary file added Assets/TemplateBoxOptions.wxf
Binary file not shown.
13 changes: 7 additions & 6 deletions PacletInfo.wl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PacletObject[ <|
"Name" -> "Wolfram/Chatbook",
"PublisherID" -> "Wolfram",
"Version" -> "2.0.20",
"Version" -> "2.1.0",
"WolframVersion" -> "14.1+",
"Description" -> "Wolfram Notebooks + LLMs",
"License" -> "MIT",
Expand Down Expand Up @@ -34,11 +34,12 @@ PacletObject[ <|
{ "Asset",
"Root" -> "Assets",
"Assets" -> {
{ "AIAssistant" , "AIAssistant" },
{ "DisplayFunctions", "DisplayFunctions.wxf" },
{ "Icons" , "Icons.wxf" },
{ "SandboxMessages" , "SandboxMessages.wl" },
{ "Tokenizers" , "Tokenizers" }
{ "AIAssistant" , "AIAssistant" },
{ "DisplayFunctions" , "DisplayFunctions.wxf" },
{ "Icons" , "Icons.wxf" },
{ "SandboxMessages" , "SandboxMessages.wl" },
{ "TemplateBoxOptions", "TemplateBoxOptions.wxf" },
{ "Tokenizers" , "Tokenizers" }
}
},
{ "LLMConfiguration",
Expand Down
1 change: 1 addition & 0 deletions Source/Chatbook/CommonSymbols.wl
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ BeginPackage[ "Wolfram`Chatbook`Common`" ];
`$simpleToolMethod;
`$statelessProgressIndicator;
`$suppressButtonAppearance;
`$templateBoxOptionsCache;
`$timingLog;
`$tinyHashLength;
`$tokenBudget;
Expand Down
2 changes: 1 addition & 1 deletion Source/Chatbook/FrontEnd.wl
Original file line number Diff line number Diff line change
Expand Up @@ -1328,7 +1328,7 @@ rasterize // endDefinition;
(*replaceCellContext*)
replaceCellContext // beginDefinition;

replaceCellContext[ expr_ ] := replaceCellContext[ expr ] = ReplaceAll[
replaceCellContext[ expr_ ] := replaceCellContext[ Verbatim[ expr ] ] = ReplaceAll[
expr,
s_Symbol /; AtomQ @ Unevaluated @ s && Context @ Unevaluated @ s === "$CellContext`" :>
With[ { new = ToExpression[ $Context <> SymbolName @ Unevaluated @ s, InputForm, $ConditionHold ] },
Expand Down
2 changes: 2 additions & 0 deletions Source/Chatbook/Handlers.wl
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ applyHandlerFunction[ settings_Association, name_String, args0_ ] := Enclose[
args = ConfirmBy[
<|
"EventName" -> name,
(* FIXME: Add settings at start of evaluation instead of each function call *)
"ChatNotebookSettings" -> KeyDrop[ settings, $settingsDroppedKeys ],
args0
|>,
Expand Down Expand Up @@ -178,6 +179,7 @@ applyProcessingFunction[ settings_Association, name_String, args_HoldComplete, p
addProcessingArguments[
name,
<|
(* FIXME: Add settings at start of evaluation instead of each function call *)
"ChatNotebookSettings" -> KeyDrop[ settings, $settingsDroppedKeys ],
"DefaultProcessingFunction" -> default,
params
Expand Down
15 changes: 10 additions & 5 deletions Source/Chatbook/PromptGenerators/RelatedDocumentation.wl
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ Needs[ "Wolfram`Chatbook`PromptGenerators`Common`" ];
(* ::**************************************************************************************************************:: *)
(* ::Section::Closed:: *)
(*Configuration*)
$snippetType = "Text";
$documentationSnippetVersion = "14-1-0-10549042";
$baseURL = "https://www.wolframcloud.com/obj/wolframai-content/DocumentationSnippets";
$documentationSnippetBaseURL = URLBuild @ { $baseURL, $documentationSnippetVersion, $snippetType };
$resourceSnippetBaseURL = URLBuild @ { $baseURL, "Resources", $snippetType };
$snippetType = "Text";
$documentationSnippetVersion := $snippetVersion;
$baseURL = "https://www.wolframcloud.com/obj/wolframai-content/DocumentationSnippets";
$documentationSnippetBaseURL := URLBuild @ { $baseURL, $documentationSnippetVersion, $snippetType };
$resourceSnippetBaseURL = URLBuild @ { $baseURL, "Resources", $snippetType };

$documentationSnippetsCacheDirectory := $documentationSnippetsCacheDirectory =
ChatbookFilesDirectory @ { "DocumentationSnippets", "Documentation", $documentationSnippetVersion };
Expand Down Expand Up @@ -46,6 +46,11 @@ $unfilteredItemsPerSource = 10;

$filteringLLMConfig = <| "StopTokens" -> { "CasualChat" } |>;

(* ::**************************************************************************************************************:: *)
(* ::Subsection::Closed:: *)
(*$snippetVersion*)
$snippetVersion := $snippetVersion = If[ $VersionNumber >= 14.2, "14-2-0-11168610", "14-1-0-10549042" ];

(* ::**************************************************************************************************************:: *)
(* ::Section::Closed:: *)
(*Messages*)
Expand Down
16 changes: 9 additions & 7 deletions Source/Chatbook/PromptGenerators/VectorDatabases.wl
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ HoldComplete[
(* ::**************************************************************************************************************:: *)
(* ::Section::Closed:: *)
(*Configuration*)
$vectorDatabases = <|
"DataRepositoryURIs" -> <| "Version" -> "1.0.0", "Bias" -> 1.0, "SnippetFunction" -> getSnippets |>,
"DocumentationURIs" -> <| "Version" -> "1.3.0", "Bias" -> 0.0, "SnippetFunction" -> getSnippets |>,
"FunctionRepositoryURIs" -> <| "Version" -> "1.0.0", "Bias" -> 1.0, "SnippetFunction" -> getSnippets |>,
"WolframAlphaQueries" -> <| "Version" -> "1.3.0", "Bias" -> 0.0, "SnippetFunction" -> Identity |>
$vectorDatabases := $vectorDatabases = <|
"DataRepositoryURIs" -> <| "Version" -> "1.0.0" , "Bias" -> 1.0, "SnippetFunction" -> getSnippets |>,
"DocumentationURIs" -> <| "Version" -> $docVersion, "Bias" -> 0.0, "SnippetFunction" -> getSnippets |>,
"FunctionRepositoryURIs" -> <| "Version" -> "1.0.0" , "Bias" -> 1.0, "SnippetFunction" -> getSnippets |>,
"WolframAlphaQueries" -> <| "Version" -> "1.3.0" , "Bias" -> 0.0, "SnippetFunction" -> Identity |>
|>;

$vectorDBNames = Keys @ $vectorDatabases;
$docVersion := If[ $VersionNumber >= 14.2, "1.4.0", "1.3.0" ];

$vectorDBNames := $vectorDBNames = Keys @ $vectorDatabases;
$allowDownload = True;
$cacheEmbeddings = True;

Expand All @@ -48,7 +50,7 @@ $maxExtraFiles = 20;
(*Remote Content Locations*)
$baseVectorDatabasesURL = "https://www.wolframcloud.com/obj/wolframai-content/VectorDatabases";

$vectorDBDownloadURLs = AssociationMap[
$vectorDBDownloadURLs := $vectorDBDownloadURLs = AssociationMap[
URLBuild @ { $baseVectorDatabasesURL, #, $vectorDatabases[ #, "Version" ], # <> ".zip" } &,
$vectorDBNames
];
Expand Down
Loading

0 comments on commit 98ae65e

Please sign in to comment.