ai: add usage metadata for openai and mistral

This commit is contained in:
end-4
2025-08-07 21:53:37 +07:00
parent f581fd4821
commit 733a792610
2 changed files with 23 additions and 0 deletions
@@ -100,6 +100,17 @@ ApiStrategy {
message.content += newContent;
message.rawContent += newContent;
// Usage metadata
if (dataJson.usage) {
return {
tokenUsage: {
input: dataJson.usage.prompt_tokens ?? -1,
output: dataJson.usage.completion_tokens ?? -1,
total: dataJson.usage.total_tokens ?? -1
}
};
}
if (`dataJson`.done) {
return { finished: true };
}