Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Major update to support additional persona customizations #608

Merged
merged 72 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
0021a13
Support `"Hidden" -> True` in a persona specification, which makes it…
rhennigan Feb 5, 2024
fff9ad2
Allow more settings to be set by the persona spec
rhennigan Feb 5, 2024
e38b755
Bugfix: ensure tools remain selected
rhennigan Feb 6, 2024
533846a
Add `FormatToolCall` to the available processing functions for custom…
rhennigan Feb 6, 2024
bd41428
More misc serialization improvements for definition notebooks
rhennigan Feb 6, 2024
526c9c5
Added `$AutomaticAssistance` which gives `True` when a chat evaluatio…
rhennigan Feb 7, 2024
74e3229
Added "TokenBudgetMultiplier" setting which can be used to scale down…
rhennigan Feb 7, 2024
ba65400
Bugfix: add unhandled argument pattern for `cutMessageContent`
rhennigan Feb 7, 2024
17dbf29
Bugfix: Blocking `$enableLLMServices` without a value prevented it fr…
rhennigan Feb 7, 2024
8c819e6
Make sure persona intialization runs before any other delayed values
rhennigan Feb 7, 2024
d1201ad
Handle zero width space hack
rhennigan Feb 7, 2024
7505a2d
Merge remote-tracking branch 'origin/main' into feature/additional-pe…
rhennigan Feb 8, 2024
e8de38a
Bugfix: Raw model should not get tool prompting
rhennigan Feb 9, 2024
0589707
Bugfix: use chat state in `GetChatHistory`
rhennigan Feb 9, 2024
147de9c
Bugfix: Setting BasePrompt to `None` should not disable tools
rhennigan Feb 9, 2024
8dedbeb
Resolve token budget multiplier
rhennigan Feb 9, 2024
c956b0a
WIP support for a simpler tool calling syntax that uses less tokens
rhennigan Feb 9, 2024
015529c
Allow user to specify additional stop tokens and choose correct tool …
rhennigan Feb 9, 2024
ea50a32
Minor organization changes
rhennigan Feb 9, 2024
236d068
simple tool syntax parsing
rhennigan Feb 10, 2024
2740a7a
Rename "Command" property to "ShortName"
rhennigan Feb 10, 2024
e22fcc9
Better name for W|A query parameter
rhennigan Feb 10, 2024
43209d8
Bugfix: Respect "AutoFormat" setting when writing dynamic splits
rhennigan Feb 10, 2024
94504b7
Token optimization: shorter hash strings
rhennigan Feb 10, 2024
bae3e63
Bugfix: Do not wait for tool response to start streaming to update dy…
rhennigan Feb 10, 2024
7cd45b1
Bugfix: Missed some "input" -> "query" renaming
rhennigan Feb 12, 2024
467c35d
Bugfix: Update string patterns to handle new hash IDs
rhennigan Feb 12, 2024
25a0d68
Bugfix: Allow `Failure[...]` in `FormatToolCall`, since it's handled …
rhennigan Feb 12, 2024
a38dd2b
Tool call formatter improvements
rhennigan Feb 12, 2024
f32f8bc
Bugfix: Some W|A graphics content is represented as `RawBoxes[...]` i…
rhennigan Feb 12, 2024
f001915
Make `toolFreeQ` a two-argument function that takes settings as the f…
rhennigan Feb 12, 2024
3b9c88c
Make chat settings immediately available in `$ChatHandlerData` to sim…
rhennigan Feb 12, 2024
a85a1f7
TODO: create a `$CurrentChatSettings` symbol
rhennigan Feb 12, 2024
9f64a6e
Optimized W|A outputs to reduce FE overhead
rhennigan Feb 12, 2024
d2e4e62
Ensure dynamic text is updated before spending time on a tool call
rhennigan Feb 12, 2024
6b90441
Debugging an issue with `CreateChatNotebook` sometimes returning `$Fa…
rhennigan Feb 13, 2024
e447aca
WIP: simple tool syntax parsing
rhennigan Feb 13, 2024
8c2ac5e
Customizable tool prompt components
rhennigan Feb 14, 2024
0cf2a16
Merge branch 'main' into feature/additional-persona-customizations
rhennigan Feb 14, 2024
61173aa
W|A pod tweaks
rhennigan Feb 15, 2024
2ccb136
Bugfix: Generate a sensible string for sandbox output forms
rhennigan Feb 15, 2024
a1b1722
Bugfix: `CellObject[uuid]` does not give a usable cell object in cloud
rhennigan Feb 15, 2024
d4d99ed
Added `nextCell` and `previousCell` that work in cloud
rhennigan Feb 15, 2024
b7e3a3d
Bugfix: Make cloud tagging rules inheritence fix version independent
rhennigan Feb 15, 2024
1063b6f
Merge branch 'main' into feature/additional-persona-customizations
rhennigan Feb 15, 2024
68162a3
Merge branch 'main' into feature/additional-persona-customizations
rhennigan Feb 16, 2024
2a5d938
Moved template arg pattern to common context
rhennigan Feb 19, 2024
958162e
Remove `CellSize` spec from pods to allow text reflow on narrow views
rhennigan Feb 19, 2024
c71d139
Fix a common TeX mistake by the LLM
rhennigan Feb 19, 2024
5239785
Allow more prompt types to be specified in the LLMConfiguration direc…
rhennigan Feb 19, 2024
b7c4707
Added "SetCellDingbat" setting
rhennigan Feb 19, 2024
087c615
Add `Authentication` to chat settings
rhennigan Feb 21, 2024
4947736
Export `insertCodeBelow` as a chatbook action
rhennigan Feb 22, 2024
41a9181
Workaround for `CellTags` issue in cloud notebooks
rhennigan Feb 22, 2024
8d36546
When inserting code, insert before the current cell if the user selec…
rhennigan Feb 22, 2024
163d9cd
Serialize WANE input cells
rhennigan Feb 22, 2024
9336fee
Include full URL in TextRefLink template boxes to open links in new t…
rhennigan Feb 22, 2024
6811dc1
Added an option to specify a target cloud object when creating a chat…
rhennigan Feb 23, 2024
1f9ddac
Bugfix: Missing argument pattern
rhennigan Feb 23, 2024
c02666e
Ensure _some_ content from the chat input cell is used, even if token…
rhennigan Feb 23, 2024
a550143
Clean up some extra unnecessary whitespace in system prompts
rhennigan Feb 23, 2024
8b8f014
Avoid autoload and `CloudObject[]` resolution when unnecessary
rhennigan Feb 23, 2024
908abc2
Bugfix: tool post prompt was out of order
rhennigan Feb 23, 2024
28e4564
Bugfix: don't tell the LLM to use documentation_searcher when it's no…
rhennigan Feb 23, 2024
b0cd078
Avoid line breaks in message text
rhennigan Feb 23, 2024
1daa10f
Bugfix: Include messages in the output of the cloud sandbox evaluator
rhennigan Feb 23, 2024
7e5c969
Include definitions in sandbox evaluations
rhennigan Feb 27, 2024
ee15bfd
Reinitialize atomic `Rational[...]` expressions after deserializing
rhennigan Feb 27, 2024
5a020c1
Emulate a persistent kernel with the cloud sandbox evaluator by passi…
rhennigan Feb 27, 2024
a38daf9
Bugfix: UTF8 conversion of tool calls was backwards
rhennigan Feb 27, 2024
a7dc311
Workaround: `TeXAssistant` doesn't handle UTF8 characters, so replace…
rhennigan Feb 27, 2024
5d198b1
Testing workaround for cloud rasterize issue
rhennigan Mar 5, 2024
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
2 changes: 1 addition & 1 deletion Developer/Resources/Styles.wl
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ Cell[
CounterIncrements -> { "ChatInputCount" },
Evaluatable -> True,
MenuSortingValue -> 1543,
StyleKeyMapping -> { "~" -> "ChatDelimiter", "'" -> "SideChat" },
StyleKeyMapping -> { "~" -> "ChatDelimiter", "'" -> "SideChat", "=" -> "WolframAlphaShort", "*" -> "Item" },
TaggingRules -> <| "ChatNotebookSettings" -> <| |> |>,
CellDingbat -> Cell[
BoxData @ DynamicBox @ ToBoxes[
Expand Down
3 changes: 2 additions & 1 deletion LLMConfiguration/Personas/RawModel/LLMConfiguration.wl
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"BasePrompt" -> None,
"DisplayName" -> "Raw Model",
"Icon" -> RawBoxes @ TemplateBox[ { }, "PersonaRawModel" ],
"Description" -> "No custom prompting, just the raw LLM"
"Description" -> "No custom prompting, just the raw LLM",
"Tools" -> None
|>
2 changes: 1 addition & 1 deletion PacletInfo.wl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PacletObject[ <|
"Name" -> "Wolfram/Chatbook",
"PublisherID" -> "Wolfram",
"Version" -> "1.4.4",
"Version" -> "1.4.5",
"WolframVersion" -> "13.3+",
"Description" -> "Wolfram Notebooks + LLMs",
"License" -> "MIT",
Expand Down
37 changes: 28 additions & 9 deletions Source/Chatbook/Actions.wl
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ BeginPackage[ "Wolfram`Chatbook`Actions`" ];
`WidgetSend;

`$alwaysOpen;
`$autoAssistMode;
`$autoOpen;
`$chatState;
`$finalCell;
`$lastCellObject;
`$lastChatString;
Expand All @@ -34,6 +34,7 @@ BeginPackage[ "Wolfram`Chatbook`Actions`" ];
`standardizeMessageKeys;
`systemCredential;
`toAPIKey;
`withChatState;

