Skip to content

Commit

Permalink
Return tool calls properly in azureChat
Browse files Browse the repository at this point in the history
Make `azureChat` handle tool calls returned the same way we do in `openAIChat`.
  • Loading branch information
ccreutzi committed Nov 5, 2024
1 parent c5e2ef1 commit 245e4b0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
16 changes: 14 additions & 2 deletions +llms/+internal/callAzureChatAPI.m
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,20 @@
if isempty(nvp.StreamFun)
message = response.Body.Data.choices(1).message;
else
message = struct("role", "assistant", ...
"content", streamedText);
pat = '{"' + wildcardPattern + '":';
if contains(streamedText,pat)
s = jsondecode(streamedText);
if contains(s.function.arguments,pat)
prompt = jsondecode(s.function.arguments);
s.function.arguments = prompt;
end
message = struct("role", "assistant", ...
"content",[], ...
"tool_calls",jsondecode(streamedText));
else
message = struct("role", "assistant", ...
"content", streamedText);
end
end
if isfield(message, "tool_choice")
text = "";
Expand Down
4 changes: 0 additions & 4 deletions tests/tazureChat.m
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,6 @@ function deploymentNotFound(testCase)
end

% open TODOs for azureChat
function generateWithToolsAndStreamFunc(testCase)
testCase.assumeFail("need to make azureChat return tool_call in the same way as openAIChat");
end

function warningJSONResponseFormat(testCase)
testCase.assumeFail("TODO for azureChat");
end
Expand Down

0 comments on commit 245e4b0

Please sign in to comment.