Skip to content

Commit 30eaa07

Browse files
Handle case when tool call response contains multiple calls
1 parent 817241d commit 30eaa07

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

Kattbot/NotificationHandlers/KattGptMessageHandler.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,12 @@ private async Task<List<ChatCompletionMessage>> HandleToolCallResponse(
256256
ChatCompletionToolCall toolCall =
257257
chatGptToolCallResponse.ToolCalls?[0] ?? throw new Exception("Tool call is null.");
258258

259+
if (chatGptToolCallResponse.ToolCalls.Count > 1)
260+
{
261+
_discordErrorLogger.LogError($"Too many tool calls: {chatGptToolCallResponse.ToolCalls.Count.ToString()}");
262+
chatGptToolCallResponse.ToolCalls.RemoveRange(index: 1, chatGptToolCallResponse.ToolCalls.Count - 1);
263+
}
264+
259265
// Parse the function call arguments
260266
string functionCallArguments = toolCall.FunctionCall.Arguments;
261267

Kattbot/Services/DiscordErrorLogger.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,6 @@ public void LogError(string error, string errorMessage)
7373
SendErrorLogChannelEmbed(error, errorMessage, DiscordConstants.ErrorEmbedColor);
7474
}
7575

76-
public void LogWarning(string warning, string warningMessage)
77-
{
78-
SendErrorLogChannelEmbed(warning, warningMessage, DiscordConstants.WarningEmbedColor);
79-
}
80-
8176
private void SendErrorLogChannelEmbed(string title, string message, int color)
8277
{
8378
ulong errorLogGuildId = _options.ErrorLogGuildId;

0 commit comments

Comments
 (0)