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

Method callModelRouter

internal/pluginhost/model_router.go:77–94  ·  view source on GitHub ↗
(ctx context.Context, pluginID string, router pluginapi.ModelRouter, req pluginapi.ModelRouteRequest)

Source from the content-addressed store, hash-verified

75}
76
77func (h *Host) callModelRouter(ctx context.Context, pluginID string, router pluginapi.ModelRouter, req pluginapi.ModelRouteRequest) (out pluginapi.ModelRouteResponse, ok bool) {
78 if h == nil || router == nil || h.isPluginFused(pluginID) {
79 return pluginapi.ModelRouteResponse{}, false
80 }
81 defer func() {
82 if recovered := recover(); recovered != nil {
83 h.fusePlugin(pluginID, "ModelRouter.RouteModel", recovered)
84 out = pluginapi.ModelRouteResponse{}
85 ok = false
86 }
87 }()
88 resp, errRoute := router.RouteModel(ctx, req)
89 if errRoute != nil {
90 log.WithField("plugin_id", pluginID).WithError(errRoute).Warn("pluginhost: model router failed")
91 return pluginapi.ModelRouteResponse{}, false
92 }
93 return resp, true
94}
95
96func normalizeModelRouteResponse(routerPluginID string, resp pluginapi.ModelRouteResponse) (pluginapi.ModelRouteResponse, bool) {
97 resp.TargetModel = strings.TrimSpace(resp.TargetModel)

Callers 1

RouteModelExceptMethod · 0.95

Calls 3

isPluginFusedMethod · 0.95
fusePluginMethod · 0.95
RouteModelMethod · 0.65

Tested by

no test coverage detected