Skip to content

Commit ccddd4b

Browse files
committed
feature: show token usage in AI assistant result
Signed-off-by: leo <longshuang@msn.cn>
1 parent e6bfff8 commit ccddd4b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/AI/Agent.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,15 @@ public async Task GenerateCommitMessageAsync(string repo, string changeList, Act
4747
{
4848
case ChatFinishReason.Stop:
4949
onUpdate?.Invoke(string.Empty);
50-
onUpdate?.Invoke("[Assistant]:");
50+
onUpdate?.Invoke("# Assistant");
5151
if (completion.Content.Count > 0)
5252
onUpdate?.Invoke(completion.Content[0].Text);
5353
else
5454
onUpdate?.Invoke("[No content was generated.]");
55+
56+
onUpdate?.Invoke(string.Empty);
57+
onUpdate?.Invoke("# Token Usage");
58+
onUpdate?.Invoke($"Total: {completion.Usage.TotalTokenCount}. Input: {completion.Usage.InputTokenCount}. Output: {completion.Usage.OutputTokenCount}");
5559
break;
5660
case ChatFinishReason.Length:
5761
throw new Exception("The response was cut off because it reached the maximum length. Consider increasing the max tokens limit.");

0 commit comments

Comments
 (0)