(ctx context.Context, request []byte)
| 267 | } |
| 268 | |
| 269 | func (h *Host) callHostModelExecute(ctx context.Context, request []byte) ([]byte, error) { |
| 270 | var req rpcHostModelExecutionRequest |
| 271 | if errUnmarshal := json.Unmarshal(request, &req); errUnmarshal != nil { |
| 272 | return nil, fmt.Errorf("decode host model execution request: %w", errUnmarshal) |
| 273 | } |
| 274 | if req.Stream { |
| 275 | return nil, fmt.Errorf("host.model.execute requires stream=false") |
| 276 | } |
| 277 | executor := h.currentModelExecutor() |
| 278 | if executor == nil { |
| 279 | return nil, fmt.Errorf("host model executor is unavailable") |
| 280 | } |
| 281 | skipPluginID := h.callbackCallerPluginID(ctx, req.HostCallbackID) |
| 282 | ctx = h.resolveCallbackContext(req.HostCallbackID, ctx) |
| 283 | resp, errMsg := executor.ExecuteModel(ctx, modelExecutionRequestFromPlugin(req.HostModelExecutionRequest, skipPluginID)) |
| 284 | if errMsg != nil { |
| 285 | return nil, modelExecutionError(errMsg) |
| 286 | } |
| 287 | return marshalRPCResult(pluginapi.HostModelExecutionResponse{ |
| 288 | StatusCode: resp.StatusCode, |
| 289 | Headers: cloneHeader(resp.Headers), |
| 290 | Body: append([]byte(nil), resp.Body...), |
| 291 | }) |
| 292 | } |
| 293 | |
| 294 | func modelExecutionRequestFromPlugin(req pluginapi.HostModelExecutionRequest, skipPluginID string) handlers.ModelExecutionRequest { |
| 295 | return handlers.ModelExecutionRequest{ |
no test coverage detected