(ctx context.Context, pluginID string, router pluginapi.ModelRouter, req pluginapi.ModelRouteRequest)
| 75 | } |
| 76 | |
| 77 | func (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 | |
| 96 | func normalizeModelRouteResponse(routerPluginID string, resp pluginapi.ModelRouteResponse) (pluginapi.ModelRouteResponse, bool) { |
| 97 | resp.TargetModel = strings.TrimSpace(resp.TargetModel) |
no test coverage detected