Skip to content

Commit 99ea47f

Browse files
authored
Merge pull request #993 from WolframResearch/feature/workspace-chat-conversion
Add ConvertChatNotebook
2 parents 15c6381 + 0c2a164 commit 99ea47f

File tree

5 files changed

+308
-73
lines changed

5 files changed

+308
-73
lines changed

PacletInfo.wl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PacletObject[ <|
22
"Name" -> "Wolfram/Chatbook",
33
"PublisherID" -> "Wolfram",
4-
"Version" -> "2.0.6",
4+
"Version" -> "2.0.7",
55
"WolframVersion" -> "14.1+",
66
"Description" -> "Wolfram Notebooks + LLMs",
77
"License" -> "MIT",

Source/Chatbook/ChatModes/UI.wl

Lines changed: 2 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,6 +1309,8 @@ assistantActionMenuItem // endDefinition
13091309
(* ::Section::Closed:: *)
13101310
(*Chat Notebook Conversion*)
13111311

1312+
(* TODO: move more of this conversion functionality to ConvertChatNotebook *)
1313+
13121314
(* ::**************************************************************************************************************:: *)
13131315
(* ::Subsection::Closed:: *)
13141316
(*popOutWorkspaceChatNB*)
@@ -1448,77 +1450,6 @@ popOutChatNB0[ id_, settings_Association ] := Enclose[
14481450

14491451
popOutChatNB0 // endDefinition;
14501452

1451-
(* ::**************************************************************************************************************:: *)
1452-
(* ::Subsubsection::Closed:: *)
1453-
(*cellsToChatNB*)
1454-
cellsToChatNB // beginDefinition;
1455-
1456-
cellsToChatNB[ cells: { ___Cell } ] :=
1457-
Notebook[ cells /. $fromWorkspaceChatConversionRules, StyleDefinitions -> "Chatbook.nb" ];
1458-
1459-
cellsToChatNB[ cells: { ___Cell }, settings_Association ] :=
1460-
Module[ { dingbat, notebook },
1461-
1462-
dingbat = Cell[ BoxData @ makeOutputDingbat @ settings, Background -> None ];
1463-
notebook = updateCellDingbats[ cellsToChatNB @ cells, dingbat ];
1464-
1465-
Append[
1466-
notebook,
1467-
TaggingRules -> <| "ChatNotebookSettings" -> KeyTake[ settings, $popOutSettings ] |>
1468-
]
1469-
];
1470-
1471-
cellsToChatNB // endDefinition;
1472-
1473-
1474-
$popOutSettings = {
1475-
"LLMEvaluator",
1476-
"MaxContextTokens",
1477-
"MaxToolResponses",
1478-
"Model"
1479-
};
1480-
1481-
(* TODO: we should really have something better for this *)
1482-
$evaluatedChatInputDingbat = Cell[
1483-
BoxData @ DynamicBox @ ToBoxes[
1484-
If[ TrueQ @ CloudSystem`$CloudNotebooks,
1485-
RawBoxes @ TemplateBox[ { }, "ChatIconUser" ],
1486-
RawBoxes @ TemplateBox[ { }, "ChatInputCellDingbat" ]
1487-
],
1488-
StandardForm
1489-
],
1490-
Background -> None,
1491-
CellFrame -> 0,
1492-
CellMargins -> 0
1493-
];
1494-
1495-
1496-
$fromWorkspaceChatConversionRules := $fromWorkspaceChatConversionRules = Dispatch @ {
1497-
Cell[ BoxData @ TemplateBox[ { Cell[ TextData[ text_ ], ___ ] }, "UserMessageBox", ___ ], "ChatInput", ___ ] :>
1498-
Cell[ Flatten @ TextData @ text, "ChatInput" ]
1499-
,
1500-
Cell[ BoxData @ TemplateBox[ { text_ }, "UserMessageBox", ___ ], "ChatInput", ___ ] :>
1501-
Cell[ Flatten @ TextData @ text, "ChatInput" ]
1502-
,
1503-
Cell[ BoxData @ TemplateBox[ { Cell[ text_, ___ ] }, "AssistantMessageBox", ___ ], "ChatOutput", ___ ] :>
1504-
Cell[ Flatten @ TextData @ text, "ChatOutput" ]
1505-
};
1506-
1507-
(* ::**************************************************************************************************************:: *)
1508-
(* ::Subsubsection::Closed:: *)
1509-
(*updateCellDingbats*)
1510-
updateCellDingbats // beginDefinition;
1511-
1512-
updateCellDingbats[ cells_, outputDingbat_ ] := ReplaceAll[
1513-
cells,
1514-
{
1515-
Cell[ a__, "ChatInput" , b___ ] :> Cell[ a, "ChatInput" , b, CellDingbat -> $evaluatedChatInputDingbat ],
1516-
Cell[ a__, "ChatOutput", b___ ] :> Cell[ a, "ChatOutput", b, CellDingbat -> outputDingbat ]
1517-
}
1518-
];
1519-
1520-
updateCellDingbats // endDefinition;
1521-
15221453
(* ::**************************************************************************************************************:: *)
15231454
(* ::Section::Closed:: *)
15241455
(*Overlay Menus*)
@@ -2207,7 +2138,6 @@ $workspaceChatProgressBar = With[
22072138
(* ::Section::Closed:: *)
22082139
(*Package Footer*)
22092140
addToMXInitialization[
2210-
$fromWorkspaceChatConversionRules;
22112141
$inlineToWorkspaceConversionRules;
22122142
$defaultUserImage;
22132143
$smallNotebookIcon;

Source/Chatbook/CommonSymbols.wl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ BeginPackage[ "Wolfram`Chatbook`Common`" ];
118118
`cellPrint;
119119
`cellPrintAfter;
120120
`cellReference;
121+
`cellsToChatNB;
121122
`cellStyles;
122123
`channelCleanup;
123124
`chatExcludedQ;
@@ -216,6 +217,8 @@ BeginPackage[ "Wolfram`Chatbook`Common`" ];
216217
`makeCellStringBudget;
217218
`makeChatCloudDockedCellContents;
218219
`makeChatMessages;
220+
`makeChatNotebookOptions;
221+
`makeChatNotebookSettings;
219222
`makeExpressionURI;
220223
`makeFailureString;
221224
`makeInteractiveCodeCell;
@@ -309,6 +312,7 @@ BeginPackage[ "Wolfram`Chatbook`Common`" ];
309312
`trackedDynamic;
310313
`truncateString;
311314
`unsetCV;
315+
`updateCellDingbats;
312316
`updateDynamics;
313317
`userMessageBox;
314318
`userMessageLabel;

0 commit comments

Comments
 (0)