Skip to content

Commit c00241a

Browse files
authored
Merge pull request #12 from matlab-deep-learning/dev-fix-ToolChoice-bug
Dev fix tool choice bug
2 parents efa591b + 544d271 commit c00241a

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

openAIChat.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,8 @@ function mustBeValidFunctionCall(this, functionCall)
311311
if ~isempty(this.Tools)
312312
toolChoice = "auto";
313313
end
314-
elseif ToolChoice ~= "auto"
315-
% if toolChoice is not empty, then it must be in the format
314+
elseif ~ismember(toolChoice,["auto","none"])
315+
% if toolChoice is not empty, then it must be "auto", "none" or in the format
316316
% {"type": "function", "function": {"name": "my_function"}}
317317
toolChoice = struct("type","function","function",struct("name",toolChoice));
318318
end

tests/topenAIChat.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ function errorsWhenPassingToolChoiceWithEmptyTools(testCase)
7777
testCase.verifyError(@()generate(chat,"input", ToolChoice="bla"), "llms:mustSetFunctionsForCall");
7878
end
7979

80+
function settingToolChoiceWithNone(testCase)
81+
functions = openAIFunction("funName");
82+
chat = openAIChat(ApiKey="this-is-not-a-real-key",Tools=functions);
83+
testCase.verifyWarningFree(@()generate(chat,"This is okay","ToolChoice","none"));
84+
end
85+
8086
function invalidInputsConstructor(testCase, InvalidConstructorInput)
8187
testCase.verifyError(@()openAIChat(InvalidConstructorInput.Input{:}), InvalidConstructorInput.Error);
8288
end

0 commit comments

Comments
 (0)