Begin[ "`Private`" ];

Expand Down Expand Up @@ -102,6 +103,7 @@ ChatbookAction[ "EvaluateChatInput" , args___ ] := catchMine @ EvaluateChatIn
ChatbookAction[ "ExclusionToggle" , args___ ] := catchMine @ ExclusionToggle @ args;
ChatbookAction[ "ExplodeDuplicate" , args___ ] := catchMine @ ExplodeDuplicate @ args;
ChatbookAction[ "ExplodeInPlace" , args___ ] := catchMine @ ExplodeInPlace @ args;
ChatbookAction[ "InsertCodeBelow", args___ ] := catchMine @ insertCodeBelow @ args;
ChatbookAction[ "InsertInlineReference", args___ ] := catchMine @ InsertInlineReference @ args;
ChatbookAction[ "OpenChatBlockSettings", args___ ] := catchMine @ OpenChatBlockSettings @ args;
ChatbookAction[ "OpenChatMenu" , args___ ] := catchMine @ OpenChatMenu @ args;
Expand Down Expand Up @@ -404,11 +406,12 @@ EvaluateChatInput[ source: _CellObject | $Failed ] :=
EvaluateChatInput @ evalCell /; chatInputCellQ @ evalCell
];

(* TODO: resolve auto settings here and set as a Block symbol *)
EvaluateChatInput[ evalCell_CellObject, nbo_NotebookObject ] :=
EvaluateChatInput[ evalCell, nbo, currentChatSettings @ evalCell ];
withChatState @ EvaluateChatInput[ evalCell, nbo, resolveAutoSettings @ currentChatSettings @ evalCell ];

