Skip to content

Commit

Permalink
More token use optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
rhennigan committed Nov 19, 2024
1 parent 47d5f32 commit 70f008b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 26 deletions.
9 changes: 2 additions & 7 deletions LLMConfiguration/Personas/NotebookAssistant/Pre.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
You are a helpful Wolfram Language assistant named Notebook Assistant. Your job is to do the following:

* Offer Wolfram Language suggestions based on previous inputs.
* Help fix errors.
* Explain error messages so the user understands what went wrong.
* Explain outputs that may be confusing to inexperienced users.
* Assist the user with other topics as needed. While you specialize in Wolfram Language, you can help with any topic.
You are a helpful Wolfram Language assistant named Notebook Assistant.
You specialize in Wolfram Language, but you can help with any topic.
11 changes: 7 additions & 4 deletions Source/Chatbook/ChatTitle.wl
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ Needs[ "Wolfram`Chatbook`Common`" ];
(* ::**************************************************************************************************************:: *)
(* ::Section::Closed:: *)
(*Configuration*)
$maxTitleLength = 30;
$hardMaxTitleLength = 40;
$maxContextLength = 100000; (* characters *)
$maxTitleLength = 30;
$hardMaxTitleLength = 40;
$maxContextLength = 100000; (* characters *)
$multimodalTitleContext = False;

$titlePrompt := "\
Please come up with a meaningful window title for the current chat conversation using no more than \
Expand Down Expand Up @@ -79,7 +80,9 @@ generateChatTitleAsync[ messages: $$chatMessages, callback_, temperature: Automa
instructions = ConfirmBy[ TemplateApply[ $titlePrompt, short ], StringQ, "Prompt" ];

context = ConfirmMatch[
Block[ { $multimodalMessages = True }, expandMultimodalString @ instructions ],
Block[ { $multimodalMessages = TrueQ @ $multimodalTitleContext },
expandMultimodalString @ instructions
],
_String | { __ },
"Context"
];
Expand Down
23 changes: 14 additions & 9 deletions Source/Chatbook/Prompting.wl
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,20 @@ $basePromptComponents[ "GeneralInstructionsHeader" ] = "\
# General Instructions
";

$basePromptComponents[ "NotebooksPreamble" ] = "\
You are interacting with a user through a special Wolfram Chat Notebook. \
This is like a regular notebook except it has special chat input cells which the user can use to send messages to an \
AI (you). \
The messages you receive from the user have been converted to plain text from notebook content. \
Similarly, your messages are automatically converted from plain text before being displayed to the user. \
For this to work correctly, you must adhere to the following guidelines:
";
$basePromptComponents[ "NotebooksPreamble" ] := If[ TrueQ @ $WorkspaceChat,
"You are interacting with a user through a special Wolfram Chat interface alongside normal notebooks. \
You will often receive context from the user's notebooks, but you will see it formatted as markdown. \
Similarly, your responses are automatically converted from plain text before being displayed to the user. \
For this to work correctly, you must adhere to the following guidelines:
",
"You are interacting with a user through a special Wolfram Chat Notebook. \
This is like a regular notebook except it has special chat input cells which the user can use to send messages to an \
AI (you). \
The messages you receive from the user have been converted to plain text from notebook content. \
Similarly, your messages are automatically converted from plain text before being displayed to the user. \
For this to work correctly, you must adhere to the following guidelines:
"
];

$basePromptComponents[ "AutoAssistant" ] = "\
* ALWAYS begin your response with one of the following tags to indicate the type of response: [INFO], [WARNING], or [ERROR]
Expand Down Expand Up @@ -256,7 +262,6 @@ $basePromptComponents[ "WolframLanguageStyle" ] = "
* Always use proper naming conventions for your variables (e.g. lowerCamelCase)
* Never use single capital letters to represent variables (e.g. use `a Sin[k x + \[Phi]]` instead of `A Sin[k x + \[Phi]]`)
* Prefer modern Wolfram Language symbols and methods
* Many new symbols have been added to WL since your knowledge cutoff date, so check documentation as needed
* When creating plots, add options such as labels and legends to make them easier to understand";

$basePromptComponents[ "WolframLanguageEvaluatorTool" ] = "\
Expand Down
7 changes: 1 addition & 6 deletions Source/Chatbook/Tools/Examples.wl
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,7 @@ $fullExamplesKeys :=
With[ { selected = Keys @ $selectedTools },
Select[
{
"AstroGraphicsDocumentation",
"FileSystemTree",
"FractionalDerivatives",
"NaturalLanguageInput",
"PlotEvaluate",
"TemporaryDirectory"
"NaturalLanguageInput"
},
ContainsAll[ selected, $exampleDependencies[ #1 ] ] &
]
Expand Down

0 comments on commit 70f008b

Please sign in to comment.