@@ -84,9 +84,12 @@ function assistantToolCallMessageIsAdded(testCase)
84
84
funCall = struct(" name" , functionName , " arguments" , args );
85
85
toolCall = struct(" id" , " 123" , " type" , " function" , " function" , funCall );
86
86
toolCallPrompt = struct(" role" , " assistant" , " content" , " " , " tool_calls" , []);
87
- toolCallPrompt.tool_calls = {toolCall };
87
+ % tool_calls is an array of struct in API response
88
+ toolCallPrompt.tool_calls = toolCall ;
88
89
msgs = addResponseMessage(msgs , toolCallPrompt );
89
- testCase .verifyEqual(msgs.Messages{1 }, toolCallPrompt );
90
+ % to include in msgs, tool_calls must be a cell
91
+ testCase .verifyEqual(fieldnames(msgs.Messages{1 }), fieldnames(toolCallPrompt ));
92
+ testCase .verifyEqual(msgs.Messages{1 }.tool_calls{1 }, toolCallPrompt .tool_calls );
90
93
end
91
94
92
95
function assistantToolCallMessageWithoutArgsIsAdded(testCase )
@@ -95,9 +98,12 @@ function assistantToolCallMessageWithoutArgsIsAdded(testCase)
95
98
funCall = struct(" name" , functionName , " arguments" , " {}" );
96
99
toolCall = struct(" id" , " 123" , " type" , " function" , " function" , funCall );
97
100
toolCallPrompt = struct(" role" , " assistant" , " content" , " " ," tool_calls" , []);
98
- toolCallPrompt.tool_calls = {toolCall };
101
+ % tool_calls is an array of struct in API response
102
+ toolCallPrompt.tool_calls = toolCall ;
99
103
msgs = addResponseMessage(msgs , toolCallPrompt );
100
- testCase .verifyEqual(msgs.Messages{1 }, toolCallPrompt );
104
+ % to include in msgs, tool_calls must be a cell
105
+ testCase .verifyEqual(fieldnames(msgs.Messages{1 }), fieldnames(toolCallPrompt ));
106
+ testCase .verifyEqual(msgs.Messages{1 }.tool_calls{1 }, toolCallPrompt .tool_calls );
101
107
end
102
108
103
109
function assistantParallelToolCallMessageIsAdded(testCase )
@@ -107,6 +113,7 @@ function assistantParallelToolCallMessageIsAdded(testCase)
107
113
funCall = struct(" name" , functionName , " arguments" , args );
108
114
toolCall = struct(" id" , " 123" , " type" , " function" , " function" , funCall );
109
115
toolCallPrompt = struct(" role" , " assistant" , " content" , " " , " tool_calls" , []);
116
+ % tool_calls is an array of struct in API response
110
117
toolCallPrompt.tool_calls = [toolCall ,toolCall ,toolCall ];
111
118
msgs = addResponseMessage(msgs , toolCallPrompt );
112
119
testCase .verifyEqual(msgs.Messages{1 }, toolCallPrompt );
0 commit comments