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

Method CountTokens

internal/pluginhost/adapters.go:1718–1743  ·  view source on GitHub ↗
(ctx context.Context, auth *coreauth.Auth, req coreexecutor.Request, opts coreexecutor.Options)

Source from the content-addressed store, hash-verified

1716}
1717
1718func (a *executorAdapter) CountTokens(ctx context.Context, auth *coreauth.Auth, req coreexecutor.Request, opts coreexecutor.Options) (resp coreexecutor.Response, err error) {
1719 if a == nil || a.executor == nil || a.host.isPluginFused(a.pluginID) || !a.host.pluginIdentityCurrent(a.pluginID, a.path, a.version) {
1720 return coreexecutor.Response{}, fmt.Errorf("plugin executor %s is unavailable", a.Identifier())
1721 }
1722 defer func() {
1723 if recovered := recover(); recovered != nil {
1724 a.host.fusePlugin(a.pluginID, "Executor.CountTokens", recovered)
1725 resp = coreexecutor.Response{}
1726 err = fmt.Errorf("plugin executor %s count tokens panic: %v", a.Identifier(), recovered)
1727 }
1728 }()
1729
1730 prepared, errPrepare := a.prepareExecutorCall(req, opts)
1731 if errPrepare != nil {
1732 return coreexecutor.Response{}, errPrepare
1733 }
1734 pluginResp, errCountTokens := a.executor.CountTokens(ctx, buildExecutorRequest(a.host, a.provider, auth, prepared.req, prepared.opts))
1735 if errCountTokens != nil {
1736 return coreexecutor.Response{}, errCountTokens
1737 }
1738 return coreexecutor.Response{
1739 Payload: a.translateExecutorResponse(ctx, prepared, pluginResp.Payload, false, nil),
1740 Metadata: cloneAnyMap(pluginResp.Metadata),
1741 Headers: cloneHeader(pluginResp.Headers),
1742 }, nil
1743}
1744
1745func (a *executorAdapter) HttpRequest(ctx context.Context, auth *coreauth.Auth, req *http.Request) (resp *http.Response, err error) {
1746 if a == nil || a.executor == nil || a.host.isPluginFused(a.pluginID) || !a.host.pluginIdentityCurrent(a.pluginID, a.path, a.version) {

Callers

nothing calls this directly

Calls 10

IdentifierMethod · 0.95
prepareExecutorCallMethod · 0.95
buildExecutorRequestFunction · 0.85
cloneAnyMapFunction · 0.85
isPluginFusedMethod · 0.80
pluginIdentityCurrentMethod · 0.80
fusePluginMethod · 0.80
cloneHeaderFunction · 0.70
CountTokensMethod · 0.65

Tested by

no test coverage detected