From 61f5adcd35ad3882825ea0aa07ade7de67ba57f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E6=98=9F=E7=B9=81?= Date: Sat, 8 Mar 2025 21:36:21 +0800 Subject: [PATCH 1/2] fix: make sure function call is omitted when empty --- src/Cnblogs.DashScope.AI/DashScopeChatClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cnblogs.DashScope.AI/DashScopeChatClient.cs b/src/Cnblogs.DashScope.AI/DashScopeChatClient.cs index 8b0012f..65e3eac 100644 --- a/src/Cnblogs.DashScope.AI/DashScopeChatClient.cs +++ b/src/Cnblogs.DashScope.AI/DashScopeChatClient.cs @@ -464,7 +464,7 @@ private IEnumerable ToTextChatMessages( from.Text ?? string.Empty, from.AuthorName, null, - functionCall); + functionCall.Count > 0 ? functionCall : null); } } From 1684a8a734030ee65d0c010ce38c70ae86925ceb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E6=98=9F=E7=B9=81?= Date: Sat, 8 Mar 2025 21:37:28 +0800 Subject: [PATCH 2/2] chore: add comments of error --- src/Cnblogs.DashScope.AI/DashScopeChatClient.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Cnblogs.DashScope.AI/DashScopeChatClient.cs b/src/Cnblogs.DashScope.AI/DashScopeChatClient.cs index 65e3eac..f28456f 100644 --- a/src/Cnblogs.DashScope.AI/DashScopeChatClient.cs +++ b/src/Cnblogs.DashScope.AI/DashScopeChatClient.cs @@ -459,6 +459,9 @@ private IEnumerable ToTextChatMessages( tools?.FindIndex(f => f.Function?.Name == c.Name) ?? -1, new FunctionCall(c.Name, JsonSerializer.Serialize(c.Arguments, ToolCallJsonSerializerOptions)))) .ToList(); + + // function all array must be null when empty + // <400> InternalError.Algo.InvalidParameter: Empty tool_calls is not supported in message yield return new TextChatMessage( from.Role.Value, from.Text ?? string.Empty,