Skip to content

Commit becf0a5

Browse files
Cheuk Lun Koccreutzi
authored andcommitted
Remove checks for old Azure API versions
Remove some code checking for old API versions that did not yet support structured output. Also remove code that captures and replaces error messages related to output format, returning the server error instead.
1 parent 00e78ba commit becf0a5

File tree

6 files changed

+1
-109
lines changed

6 files changed

+1
-109
lines changed

+llms/+azure/validateResponseFormat.m

Lines changed: 0 additions & 32 deletions
This file was deleted.

+llms/+openai/validateMessageSupported.m

Lines changed: 0 additions & 15 deletions
This file was deleted.

+llms/+openai/validateResponseFormat.m

Lines changed: 0 additions & 33 deletions
This file was deleted.

+llms/+utils/errorMessageCatalog.m

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@
6161
catalog("llms:mustSetFunctionsForCall") = "When no functions are defined, ToolChoice must not be specified.";
6262
catalog("llms:mustBeMessagesOrTxt") = "Message must be nonempty string, character array, cell array of character vectors, or messageHistory object.";
6363
catalog("llms:invalidOptionAndValueForModel") = "'{1}' with value '{2}' is not supported for model ""{3}"".";
64-
catalog("llms:noStructuredOutputForAzureDeployment") = "Structured output is not supported for deployment ""{1}"".";
65-
catalog("llms:structuredOutputRequiresAPI") = "Structured output is not supported for API version ""{1}"". Use APIVersion=""2024-08-01-preview"" or newer.";
6664
catalog("llms:invalidOptionForModel") = "Invalid argument name {1} for model ""{2}"".";
6765
catalog("llms:functionNotAvailableForModel") = "Image editing is not supported for model ""{1}"".";
6866
catalog("llms:promptLimitCharacter") = "Prompt must contain at most {1} characters for model ""{2}"".";

azureChat.m

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,6 @@
249249
messagesStruct = horzcat(this.SystemPrompt, messagesStruct);
250250
end
251251

252-
llms.azure.validateResponseFormat(nvp.ResponseFormat, this, messagesStruct);
253-
254252
toolChoice = convertToolChoice(this, nvp.ToolChoice);
255253

256254
if isfield(nvp,"StreamFun")
@@ -281,15 +279,7 @@
281279
end
282280

283281
if isfield(response.Body.Data,"error")
284-
err = response.Body.Data.error.message;
285-
if startsWith(err,"'json_schema' is not one of ['json_object', 'text']") || ...
286-
startsWith(replace(err,newline," "),...
287-
"Invalid parameter: 'response_format' of type 'json_schema' is not supported with this model.")
288-
error("llms:noStructuredOutputForAzureDeployment", ...
289-
llms.utils.errorMessageCatalog.getMessage( ...
290-
"llms:noStructuredOutputForAzureDeployment",this.DeploymentID));
291-
end
292-
error("llms:apiReturnedError",llms.utils.errorMessageCatalog.getMessage("llms:apiReturnedError",err));
282+
error("llms:apiReturnedError",llms.utils.errorMessageCatalog.getMessage("llms:apiReturnedError",response.Body.Data.error.message));
293283
end
294284

295285
if ~isempty(text)

tests/tazureChat.m

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,6 @@ function jsonFormatWithSystemPrompt(testCase)
110110
"string");
111111
end
112112

113-
function responseFormatRequiresNewAPI(testCase)
114-
chat = azureChat(APIVersion="2024-02-01");
115-
testCase.verifyError(@() generate(chat, ...
116-
"What is the smallest prime?", ...
117-
ResponseFormat=struct("number",1)), ...
118-
"llms:structuredOutputRequiresAPI");
119-
end
120-
121113
function maxNumTokensWithReasoningModel(testCase)
122114
% Unlike OpenAI, Azure requires different parameter names for
123115
% different models (max_tokens vs max_completion_tokens). Since
@@ -177,14 +169,6 @@ function canUseAPIVersions(testCase, APIVersions)
177169
testCase.verifyClass(response,'string');
178170
testCase.verifyGreaterThan(strlength(response),0);
179171
end
180-
181-
function specialErrorForUnsupportedResponseFormat(testCase)
182-
testCase.verifyError(@() generate(...
183-
azureChat(DeploymentID="o1-mini"), ...
184-
"What is the smallest prime?", ...
185-
ResponseFormat=struct("number",1)), ...
186-
"llms:noStructuredOutputForAzureDeployment");
187-
end
188172
end
189173

190174
methods

0 commit comments

Comments
 (0)