mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-21 13:20:30 +08:00
feature: show token usage in AI assistant result
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
@@ -47,11 +47,15 @@ namespace SourceGit.AI
|
||||
{
|
||||
case ChatFinishReason.Stop:
|
||||
onUpdate?.Invoke(string.Empty);
|
||||
onUpdate?.Invoke("[Assistant]:");
|
||||
onUpdate?.Invoke("# Assistant");
|
||||
if (completion.Content.Count > 0)
|
||||
onUpdate?.Invoke(completion.Content[0].Text);
|
||||
else
|
||||
onUpdate?.Invoke("[No content was generated.]");
|
||||
|
||||
onUpdate?.Invoke(string.Empty);
|
||||
onUpdate?.Invoke("# Token Usage");
|
||||
onUpdate?.Invoke($"Total: {completion.Usage.TotalTokenCount}. Input: {completion.Usage.InputTokenCount}. Output: {completion.Usage.OutputTokenCount}");
|
||||
break;
|
||||
case ChatFinishReason.Length:
|
||||
throw new Exception("The response was cut off because it reached the maximum length. Consider increasing the max tokens limit.");
|
||||
|
||||
Reference in New Issue
Block a user