EvaluateChatInput[ evalCell_CellObject, nbo_NotebookObject, settings_Association? AssociationQ ] :=
withChatState @ Block[ { $autoAssistMode = False, $aborted = False },
withChatState @ Block[ { $AutomaticAssistance = False, $aborted = False },
$lastCellObject = None;
$lastChatString = None;
$lastMessages = None;
Expand Down Expand Up @@ -594,9 +597,15 @@ AIAutoAssist[ cell_CellObject ] :=
];

AIAutoAssist[ cell_CellObject, nbo_NotebookObject ] := withChatState @
If[ autoAssistQ[ cell, nbo ],
Block[ { $autoAssistMode = True }, needsBasePrompt[ "AutoAssistant" ]; SendChat @ cell ],
Null
Module[ { settings },
settings = resolveAutoSettings @ currentChatSettings @ cell;
If[ autoAssistQ @ settings,
Block[ { $AutomaticAssistance = True },
needsBasePrompt[ "AutoAssistant" ];
SendChat[ cell, parentNotebook @ cell, settings ]
],
Null
]
];

AIAutoAssist // endDefinition;
Expand All @@ -606,6 +615,9 @@ AIAutoAssist // endDefinition;
(*autoAssistQ*)
autoAssistQ // beginDefinition;

autoAssistQ[ settings_Association ] :=
TrueQ @ settings[ "Assistance" ];

autoAssistQ[ cell_CellObject, nbo_NotebookObject ] :=
autoAssistQ @ cell;

Expand Down Expand Up @@ -1056,7 +1068,7 @@ excludeChatCells // endDefinition;
WidgetSend // beginDefinition;

WidgetSend[ cell_CellObject ] := withChatState @
Block[ { $alwaysOpen = True, cellPrint = cellPrintAfter @ cell, $finalCell = cell, $autoAssistMode = True },
Block[ { $alwaysOpen = True, cellPrint = cellPrintAfter @ cell, $finalCell = cell, $AutomaticAssistance = True },
(* TODO: this is currently the only UI method to turn this back on *)
CurrentValue[ parentNotebook @ cell, { TaggingRules, "ChatNotebookSettings", "Assistance" } ] = True;
SendChat @ cell
Expand Down Expand Up @@ -1128,7 +1140,7 @@ SendChat[ evalCell_CellObject ] := SendChat[ evalCell, parentNotebook @ evalCell
SendChat[ evalCell_CellObject, nbo_NotebookObject? queuedEvaluationsQ ] := Null;

SendChat[ evalCell_CellObject, nbo_NotebookObject ] :=
SendChat[ evalCell, nbo, currentChatSettings @ evalCell ];
withChatState @ SendChat[ evalCell, nbo, resolveAutoSettings @ currentChatSettings @ evalCell ];

SendChat[ evalCell_CellObject, nbo_NotebookObject, settings_Association? AssociationQ ] :=
SendChat[ evalCell, nbo, settings, Lookup[ settings, "ShowMinimized", Automatic ] ];
Expand Down Expand Up @@ -1377,8 +1389,15 @@ $apiKeyDialogDescription := $apiKeyDialogDescription = Get @ FileNameJoin @ {
withChatState // beginDefinition;
withChatState // Attributes = { HoldFirst };

(* TODO: create a `$CurrentChatSettings` symbol that's scoped here and defined as soon as settings are resolved *)
withChatState[ eval_ ] :=
Block[ { $enableLLMServices },
Block[
{
$AutomaticAssistance = False,
$chatState = True,
$enableLLMServices = Automatic,
withChatState = # &
},
$ChatHandlerData = <| |>;
withToolBox @ withBasePromptBuilder @ eval
];
Expand Down
3 changes: 2 additions & 1 deletion Source/Chatbook/ChatHistory.wl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ HoldComplete[
Begin[ "`Private`" ];

Needs[ "Wolfram`Chatbook`" ];
Needs[ "Wolfram`Chatbook`Actions`" ];
Needs[ "Wolfram`Chatbook`ChatMessages`" ];
Needs[ "Wolfram`Chatbook`Common`" ];
Needs[ "Wolfram`Chatbook`FrontEnd`" ];
Expand Down Expand Up @@ -66,7 +67,7 @@ GetChatHistory[ cell_CellObject, "CellObjects" ] :=
catchMine @ getCellsInChatHistory @ cell;

GetChatHistory[ cell_CellObject, property: $$historyProperty ] := catchMine @ Enclose[
Module[ { cells, data, as },
withChatState @ Module[ { cells, data, as },
{ cells, data } = Reap[ getCellsInChatHistory @ cell, $chatHistoryTag ];
ConfirmMatch[ cells, { ___CellObject }, "CellObjects" ];
as = ConfirmBy[ <| data, "CellObjects" -> cells |>, AssociationQ, "Data" ];
Expand Down
Loading
Loading