Skip to content

Commit

Permalink
Merge pull request #951 from WolframResearch/feature/LLM-699_ErrorBlobs
Browse files Browse the repository at this point in the history
New error message design
  • Loading branch information
rhennigan authored Nov 24, 2024
2 parents 24e15b4 + 18436f9 commit ebd314b
Show file tree
Hide file tree
Showing 17 changed files with 1,462 additions and 28 deletions.
23 changes: 23 additions & 0 deletions Developer/Resources/FrontEndResources/Common/Close.wl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
(* ::Package:: *)

(* Created with the Wolfram Language : www.wolfram.com *)
Function[Evaluate @ ToBoxes @
Graphics[{Thickness[0.05555555555555555], {Thickness[0.05555555555555555],
EdgeForm[#1], FaceForm[#2], (* added for flexibility *)
FilledCurve[{{{1, 4, 3}, {1, 3, 3}, {1, 3, 3}, {1, 3, 3}}}, {{{18., 9.},
{18., 4.0289998054504395}, {13.97100019454956, 0.}, {9., 0.},
{4.029000282287598, 0.}, {0., 4.0289998054504395}, {0., 9.}, {0.,
13.97100019454956}, {4.029000282287598, 18.}, {9., 18.},
{13.97100019454956, 18.}, {18., 13.97100019454956}, {18., 9.}}}]},
{FaceForm[{#3, Opacity[1.]}],
FilledCurve[{{{0, 2, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0,
1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1, 0}, {0, 1,
0}}}, {{{12.350000381469727, 13.}, {8.999000549316406, 9.64900016784668},
{5.649000644683838, 13.}, {5., 12.349999964237213}, {8.350000381469727,
8.999000072479248}, {5., 5.649999618530273}, {5.649000644683838, 5.},
{8.999000549316406, 8.351000308990479}, {12.350000381469727, 5.},
{13.000000417232513, 5.649999618530273}, {9.649000406265259,
8.999000072479248}, {13.000000417232513, 12.349999964237213},
{12.350000381469727, 13.}}}]}},ImagePadding -> {{0,1}, {1,0}} , AspectRatio -> Automatic,
ImageSize -> {18., 18.}, PlotRange -> {{0., 18.}, {0., 18.}}]
]
633 changes: 633 additions & 0 deletions Developer/Resources/FrontEndResources/Common/RateLimit.wl

Large diffs are not rendered by default.

364 changes: 363 additions & 1 deletion FrontEnd/TextResources/ChatbookResources.tr

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions FrontEnd/TextResources/ChatbookStrings.tr
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@
"UIAdvancedRoles" -> "Roles",
"UITryEnableChatDialogMainText" -> "Enabling Chat Notebook functionality will destroy the private styles defined in this notebook, and replace them with the shared Chatbook stylesheet.",
"UITryEnableChatDialogConfirm" -> "Are you sure you wish to continue?",
"UIMessageManageSubscription" -> "Manage Subscription \[RightGuillemet]",
"UIMessageContactUs" -> "Contact us \[RightGuillemet]",
"UIMessageUsed80" -> "You have used 80% of your Wolfram Notebook Assistant + LLM Kit allowance for this month.",
"UIMessageUsedAll" -> "You have used your entire Wolfram Notebook Assistant + LLM Kit allowance for this month.",
"UIMessageHighUsageRate" -> "We've detected a very high rate of requests from your account. To prevent disruptions to the service for other users, we've temporarily had to block your requests.",
"UIMessageUnblockRequest" -> "Ask to be unblocked \[RightGuillemet]",

"StylesheetChatWidgetButtonTooltip" -> "Send to LLM",
"StylesheetAssistantMenuInitializerButtonTooltip" -> "Disable automatic assistance",
Expand Down
6 changes: 6 additions & 0 deletions FrontEnd/TextResources/ChineseSimplified/ChatbookStrings.tr
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@
"UIAdvancedRoles" -> "\:89D2\:8272",
"UITryEnableChatDialogMainText" -> "\:542F\:7528\:804A\:5929\:7B14\:8BB0\:672C\:529F\:80FD\:5C06\:7834\:574F\:6B64\:7B14\:8BB0\:672C\:4E2D\:5B9A\:4E49\:7684\:4E13\:6709\:6837\:5F0F\:ff0c\:5E76\:5C06\:5176\:66FF\:6362\:4E3A\:5171\:4EAB\:7684\:804A\:5929\:7B14\:8BB0\:672C\:6837\:5F0F\:3002",
"UITryEnableChatDialogConfirm" -> "\:60A8\:786E\:5B9A\:8981\:7EE7\:7EED\:5417\:ff1f",
"UIMessageManageSubscription" -> "Manage Subscription \[RightGuillemet]",
"UIMessageContactUs" -> "Contact us \[RightGuillemet]",
"UIMessageUsed80" -> "You have used 80% of your Wolfram Notebook Assistant + LLM Kit allowance for this month.",
"UIMessageUsedAll" -> "You have used your entire Wolfram Notebook Assistant + LLM Kit allowance for this month.",
"UIMessageHighUsageRate" -> "We've detected a very high rate of requests from your account. To prevent disruptions to the service for other users, we've temporarily had to block your requests.",
"UIMessageUnblockRequest" -> "Ask to be unblocked \[RightGuillemet]",

"StylesheetChatWidgetButtonTooltip" -> "\:53D1\:9001\:5230 LLM",
"StylesheetAssistantMenuInitializerButtonTooltip" -> "\:7981\:7528\:81EA\:52A8\:534F\:52A9\:529F\:80FD",
Expand Down
6 changes: 6 additions & 0 deletions FrontEnd/TextResources/ChineseTraditional/ChatbookStrings.tr
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@
"UIAdvancedRoles" -> "\:89D2\:8272",
"UITryEnableChatDialogMainText" -> "\:8CE6\:80FD\:7DB2\:8DEF\:804A\:5929\:7CFB\:7D71\:7B46\:8A18\:672C\:7684\:529F\:80FD\:6027\:FF0C\:4E0D\:50C5\:5C07\:6703\:6BC0\:640D\:8F09\:6B64\:7B46\:8A18\:672C\:4E2D\:6240\:5B9A\:7FA9\:7684\:79C1\:7528\:6A23\:5F0F\:FF0C\:4E14\:6703\:88AB\:5171\:4EAB Chatbook \:6A23\:5F0F\:8868\:53D6\:800C\:4EE3\:4E4B\:3002",
"UITryEnableChatDialogConfirm" -> "\:60A8\:78BA\:5B9A\:8981\:7E7C\:7E8C\:55CE\:FF1F",
"UIMessageManageSubscription" -> "Manage Subscription \[RightGuillemet]",
"UIMessageContactUs" -> "Contact us \[RightGuillemet]",
"UIMessageUsed80" -> "You have used 80% of your Wolfram Notebook Assistant + LLM Kit allowance for this month.",
"UIMessageUsedAll" -> "You have used your entire Wolfram Notebook Assistant + LLM Kit allowance for this month.",
"UIMessageHighUsageRate" -> "We've detected a very high rate of requests from your account. To prevent disruptions to the service for other users, we've temporarily had to block your requests.",
"UIMessageUnblockRequest" -> "Ask to be unblocked \[RightGuillemet]",

"StylesheetChatWidgetButtonTooltip" -> "\:767C\:9001\:81F3 LLM",
"StylesheetAssistantMenuInitializerButtonTooltip" -> "\:5931\:80FD\:81EA\:52D5\:8F14\:52A9",
Expand Down
6 changes: 6 additions & 0 deletions FrontEnd/TextResources/French/ChatbookStrings.tr
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@
"UIAdvancedRoles" -> "Choisir automatiquement",
"UITryEnableChatDialogMainText" -> "L\[CloseCurlyQuote]activation de la fonctionnalit\[EAcute] du notebook de chat d\[EAcute]truira les styles priv\[EAcute]s d\[EAcute]finis dans ce notebook et les remplacera par la feuille de style du chatbook partag\[EAcute]e.",
"UITryEnableChatDialogConfirm" -> "\[CapitalEHat]tes-vous s\[UHat]r de vouloir continuer\[NonBreakingSpace]?",
"UIMessageManageSubscription" -> "Manage Subscription \[RightGuillemet]",
"UIMessageContactUs" -> "Contact us \[RightGuillemet]",
"UIMessageUsed80" -> "You have used 80% of your Wolfram Notebook Assistant + LLM Kit allowance for this month.",
"UIMessageUsedAll" -> "You have used your entire Wolfram Notebook Assistant + LLM Kit allowance for this month.",
"UIMessageHighUsageRate" -> "We've detected a very high rate of requests from your account. To prevent disruptions to the service for other users, we've temporarily had to block your requests.",
"UIMessageUnblockRequest" -> "Ask to be unblocked \[RightGuillemet]",

"StylesheetChatWidgetButtonTooltip" -> "Envoyer au LLM",
"StylesheetAssistantMenuInitializerButtonTooltip" -> "D\[EAcute]sactiver l\[CloseCurlyQuote]assistance automatique",
Expand Down
6 changes: 6 additions & 0 deletions FrontEnd/TextResources/Japanese/ChatbookStrings.tr
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@
"UIAdvancedRoles" -> "\:5f79\:5272",
"UITryEnableChatDialogMainText" -> "\:30c1\:30e3\:30c3\:30c8\:30ce\:30fc\:30c8\:30d6\:30c3\:30af\:306e\:6a5f\:80fd\:3092\:6709\:52b9\:306b\:3059\:308b\:3068\:ff0c\:3053\:306e\:30ce\:30fc\:30c8\:30d6\:30c3\:30af\:306b\:5b9a\:7fa9\:3055\:308c\:305f\:30b9\:30bf\:30a4\:30eb\:304c\:7834\:68c4\:3055\:308c\:ff0c\:5171\:6709\:306eChatbook\:30b9\:30bf\:30a4\:30eb\:30b7\:30fc\:30c8\:3067\:7f6e\:63db\:3055\:308c\:307e\:3059\:ff0e",
"UITryEnableChatDialogConfirm" -> "\:7d9a\:884c\:3057\:307e\:3059\:304b\:ff1f",
"UIMessageManageSubscription" -> "Manage Subscription \[RightGuillemet]",
"UIMessageContactUs" -> "Contact us \[RightGuillemet]",
"UIMessageUsed80" -> "You have used 80% of your Wolfram Notebook Assistant + LLM Kit allowance for this month.",
"UIMessageUsedAll" -> "You have used your entire Wolfram Notebook Assistant + LLM Kit allowance for this month.",
"UIMessageHighUsageRate" -> "We've detected a very high rate of requests from your account. To prevent disruptions to the service for other users, we've temporarily had to block your requests.",
"UIMessageUnblockRequest" -> "Ask to be unblocked \[RightGuillemet]",

"StylesheetChatWidgetButtonTooltip" -> "\:5927\:898f\:6a21\:8a00\:8a9e\:30e2\:30c7\:30eb\:306b\:9001\:4fe1",
"StylesheetAssistantMenuInitializerButtonTooltip" -> "\:81ea\:52d5\:30a2\:30b7\:30b9\:30bf\:30f3\:30c8\:3092\:7121\:52b9\:306b\:3059\:308b",
Expand Down
6 changes: 6 additions & 0 deletions FrontEnd/TextResources/Korean/ChatbookStrings.tr
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@
"UIAdvancedRoles" -> "\:C5ED\:D560",
"UITryEnableChatDialogMainText" -> "\:CC44\:D305 \:B178\:D2B8\:BD81 \:AE30\:B2A5\:C744 \:D65C\:C131\:D654\:D558\:BA74 \:C774 \:B178\:D2B8\:BD81\:C5D0 \:C815\:C758\:B41C \:C2A4\:D0C0\:C77C\:C774 \:C0AD\:C81C\:B418\:BA70 \:ACF5\:C720\:B41C Chatbook \:C2A4\:D0C0\:C77C\:C2DC\:D2B8\:B85C \:B300\:CCB4\:B429\:B2C8\:B2E4.",
"UITryEnableChatDialogConfirm" -> "\:ACC4\:C18D \:D558\:C2DC\:ACA0\:C2B5\:B2C8\:AE4C?",
"UIMessageManageSubscription" -> "Manage Subscription \[RightGuillemet]",
"UIMessageContactUs" -> "Contact us \[RightGuillemet]",
"UIMessageUsed80" -> "You have used 80% of your Wolfram Notebook Assistant + LLM Kit allowance for this month.",
"UIMessageUsedAll" -> "You have used your entire Wolfram Notebook Assistant + LLM Kit allowance for this month.",
"UIMessageHighUsageRate" -> "We've detected a very high rate of requests from your account. To prevent disruptions to the service for other users, we've temporarily had to block your requests.",
"UIMessageUnblockRequest" -> "Ask to be unblocked \[RightGuillemet]",

"StylesheetChatWidgetButtonTooltip" -> "\:B300\:D615 \:C5B8\:C5B4 \:BAA8\:B378\:B85C \:C804\:C1A1",
"StylesheetAssistantMenuInitializerButtonTooltip" -> "\:C790\:B3D9 \:B3C4\:C6B0\:BBF8 \:BE44\:D65C\:C131\:D654",
Expand Down
6 changes: 6 additions & 0 deletions FrontEnd/TextResources/Spanish/ChatbookStrings.tr
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@
"UIAdvancedRoles" -> "Roles",
"UITryEnableChatDialogMainText" -> "Habilitar la funcionalidad de Cuadernos de chat destruir\[AAcute] los estilos privados definidos en este cuaderno, y los reemplazar\[AAcute] con la hoja de estilo compartida Chatbook.",
"UITryEnableChatDialogConfirm" -> "\[DownQuestion]Est\[AAcute] seguro que desea continuar?",
"UIMessageManageSubscription" -> "Manage Subscription \[RightGuillemet]",
"UIMessageContactUs" -> "Contact us \[RightGuillemet]",
"UIMessageUsed80" -> "You have used 80% of your Wolfram Notebook Assistant + LLM Kit allowance for this month.",
"UIMessageUsedAll" -> "You have used your entire Wolfram Notebook Assistant + LLM Kit allowance for this month.",
"UIMessageHighUsageRate" -> "We've detected a very high rate of requests from your account. To prevent disruptions to the service for other users, we've temporarily had to block your requests.",
"UIMessageUnblockRequest" -> "Ask to be unblocked \[RightGuillemet]",

"StylesheetChatWidgetButtonTooltip" -> "Enviar a LLM",
"StylesheetAssistantMenuInitializerButtonTooltip" -> "Deshabilitar asistencia autom\[AAcute]tica",
Expand Down
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.5.2.3",
"Version" -> "1.5.2.4",
"WolframVersion" -> "14.1+",
"Description" -> "Wolfram Notebooks + LLMs",
"License" -> "MIT",
Expand Down
10 changes: 0 additions & 10 deletions Source/Chatbook/ChatModes/UI.wl
Original file line number Diff line number Diff line change
Expand Up @@ -294,16 +294,6 @@ $toolbarButtonHover = Sequence[ Background -> RGBColor[ "#87C3E3" ], FrameStyl
$toolbarButtonActive = Sequence[ Background -> RGBColor[ "#3689B5" ], FrameStyle -> RGBColor[ "#3689B5" ] ];
$toolbarButtonLight = Sequence[ Background -> RGBColor[ "#F1F8FC" ], FrameStyle -> RGBColor[ "#F1F8FC" ] ];


(* ::**************************************************************************************************************:: *)
(* ::Subsubsubsection::Closed:: *)
(*mouseDown*)
mouseDown // beginDefinition;
(* Workaround for dynamics freezing in attached cells when mousing over docked cell: *)
mouseDown[ a_, b_, c_ ] /; $OperatingSystem === "Windows" := Mouseover[ a, b ];
mouseDown[ a_, b_, c_ ] := NotebookTools`Mousedown[ a, b, c ];
mouseDown // endDefinition;

(* ::**************************************************************************************************************:: *)
(* ::Subsubsubsection::Closed:: *)
(*buttonTooltip*)
Expand Down
2 changes: 2 additions & 0 deletions Source/Chatbook/CommonSymbols.wl
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ BeginPackage[ "Wolfram`Chatbook`Common`" ];
`documentationSearchAPI;
`dynamicAutoFormatQ;
`dynamicSplitQ;
`errorMessageBox;
`escapeMarkdownString;
`evaluateInlineChat;
`evaluateWithProgress;
Expand Down Expand Up @@ -229,6 +230,7 @@ BeginPackage[ "Wolfram`Chatbook`Common`" ];
`modelDisplayName;
`modelListCachedQ;
`modifierTemplateBoxes;
`mouseDown;
`moveToChatInputField;
`multimodalModelQ;
`multimodalPacletsAvailable;
Expand Down
9 changes: 9 additions & 0 deletions Source/Chatbook/FrontEnd.wl
Original file line number Diff line number Diff line change
Expand Up @@ -1247,6 +1247,15 @@ $statelessProgressIndicator =
(* ::Section::Closed:: *)
(*Misc*)

(* ::**************************************************************************************************************:: *)
(* ::Subsection::Closed:: *)
(*mouseDown*)
mouseDown // beginDefinition;
(* Workaround for dynamics freezing in attached cells when mousing over docked cell: *)
mouseDown[ a_, b_, c_ ] /; $OperatingSystem === "Windows" := Mouseover[ a, b ];
mouseDown[ a_, b_, c_ ] := NotebookTools`Mousedown[ a, b, c ];
mouseDown // endDefinition;

(* ::**************************************************************************************************************:: *)
(* ::Subsection::Closed:: *)
(*usingFrontEnd*)
Expand Down
85 changes: 70 additions & 15 deletions Source/Chatbook/SendChat.wl
Original file line number Diff line number Diff line change
Expand Up @@ -2580,11 +2580,16 @@ throwFailureToChatOutput[ failure_ ] :=

throwFailureToChatOutput[ task_, cell_CellObject, failure_ ] := (
Quiet @ TaskRemove @ task;
throwTop @ writeErrorCell[ cell, failure ];
If[ StringQ @ CurrentValue[ cell, ExpressionUUID ],
throwTop @ writeErrorCell[ cell, failure ],
throwTop @ failure
]
);

throwFailureToChatOutput[ _, None, failure_Failure ] :=
throwTop @ failure;
throwFailureToChatOutput[ task_, None, failure_Failure ] := (
Quiet @ TaskRemove @ task;
throwTop @ failure
);

throwFailureToChatOutput // endDefinition;

Expand All @@ -2600,23 +2605,23 @@ writeErrorCell // endDefinition;
(*errorCell*)
errorCell // beginDefinition;

errorCell[ as_ ] /; ! FreeQ[ as, $$usageLimitCode ] :=
Cell[
BoxData @ ToBoxes @ errorMessageBox[ "UsageBlocked" ],
"Text",
CellAutoOverwrite -> True,
CellTrayWidgets -> <| "ChatFeedback" -> <| "Visible" -> False |> |>,
CodeAssistOptions -> { "AutoDetectHyperlinks" -> True },
GeneratedCell -> True,
Initialization -> None
];

errorCell[ as_ ] := Enclose[
Module[ { text },
text = ConfirmMatch[ errorText @ as, _String|$$textDataList, "ErrorText" ];
Cell[
TextData @ Flatten @ {
StyleBox[ "\[WarningSign] ", FontColor -> Darker @ Red, FontSize -> 1.5 Inherited ],
If[ StringQ @ text,
{
text,
"\n\n",
Cell @ BoxData @ Quiet @ errorBoxes @ as
},
text
]
},
BoxData @ toErrorBoxes @ text,
"Text",
"ChatOutput",
CellAutoOverwrite -> True,
CellTrayWidgets -> <| "ChatFeedback" -> <| "Visible" -> False |> |>,
CodeAssistOptions -> { "AutoDetectHyperlinks" -> True },
Expand All @@ -2629,6 +2634,56 @@ errorCell[ as_ ] := Enclose[

errorCell // endDefinition;


$$usageLimitCode = Alternatives[
"request-per-minute-limit-exceeded",
"credits-per-minute-limit-exceeded",
"request-per-hour-limit-exceeded",
"credits-per-hour-limit-exceeded",
"request-per-month-limit-exceeded",
"credits-per-month-limit-exceeded"
];

(* ::**************************************************************************************************************:: *)
(* ::Subsubsection::Closed:: *)
(*toErrorBoxes*)
toErrorBoxes // beginDefinition;

toErrorBoxes[ text_String ] := Enclose[
Module[ { label, box },
label = Row @ { RawBoxes @ $errorIconBox, text };
box = ConfirmMatch[
errorMessageBox[ label, Appearance -> "Fatal", ImageSize -> { Scaled[ 1 ], Automatic } ],
_Framed,
"Box"
];
ToBoxes @ box
],
throwInternalFailure
];

toErrorBoxes[ text: $$testDataList ] := Enclose[
Module[ { label, box },
label = RawBoxes @ Cell[
TextData @ Flatten @ { $errorIconBox, text },
Background -> None,
ShowStringCharacters -> False
];
box = ConfirmMatch[
errorMessageBox[ label, Appearance -> "Fatal", ImageSize -> { Scaled[ 1 ], Automatic } ],
_Framed,
"Box"
];
ToBoxes @ box
],
throwInternalFailure
];

toErrorBoxes // endDefinition;


$errorIconBox = StyleBox[ "\[WarningSign] ", FontColor -> Darker @ Red, FontSize -> 1.5 * Inherited ];

(* ::**************************************************************************************************************:: *)
(* ::Subsubsection::Closed:: *)
(*errorText*)
Expand Down
14 changes: 13 additions & 1 deletion Source/Chatbook/Serialization.wl
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,10 @@ $$longNameCharacter = Alternatives @@ $longNameCharacterList;

$$invisibleCharacter = Alternatives[
FromCharacterCode[ 8203 ], (* U+200B Zero Width Space *)
FromCharacterCode[ 62304 ] (* InvisibleSpace *)
FromCharacterCode[ 62304 ], (* InvisibleSpace *)
"\[SpanFromLeft]",
"\[SpanFromAbove]",
"\[SpanFromBoth]"
];

(* Characters that should be automatically escaped when they appear in plain text to be valid markdown: *)
Expand Down Expand Up @@ -2163,6 +2166,15 @@ $$ignoredBox = Alternatives[

fasterCellToString0[ $$ignoredBox ] := "";

(* ::**************************************************************************************************************:: *)
(* ::Subsubsubsection::Closed:: *)
(*Chatbook Text Resources*)
fasterCellToString0[ DynamicBox[ FEPrivate`FrontEndResource[ "ChatbookExpressions", "Close" ][ ___ ], ___ ] ] :=
"";

fasterCellToString0[ DynamicBox[ ToBoxes[ FEPrivate`FrontEndResource[ "ChatbookStrings", name_String ], _ ], ___ ] ] :=
With[ { str = trRaw @ name }, str /; StringQ @ str ];

(* ::**************************************************************************************************************:: *)
(* ::Subsubsubsection::Closed:: *)
(*Other*)
Expand Down
Loading

0 comments on commit ebd314b

Please sign in to comment.