Skip to content

Commit 245e4b0

Browse files
committed
Return tool calls properly in azureChat
Make `azureChat` handle tool calls returned the same way we do in `openAIChat`.
1 parent c5e2ef1 commit 245e4b0

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

Diff for: +llms/+internal/callAzureChatAPI.m

+14-2
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,20 @@
7373
if isempty(nvp.StreamFun)
7474
message = response.Body.Data.choices(1).message;
7575
else
76-
message = struct("role", "assistant", ...
77-
"content", streamedText);
76+
pat = '{"' + wildcardPattern + '":';
77+
if contains(streamedText,pat)
78+
s = jsondecode(streamedText);
79+
if contains(s.function.arguments,pat)
80+
prompt = jsondecode(s.function.arguments);
81+
s.function.arguments = prompt;
82+
end
83+
message = struct("role", "assistant", ...
84+
"content",[], ...
85+
"tool_calls",jsondecode(streamedText));
86+
else
87+
message = struct("role", "assistant", ...
88+
"content", streamedText);
89+
end
7890
end
7991
if isfield(message, "tool_choice")
8092
text = "";

Diff for: tests/tazureChat.m

-4
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,6 @@ function deploymentNotFound(testCase)
172172
end
173173

174174
% open TODOs for azureChat
175-
function generateWithToolsAndStreamFunc(testCase)
176-
testCase.assumeFail("need to make azureChat return tool_call in the same way as openAIChat");
177-
end
178-
179175
function warningJSONResponseFormat(testCase)
180176
testCase.assumeFail("TODO for azureChat");
181177
end

0 commit comments

Comments
 (0)