@@ -183,6 +183,69 @@ func TestConverseAlpha2(t *testing.T) {
183183 },
184184 },
185185 },
186+ {
187+ name : "tool call request with multiple arguments alphabetic ordering of arguments" ,
188+ messages : []llms.MessageContent {
189+ {
190+ Role : llms .ChatMessageTypeHuman ,
191+ Parts : []llms.ContentPart {
192+ llms.TextContent {Text : "hello echo" },
193+ },
194+ },
195+ },
196+ tools : []llms.Tool {
197+ {
198+ Type : "function" ,
199+ Function : & llms.FunctionDefinition {
200+ Name : "myfunc" ,
201+ Description : "A function that does something" ,
202+ Parameters : map [string ]any {
203+ "type" : "object" ,
204+ "properties" : map [string ]any {
205+ "unit" : map [string ]any {
206+ "type" : "string" ,
207+ "description" : "unit should come last" ,
208+ },
209+ "name" : map [string ]any {
210+ "type" : "string" ,
211+ "description" : "The name to process, should come second" ,
212+ },
213+ "location" : map [string ]any {
214+ "type" : "string" ,
215+ "description" : "location should come first" ,
216+ },
217+ },
218+ },
219+ },
220+ },
221+ },
222+ expected : & conversation.Response {
223+ Outputs : []conversation.Result {
224+ {
225+ StopReason : "tool_calls" ,
226+ Choices : []conversation.Choice {
227+ {
228+ FinishReason : "tool_calls" ,
229+ Index : 0 ,
230+ Message : conversation.Message {
231+ Content : "hello echo" ,
232+ ToolCallRequest : & []llms.ToolCall {
233+ {
234+ ID : "0" , // ID is auto-generated by the echo component
235+ Type : "function" ,
236+ FunctionCall : & llms.FunctionCall {
237+ Name : "myfunc" ,
238+ Arguments : "location,name,unit" ,
239+ },
240+ },
241+ },
242+ },
243+ },
244+ },
245+ },
246+ },
247+ },
248+ },
186249 {
187250 name : "text message with tool call response" ,
188251 // echo responds with the text message and tool call response appended to the message content
0 commit comments