@@ -1380,7 +1380,7 @@ SaveAsChatNotebook // endExportedDefinition;
1380
1380
saveAsChatNB // beginDefinition ;
1381
1381
1382
1382
saveAsChatNB [ targetObj_ NotebookObject ] := Enclose [
1383
- Catch @ Module [ { cellObjects , title , filepath , cells , nbExpr },
1383
+ Catch @ Module [ { cellObjects , title , filepath , cells , settings , nbExpr },
1384
1384
cellObjects = Cells @ targetObj ;
1385
1385
If [ ! MatchQ [ cellObjects , { __ CellObject } ], Throw @ Null ];
1386
1386
title = Replace [
@@ -1400,7 +1400,8 @@ saveAsChatNB[ targetObj_NotebookObject ] := Enclose[
1400
1400
StringQ @ filepath && StringEndsQ [ filepath , ".nb" ],
1401
1401
cells = NotebookRead @ cellObjects ;
1402
1402
If [ ! MatchQ [ cells , { __ Cell } ], Throw @ Null ];
1403
- nbExpr = ConfirmMatch [ cellsToChatNB @ cells , _ Notebook , "Converted" ];
1403
+ settings = CurrentChatSettings @ targetObj ;
1404
+ nbExpr = ConfirmMatch [ cellsToChatNB [ cells , settings ], _ Notebook , "Converted" ];
1404
1405
ConfirmBy [ Export [ filepath , nbExpr , "NB" ], FileExistsQ , "Exported" ],
1405
1406
True ,
1406
1407
Null
@@ -1415,24 +1416,25 @@ saveAsChatNB // endDefinition;
1415
1416
(* ::Subsection::Closed:: *)
1416
1417
(*popOutChatNB*)
1417
1418
popOutChatNB // beginDefinition ;
1418
- popOutChatNB [ nbo_ NotebookObject ] := popOutChatNB @ NotebookGet @ nbo ;
1419
- popOutChatNB [ Notebook [ cells_ , ___ ] ] := popOutChatNB @ cells ;
1420
- popOutChatNB [ Dynamic [ messageList_ ] ] := popOutChatNB @ messageList ;
1421
- popOutChatNB [ cells : { ___ Cell } ] := NotebookPut @ cellsToChatNB @ cells ;
1422
- popOutChatNB [ chat_ Association ] := popOutChatNB0 @ chat ;
1419
+ popOutChatNB [ nbo_ NotebookObject ] := popOutChatNB [ NotebookGet @ nbo , CurrentChatSettings @ nbo ];
1420
+ popOutChatNB [ Notebook [ cells_ , ___ ], settings_ ] := popOutChatNB [ cells , settings ];
1421
+ popOutChatNB [ cells : { ___ Cell }, settings_ ] := NotebookPut @ cellsToChatNB [ cells , settings ];
1422
+ popOutChatNB [ chat_ Association , settings_ Association ] := popOutChatNB0 [ chat , settings ];
1423
1423
popOutChatNB // endDefinition ;
1424
1424
1425
1425
1426
1426
popOutChatNB0 // beginDefinition ;
1427
1427
1428
- popOutChatNB0 [ id_ ] := Enclose [
1429
- Module [ { loaded , uuid , title , messages , cells },
1428
+ popOutChatNB0 [ id_ , settings_ Association ] := Enclose [
1429
+ Module [ { loaded , uuid , title , messages , dingbat , cells , options },
1430
1430
loaded = ConfirmBy [ LoadChat @ id , AssociationQ , "Loaded" ];
1431
1431
uuid = ConfirmBy [ loaded [ "ConversationUUID" ], StringQ , "UUID" ];
1432
1432
title = ConfirmBy [ loaded [ "ConversationTitle" ], StringQ , "Title" ];
1433
1433
messages = ConfirmBy [ loaded [ "Messages" ], ListQ , "Messages" ];
1434
- cells = ConfirmMatch [ ChatMessageToCell @ messages , { __ Cell }, "Cells" ];
1435
- ConfirmMatch [ CreateChatNotebook @ cells , _ NotebookObject , "Notebook" ]
1434
+ dingbat = Cell [ BoxData @ makeOutputDingbat @ settings , Background -> None ];
1435
+ cells = ConfirmMatch [ updateCellDingbats [ ChatMessageToCell @ messages , dingbat ], { __ Cell }, "Cells" ];
1436
+ options = Sequence @@ Normal [ settings , Association ];
1437
+ ConfirmMatch [ CreateChatNotebook [ cells , options ], _ NotebookObject , "Notebook" ]
1436
1438
],
1437
1439
throwInternalFailure
1438
1440
];
@@ -1447,9 +1449,43 @@ cellsToChatNB // beginDefinition;
1447
1449
cellsToChatNB [ cells : { ___ Cell } ] :=
1448
1450
Notebook [ cells /. $fromWorkspaceChatConversionRules , StyleDefinitions -> "Chatbook.nb" ];
1449
1451
1452
+ cellsToChatNB [ cells : { ___ Cell }, settings_ Association ] :=
1453
+ Module [ { dingbat , notebook },
1454
+
1455
+ dingbat = Cell [ BoxData @ makeOutputDingbat @ settings , Background -> None ];
1456
+ notebook = updateCellDingbats [ cellsToChatNB @ cells , dingbat ];
1457
+
1458
+ Append [
1459
+ notebook ,
1460
+ TaggingRules -> < | "ChatNotebookSettings" -> KeyTake [ settings , $popOutSettings ] |>
1461
+ ]
1462
+ ];
1463
+
1450
1464
cellsToChatNB // endDefinition ;
1451
1465
1452
1466
1467
+ $popOutSettings = {
1468
+ "LLMEvaluator" ,
1469
+ "MaxContextTokens" ,
1470
+ "MaxToolResponses" ,
1471
+ "Model"
1472
+ };
1473
+
1474
+ (* TODO: we should really have something better for this *)
1475
+ $evaluatedChatInputDingbat = Cell [
1476
+ BoxData @ DynamicBox @ ToBoxes [
1477
+ If [ TrueQ @ CloudSystem ` $CloudNotebooks ,
1478
+ RawBoxes @ TemplateBox [ { }, "ChatIconUser" ],
1479
+ RawBoxes @ TemplateBox [ { }, "ChatInputCellDingbat" ]
1480
+ ],
1481
+ StandardForm
1482
+ ],
1483
+ Background -> None ,
1484
+ CellFrame -> 0 ,
1485
+ CellMargins -> 0
1486
+ ];
1487
+
1488
+
1453
1489
$fromWorkspaceChatConversionRules := $fromWorkspaceChatConversionRules = Dispatch @ {
1454
1490
Cell [ BoxData @ TemplateBox [ { Cell [ TextData [ text_ ], ___ ] }, "UserMessageBox" , ___ ], "ChatInput" , ___ ] :>
1455
1491
Cell [ Flatten @ TextData @ text , "ChatInput" ]
@@ -1461,6 +1497,21 @@ $fromWorkspaceChatConversionRules := $fromWorkspaceChatConversionRules = Dispatc
1461
1497
Cell [ Flatten @ TextData @ text , "ChatOutput" ]
1462
1498
};
1463
1499
1500
+ (* ::**************************************************************************************************************:: *)
1501
+ (* ::Subsubsection::Closed:: *)
1502
+ (*updateCellDingbats*)
1503
+ updateCellDingbats // beginDefinition ;
1504
+
1505
+ updateCellDingbats [ cells_ , outputDingbat_ ] := ReplaceAll [
1506
+ cells ,
1507
+ {
1508
+ Cell [ a__ , "ChatInput" , b___ ] :> Cell [ a , "ChatInput" , b , CellDingbat -> $evaluatedChatInputDingbat ],
1509
+ Cell [ a__ , "ChatOutput" , b___ ] :> Cell [ a , "ChatOutput" , b , CellDingbat -> outputDingbat ]
1510
+ }
1511
+ ];
1512
+
1513
+ updateCellDingbats // endDefinition ;
1514
+
1464
1515
(* ::**************************************************************************************************************:: *)
1465
1516
(* ::Section::Closed:: *)
1466
1517
(*Overlay Menus*)
@@ -1977,7 +2028,7 @@ makeHistoryMenuItem[ Dynamic[ rows_ ], nbo_NotebookObject, chat_Association ] :=
1977
2028
{ {
1978
2029
Button [
1979
2030
$popOutButtonLabel ,
1980
- popOutChatNB @ chat ,
2031
+ popOutChatNB [ chat , CurrentChatSettings @ nbo ] ,
1981
2032
Appearance -> "Suppressed"
1982
2033
],
1983
2034
Button [
0 commit comments