add plugins

This commit is contained in:
jinhui.li
2025-06-18 12:20:07 +08:00
parent 84cb9a2009
commit 57a7da14a3
6 changed files with 77 additions and 22 deletions

View File

@@ -68,7 +68,11 @@ export const router = async (
JSON.stringify(contentPart.input)
).length;
} else if (contentPart.type === "tool_result") {
tokenCount += enc.encode(contentPart.content || "").length;
tokenCount += enc.encode(
typeof contentPart.content === "string"
? contentPart.content
: JSON.stringify(contentPart.content)
).length;
}
});
}