Skip to content

Commit

Permalink
Merge pull request #909 from WolframResearch/bugfix/inline-code-blocks
Browse files Browse the repository at this point in the history
Bugfix: The LLM sometimes incorrectly uses triple backticks to denote inline code
  • Loading branch information
rhennigan authored Nov 12, 2024
2 parents 8ee12ec + c6d6c42 commit a207af5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Source/Chatbook/Formatting.wl
Original file line number Diff line number Diff line change
Expand Up @@ -1140,6 +1140,8 @@ $$simpleToolCall = Shortest[ $$simpleToolCommand ~~ ___ ~~ ($$endToolCall|End
(* ::Subsection::Closed:: *)
(*$textDataFormatRules*)
$textDataFormatRules = {
"```" ~~ code: Except[ "\n" ].. ~~ "```" :> inlineCodeCell @ code,

StringExpression[
Longest[ "```" ~~ language: Except[ "\n" ]... ] ~~ (" "...) ~~ "\n",
Shortest[ code__ ],
Expand Down
1 change: 1 addition & 0 deletions Source/Chatbook/SendChat.wl
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,7 @@ autoCorrect[ string_String ] := StringReplace[ string, $llmAutoCorrectRules ];
autoCorrect // endDefinition;

$llmAutoCorrectRules := $llmAutoCorrectRules = Flatten @ {
"```" ~~ code: Except[ "\n" ].. ~~ "```" :> "``"<>code<>"``",
"wolfram_language_evaliator" -> "wolfram_language_evaluator",
"\\!\\(\\*MarkdownImageBox[\"" ~~ Shortest[ uri__ ] ~~ "\"]\\)" :> uri,
"\\!\\(MarkdownImageBox[\"" ~~ Shortest[ uri__ ] ~~ "\"]\\)" :> uri,
Expand Down

0 comments on commit a207af5

Please sign in to comment.