MCPcopy Create free account
hub / github.com/astercloud/aster / GetCounter

Method GetCounter

pkg/context/token_counter.go:377–391  ·  view source on GitHub ↗

GetCounter 获取指定模型的计数器

(modelName string)

Source from the content-addressed store, hash-verified

375
376// GetCounter 获取指定模型的计数器
377func (m *MultiModelTokenCounter) GetCounter(modelName string) TokenCounter {
378 if counter, ok := m.counters[modelName]; ok {
379 return counter
380 }
381
382 // 尝试模糊匹配
383 lowerModelName := strings.ToLower(modelName)
384 for name, counter := range m.counters {
385 if strings.Contains(lowerModelName, strings.ToLower(name)) {
386 return counter
387 }
388 }
389
390 return m.default_
391}
392
393// CountForModel 为指定模型计算 Token 数
394func (m *MultiModelTokenCounter) CountForModel(ctx context.Context, modelName string, text string) (int, error) {

Callers 3

CountForModelMethod · 0.95

Calls

no outgoing calls

Tested by 1