One assistant message for all toolcalls

This commit is contained in:
Rob Lourens
2024-09-10 13:57:27 -07:00
parent 9d0ca04e6a
commit 777d32c1d8

View File

@ -116,16 +116,14 @@ function registerChatParticipant(context: vscode.ExtensionContext) {
}
if (toolCalls.length) {
let assistantMsg = vscode.LanguageModelChatMessage.Assistant('');
assistantMsg.content2 = toolCalls.map(toolCall => new vscode.LanguageModelChatResponseToolCallPart(toolCall.tool.id, toolCall.call.toolCallId, toolCall.call.parameters));
messages.push(assistantMsg);
for (const toolCall of toolCalls) {
let assistantMsg = vscode.LanguageModelChatMessage.Assistant('');
assistantMsg.content2 = [new vscode.LanguageModelChatResponseToolCallPart(toolCall.tool.id, toolCall.call.toolCallId, toolCall.call.parameters)];
messages.push(assistantMsg);
// NOTE that the result of calling a function is a special content type of a USER-message
let message = vscode.LanguageModelChatMessage.User('');
message.content2 = [new vscode.LanguageModelChatMessageToolResultPart(toolCall.call.toolCallId, (await toolCall.result).toString())];
messages.push(message);
}
// IMPORTANT The prompt must end with a USER message (with no tool call)