Skip to content

Commit adbddc2

Browse files
committed
adding tests and minor fixes.
1 parent bd780e2 commit adbddc2

22 files changed

+780
-441
lines changed

+llms/+internal/callOpenAIChatAPI.m

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
function [text, message, response] = callOpenAIChatAPI(messages, functions, nvp)
2-
% This function is undocumented and will change in a future release
3-
42
%callOpenAIChatAPI Calls the openAI chat completions API.
53
%
64
% MESSAGES and FUNCTIONS should be structs matching the json format
@@ -52,7 +50,7 @@
5250
% % Send a request
5351
% [text, message] = llms.internal.callOpenAIChatAPI(messages, functions, ApiKey=apiKey)
5452

55-
% Copyright 2023 The MathWorks, Inc.
53+
% Copyright 2023-2024 The MathWorks, Inc.
5654

5755
arguments
5856
messages

+llms/+utils/errorMessageCatalog.m

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
classdef errorMessageCatalog
2-
% This class is undocumented and will change in a future release
3-
42
%errorMessageCatalog Stores the error messages from this repository
53

6-
% Copyright 2023 The MathWorks, Inc.
4+
% Copyright 2023-2024 The MathWorks, Inc.
5+
76
properties(Constant)
87
%CATALOG dictionary mapping error ids to error msgs
98
Catalog = buildErrorMessageCatalog;
109
end
1110

1211
methods(Static)
1312
function msg = getMessage(messageId, slot)
14-
% This function is undocumented and will change in a future release
15-
1613
%getMessage returns error message given a messageID and a SLOT.
1714
% The value in SLOT should be ordered, where the n-th element
1815
% will replace the value "{n}".
@@ -47,7 +44,12 @@
4744
catalog("llms:stopSequencesMustHaveMax4Elements") = "Number of elements must not be larger than 4.";
4845
catalog("llms:keyMustBeSpecified") = "API key not found as environment variable OPENAI_API_KEY and not specified via ApiKey parameter.";
4946
catalog("llms:mustHaveMessages") = "Value must contain at least one message in Messages.";
50-
catalog("llms:mustSetFunctionsForCall") = "When no functions are defined, FunctionCall must not be specified.";
47+
catalog("llms:mustSetFunctionsForCall") = "When no functions are defined, ToolChoice must not be specified.";
5148
catalog("llms:mustBeMessagesOrTxt") = "Messages must be text with one or more characters or an openAIMessages objects.";
52-
end
53-
49+
catalog("llms:invalidOptionAndValueForModel") = "'{1}' with value '{2}' is not supported for ModelName '{3}'";
50+
catalog("llms:invalidOptionForModel") = "{1} is not supported for ModelName '{2}'";
51+
catalog("llms:functionNotAvailableForModel") = "This function is not supported for ModelName '{1}'";
52+
catalog("llms:promptLimitCharacter") = "Prompt must have a maximum length of {1} characters for ModelName '{2}'";
53+
catalog("llms:pngExpected") = "Argument must be a PNG image.";
54+
catalog("llms:warningJsonInstruction") = "When using JSON mode, you must also prompt the model to produce JSON yourself via a system or user message.";
55+
end

examples/ExampleDALLE.mlx

4.59 MB
Binary file not shown.

examples/ExampleFunctionCalling.mlx

-2.76 KB
Binary file not shown.

examples/ExampleGPT4Vision.mlx

1.17 MB
Binary file not shown.

examples/ExampleJSONMode.mlx

4.75 KB
Binary file not shown.
4.28 KB
Binary file not shown.

examples/ExampleStreaming.mlx

5.33 KB
Binary file not shown.

examples/Example_DALL·E.mlx

-2.45 MB
Binary file not shown.

examples/Example_GPT4_Vision.mlx

-1.17 MB
Binary file not shown.

0 commit comments

Comments
 (0)