MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / HandleUsage

Method HandleUsage

internal/pluginhost/adapters.go:1807–1851  ·  view source on GitHub ↗
(ctx context.Context, record coreusage.Record)

Source from the content-addressed store, hash-verified

1805}
1806
1807func (a *usageAdapter) HandleUsage(ctx context.Context, record coreusage.Record) {
1808 if a == nil {
1809 return
1810 }
1811 plugin := a.host.currentUsagePlugin(a.pluginID)
1812 if plugin == nil {
1813 return
1814 }
1815 defer func() {
1816 if recovered := recover(); recovered != nil {
1817 a.host.fusePlugin(a.pluginID, "UsagePlugin.HandleUsage", recovered)
1818 }
1819 }()
1820 plugin.HandleUsage(ctx, pluginapi.UsageRecord{
1821 Provider: record.Provider,
1822 ExecutorType: record.ExecutorType,
1823 Model: record.Model,
1824 Alias: record.Alias,
1825 APIKey: record.APIKey,
1826 AuthID: record.AuthID,
1827 AuthIndex: record.AuthIndex,
1828 AuthType: record.AuthType,
1829 Source: record.Source,
1830 ReasoningEffort: record.ReasoningEffort,
1831 ServiceTier: record.ServiceTier,
1832 RequestedAt: record.RequestedAt,
1833 Latency: record.Latency,
1834 TTFT: record.TTFT,
1835 Failed: record.Failed,
1836 Failure: pluginapi.UsageFailure{
1837 StatusCode: record.Fail.StatusCode,
1838 Body: record.Fail.Body,
1839 },
1840 Detail: pluginapi.UsageDetail{
1841 InputTokens: record.Detail.InputTokens,
1842 OutputTokens: record.Detail.OutputTokens,
1843 ReasoningTokens: record.Detail.ReasoningTokens,
1844 CachedTokens: record.Detail.CachedTokens,
1845 CacheReadTokens: record.Detail.CacheReadTokens,
1846 CacheCreationTokens: record.Detail.CacheCreationTokens,
1847 TotalTokens: record.Detail.TotalTokens,
1848 },
1849 ResponseHeaders: cloneHeader(record.ResponseHeaders),
1850 })
1851}
1852
1853func (a *thinkingAdapter) Apply(body []byte, config thinking.ThinkingConfig, modelInfo *registry.ModelInfo) (out []byte, err error) {
1854 if a == nil || a.applier == nil || a.host == nil || a.host.isPluginFused(a.pluginID) || !a.host.pluginIdentityCurrent(a.pluginID, a.path, a.version) {

Calls 4

currentUsagePluginMethod · 0.80
fusePluginMethod · 0.80
cloneHeaderFunction · 0.70
HandleUsageMethod · 0.65