Skip to content

Special error message for removing from empty history #79

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

Merged
merged 2 commits into from
Aug 26, 2024
Merged
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
1 change: 1 addition & 0 deletions +llms/+utils/errorMessageCatalog.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
catalog("llms:mustBeAssistantWithNameAndArguments") = "Field 'function' must be a struct with fields 'name' and 'arguments'.";
catalog("llms:assistantMustHaveTextNameAndArguments") = "Fields 'name' and 'arguments' must be text with one or more characters.";
catalog("llms:mustBeValidIndex") = "Index exceeds the number of array elements. Index must be less than or equal to {1}.";
catalog("llms:removeFromEmptyHistory") = "Unable to remove message from empty message history.";
catalog("llms:stopSequencesMustHaveMax4Elements") = "Number of stop sequences must be less than or equal to 4.";
catalog("llms:endpointMustBeSpecified") = "Unable to find endpoint. Either set environment variable AZURE_OPENAI_ENDPOINT or specify name-value argument ""Endpoint"".";
catalog("llms:deploymentMustBeSpecified") = "Unable to find deployment name. Either set environment variable AZURE_OPENAI_DEPLOYMENT or specify name-value argument ""Deployment"".";
Expand Down
3 changes: 3 additions & 0 deletions messageHistory.m
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@
this (1,1) messageHistory
idx (1,1) {mustBeInteger, mustBePositive}
end
if isempty(this.Messages)
error("llms:removeFromEmptyHistory",llms.utils.errorMessageCatalog.getMessage("llms:removeFromEmptyHistory"));
end
if idx>numel(this.Messages)
error("llms:mustBeValidIndex",llms.utils.errorMessageCatalog.getMessage("llms:mustBeValidIndex", string(numel(this.Messages))));
end
Expand Down
4 changes: 4 additions & 0 deletions tests/tmessageHistory.m
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,10 @@ function invalidInputsResponsePrompt(testCase, InvalidInputsResponseMessage)
struct("Input", {{0}}, ...
"Error", "MATLAB:validators:mustBePositive"), ...
...
"FromEmpty", ...
struct("Input", {{1}}, ...
"Error", "llms:removeFromEmptyHistory"), ...
...
"NonScalarInput", ...
struct("Input", {{[1 2]}}, ...
"Error", "MATLAB:validation:IncompatibleSize"));
Expand Down