-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from matlab-deep-learning/refactor-models
Move model capabilitiy verification out of openAIChat.m, for maintain…
- Loading branch information
Showing
6 changed files
with
217 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
function models = models | ||
%MODELS - supported OpenAI models | ||
|
||
% Copyright 2024 The MathWorks, Inc. | ||
models = [... | ||
"gpt-4o","gpt-4o-2024-05-13",... | ||
"gpt-4-turbo","gpt-4-turbo-2024-04-09",... | ||
"gpt-4","gpt-4-0613", ... | ||
"gpt-3.5-turbo","gpt-3.5-turbo-0125", ... | ||
"gpt-3.5-turbo-1106",... | ||
]; | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
function validateMessageSupported(message, model); | ||
%validateMessageSupported - check that message is supported by model | ||
|
||
% Copyright 2024 The MathWorks, Inc. | ||
|
||
% only certain models support image generation | ||
if iscell(message.content) && any(cellfun(@(x) isfield(x,"image_url"), message.content)) | ||
if ~ismember(model,["gpt-4-turbo","gpt-4-turbo-2024-04-09","gpt-4o","gpt-4o-2024-05-13"]) | ||
error("llms:invalidContentTypeForModel", ... | ||
llms.utils.errorMessageCatalog.getMessage("llms:invalidContentTypeForModel", "Image content", model)); | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
function validateResponseFormat(format,model) | ||
%validateResponseFormat - validate requested response format is available for selected model | ||
% Not all OpenAI models support JSON output | ||
|
||
% Copyright 2024 The MathWorks, Inc. | ||
|
||
if format == "json" | ||
if ismember(model,["gpt-4","gpt-4-0613"]) | ||
error("llms:invalidOptionAndValueForModel", ... | ||
llms.utils.errorMessageCatalog.getMessage("llms:invalidOptionAndValueForModel", "ResponseFormat", "json", model)); | ||
else | ||
warning("llms:warningJsonInstruction", ... | ||
llms.utils.errorMessageCatalog.getMessage("llms:warningJsonInstruction")) | ||
end | ||
end | ||
end |
Binary file modified
BIN
+54 Bytes
(100%)
examples/ProcessGeneratedTextinRealTimebyUsingChatGPTinStreamingMode.mlx
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters