Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ Assets/VectorDatabases/**/*.wl
Assets/VectorDatabases/**/*.wxf
build
Developer/VectorDatabases/SourceData/*.jsonl
Source/Chatbook/64Bit/Chatbook.mx
Source/Chatbook/64Bit/Chatbook.mx
.claude/
45 changes: 32 additions & 13 deletions Source/Chatbook/ChatModes/ShowNotebookAssistance.wl
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ ShowNotebookAssistance // Options = {
"EvaluateInput" -> False,
"ExtraInstructions" -> None,
"Input" -> "",
"NewChat" -> Automatic
"NewChat" -> Automatic,
"NotebookOptions" -> { } (* TODO: pass any notebook options specified here to the created notebook *)
};

(* ::**************************************************************************************************************:: *)
Expand All @@ -178,10 +179,12 @@ ShowNotebookAssistance[obj$, \"type$\"] shows code assistance of the specified t
| ExtraInstructions | None | Additional instructions to include in the system prompt for the LLM |
| Input | None | The initial chat input string or Key[\"name$\"] to reference a predefined input |
| NewChat | Automatic | Whether to start a new chat |
| NotebookOptions | { } | A list of rules to be applied to the notebook created for the code assistance |
* If EvaluateInput is True, a value must be given for Input or InputName.
* Specifying NewChat \[Rule] True will clear the existing code assistance chat (if any).
* The setting for NewChat has no effect for Inline code assistance.
* Possible values for \"name$\" in Key[\"name$\"] can be found in Keys[$NotebookAssistanceInputs].\
* Possible values for \"name$\" in Key[\"name$\"] can be found in Keys[$NotebookAssistanceInputs].
* NotebookOptions allows you to customize the appearance and behavior of the created notebook.\
" ];

(* ::**************************************************************************************************************:: *)
Expand Down Expand Up @@ -469,8 +472,10 @@ showNotebookAssistanceWindow[ source_, input_, evaluate_, new_, settings_Associa
];

showNotebookAssistanceWindow[ source_NotebookObject, input_, evaluate_, new_ ] := Enclose[
Module[ { current, nbo, movedLastChatToSourcesIndicatorQ },

Module[ { current, nbo, movedLastChatToSourcesIndicatorQ, nbOptions },

nbOptions = OptionValue[ ShowNotebookAssistance, "NotebookOptions" ];

current = ConfirmMatch[
LogChatTiming @ findCurrentWorkspaceChat[ "NotebookAssistance" ],
_NotebookObject | Missing[ "NotFound" ],
Expand All @@ -485,7 +490,7 @@ showNotebookAssistanceWindow[ source_NotebookObject, input_, evaluate_, new_ ] :
];

nbo = If[ MissingQ @ current,
ConfirmMatch[ LogChatTiming @ createWorkspaceChat @ source, _NotebookObject, "New" ],
ConfirmMatch[ LogChatTiming @ createWorkspaceChat[ source, nbOptions ], _NotebookObject, "New" ],
ConfirmMatch[ LogChatTiming @ attachToLeft[ source, current ], _NotebookObject, "Attached" ]
];

Expand Down Expand Up @@ -516,7 +521,9 @@ showNotebookAssistanceWindow[ source_NotebookObject, input_, evaluate_, new_ ] :


showNotebookAssistanceWindow[ None, input_, evaluate_, new_ ] := Enclose[
Module[ { current, nbo },
Module[ { current, nbo, nbOptions },

nbOptions = OptionValue[ ShowNotebookAssistance, "NotebookOptions" ];

current = ConfirmMatch[
findCurrentWorkspaceChat[ "NotebookAssistance" ],
Expand All @@ -530,7 +537,7 @@ showNotebookAssistanceWindow[ None, input_, evaluate_, new_ ] := Enclose[
];

nbo = If[ MissingQ @ current,
ConfirmMatch[ createWorkspaceChat[ ], _NotebookObject, "New" ],
ConfirmMatch[ createWorkspaceChat[ nbOptions ], _NotebookObject, "New" ],
current
];

Expand Down Expand Up @@ -710,10 +717,15 @@ createWorkspaceChat // beginDefinition;
createWorkspaceChat[ ] :=
createWorkspaceChat[ { } ];

createWorkspaceChat[ cells: { ___Cell } ] := Enclose[
Module[ { nbo },
createWorkspaceChat[ cells: { ___Cell } ] :=
createWorkspaceChat[ cells, { } ];

createWorkspaceChat[ cells: { ___Cell }, options: { ___Rule } ] := Enclose[
Module[ { nbo, nbOptions },
nbOptions = Flatten @ { $workspaceChatNotebookOptions, options };

nbo = ConfirmMatch[
NotebookPut @ Notebook[ cells, $workspaceChatNotebookOptions ],
NotebookPut @ Notebook[ cells, nbOptions ],
_NotebookObject,
"Notebook"
];
Expand All @@ -732,11 +744,18 @@ createWorkspaceChat[ cells: { ___Cell } ] := Enclose[
createWorkspaceChat[ source_NotebookObject ] :=
createWorkspaceChat[ source, { } ];

createWorkspaceChat[ source_NotebookObject, cells: { ___Cell } ] := Enclose[
Module[ { nbo },
createWorkspaceChat[ source_NotebookObject, options: { ___Rule } ] :=
createWorkspaceChat[ source, { }, options ];

createWorkspaceChat[ source_NotebookObject, cells: { ___Cell } ] :=
createWorkspaceChat[ source, cells, { } ];

createWorkspaceChat[ source_NotebookObject, cells: { ___Cell }, options: { ___Rule } ] := Enclose[
Module[ { nbo, nbOptions },
nbOptions = Flatten @ { $workspaceChatNotebookOptions, options };

nbo = ConfirmMatch[
NotebookPut @ Notebook[ cells, $workspaceChatNotebookOptions ],
NotebookPut @ Notebook[ cells, nbOptions ],
_NotebookObject,
"Notebook"
];
Expand Down
Loading