refactor: update LLMResponseUsage struct and ChatMessage usage aggregation

- Renamed fields in LLMResponseUsage struct to better reflect their purpose, changing InputTokens and OutputTokens to PromptTokens and CompletionTokens.
- Modified GetUsage method in ChatMessage to accept an optional contents parameter, improving flexibility in usage tracking.
- Ensured consistent field naming and improved clarity in token usage aggregation logic.
This commit is contained in:
Marvin Zhang
2025-04-14 16:29:32 +08:00
parent 8273507d20
commit 67b51fdc83
2 changed files with 11 additions and 8 deletions

View File

@@ -1,7 +1,7 @@
package entity
type LLMResponseUsage struct {
InputTokens int `json:"input_tokens" bson:"input_tokens"`
OutputTokens int `json:"output_tokens" bson:"output_tokens"`
TotalTokens int `json:"total_tokens" bson:"total_tokens"`
PromptTokens int `json:"prompt_tokens" bson:"prompt_tokens"`
CompletionTokens int `json:"completion_tokens" bson:"completion_tokens"`
TotalTokens int `json:"total_tokens" bson:"total_tokens"`
}