MCPcopy
hub / github.com/mudler/LocalAI / recordHTTPDecision

Function recordHTTPDecision

core/http/middleware/route_model.go:213–225  ·  view source on GitHub ↗

recordHTTPDecision writes the resolved decision to the store with HTTP-shaped audit metadata (correlation id from header, user from auth middleware, fallback to the synthetic local user). Realtime has its own recorder that supplies session-derived metadata instead.

(c echo.Context, store router.DecisionStore, result *router.ResolveResult, fallbackUser *auth.User, source string)

Source from the content-addressed store, hash-verified

211// has its own recorder that supplies session-derived metadata
212// instead.
213func recordHTTPDecision(c echo.Context, store router.DecisionStore, result *router.ResolveResult, fallbackUser *auth.User, source string) {
214 correlationID, _ := c.Get(ContextKeyCorrelationID).(string)
215 if correlationID == "" {
216 correlationID = c.Response().Header().Get("X-Correlation-ID")
217 }
218 userID := ""
219 if u := auth.GetUser(c); u != nil {
220 userID = u.ID
221 } else if fallbackUser != nil {
222 userID = fallbackUser.ID
223 }
224 _ = store.Record(context.Background(), result.ToDecisionRecord(newDecisionID(), correlationID, userID, source))
225}
226
227// GetOrBuildClassifier looks up a built Classifier for the named router
228// model in the registry and builds it on miss. Exported so the

Callers 1

RouteModelFunction · 0.85

Calls 6

GetUserFunction · 0.92
newDecisionIDFunction · 0.85
HeaderMethod · 0.80
ToDecisionRecordMethod · 0.80
GetMethod · 0.65
RecordMethod · 0.65

Tested by

no test coverage detected