MCPcopy Create free account
hub / github.com/InferCore/InferCore / buildResponse

Function buildResponse

internal/replay/replay.go:225–247  ·  view source on GitHub ↗
(cfg *config.Config, req types.AIRequest, policyReason string, primary types.RouteDecision, exec types.ExecutionResult, requestID, traceID string)

Source from the content-addressed store, hash-verified

223}
224
225func buildResponse(cfg *config.Config, req types.AIRequest, policyReason string, primary types.RouteDecision, exec types.ExecutionResult, requestID, traceID string) types.AIResponse {
226 chosenBackendCfg, _ := cfg.BackendByName(exec.BackendName)
227 latency := int64(0)
228 return types.AIResponse{
229 RequestID: requestID,
230 TraceID: traceID,
231 RequestType: req.RequestType,
232 PipelineRef: req.PipelineRef,
233 SelectedBackend: exec.BackendName,
234 RouteReason: primary.Reason,
235 PolicyReason: policyReason,
236 EffectivePriority: req.Priority,
237 Status: exec.Status,
238 Result: exec.Output,
239 Metrics: types.AIMetrics{
240 CompletionLatencyMs: latency,
241 EstimatedCost: chosenBackendCfg.Cost.Unit,
242 ServerReceivedAtUnix: time.Now().UnixMilli(),
243 },
244 Fallback: types.FallbackState{Triggered: exec.UsedFallback},
245 Degrade: types.DegradeState{},
246 }
247}
248
249// NewDependenciesFromConfig builds policy/router/reliability for CLI replay.
250func NewDependenciesFromConfig(cfg *config.Config, adapters map[string]interfaces.BackendAdapter, retrievalAdapters map[string]interfaces.RetrievalAdapter) Dependencies {

Callers 2

replayExactFunction · 0.85
replayCurrentFunction · 0.85

Calls 1

BackendByNameMethod · 0.80

Tested by

no test coverage detected