MCPcopy
hub / github.com/wavetermdev/waveterm / getUsage

Function getUsage

pkg/aiusechat/usechat.go:190–206  ·  view source on GitHub ↗
(msgs []uctypes.GenAIMessage)

Source from the content-addressed store, hash-verified

188}
189
190func getUsage(msgs []uctypes.GenAIMessage) uctypes.AIUsage {
191 var rtn uctypes.AIUsage
192 var found bool
193 for _, msg := range msgs {
194 if usage := msg.GetUsage(); usage != nil {
195 if !found {
196 rtn = *usage
197 found = true
198 } else {
199 rtn.InputTokens += usage.InputTokens
200 rtn.OutputTokens += usage.OutputTokens
201 rtn.NativeWebSearchCount += usage.NativeWebSearchCount
202 }
203 }
204 }
205 return rtn
206}
207
208func GetChatUsage(chat *uctypes.AIChat) uctypes.AIUsage {
209 usage := getUsage(chat.NativeMessages)

Callers 2

GetChatUsageFunction · 0.85
RunAIChatFunction · 0.85

Calls 1

GetUsageMethod · 0.65

Tested by

no test coverage detected