fix prompt logs for tools
This commit is contained in:
parent
b98c7a53af
commit
3d75fb4a2b
1 changed files with 13 additions and 2 deletions
|
|
@ -445,11 +445,22 @@ export abstract class BaseLLM implements ILLM {
|
|||
const msgsCopy = messages ? messages.map((msg) => ({ ...msg })) : [];
|
||||
let formatted = "";
|
||||
for (const msg of msgsCopy) {
|
||||
if ("content" in msg && Array.isArray(msg.content)) {
|
||||
let contentToShow = "";
|
||||
if (msg.role === "tool") {
|
||||
contentToShow = msg.content;
|
||||
} else if (msg.role === "assistant" && msg.toolCalls) {
|
||||
contentToShow = msg.toolCalls
|
||||
?.map(
|
||||
(toolCall) =>
|
||||
`${toolCall.function?.name}(${toolCall.function?.arguments})`,
|
||||
)
|
||||
.join("\n");
|
||||
} else if ("content" in msg && Array.isArray(msg.content)) {
|
||||
const content = renderChatMessage(msg);
|
||||
msg.content = content;
|
||||
}
|
||||
formatted += `<${msg.role}>\n${msg.content || ""}\n\n`;
|
||||
|
||||
formatted += `<${msg.role}>\n${contentToShow}\n\n`;
|
||||
}
|
||||
return formatted;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue