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

Function modelsFromContext

core/http/middleware/usage.go:244–254  ·  view source on GitHub ↗

modelsFromContext returns (requested, served) using context-set values when present, falling back to the response-reported model for both. The router middleware (subsystem 2 of the routing plan) populates these; until it lands they are equal.

(c echo.Context, fallback string)

Source from the content-addressed store, hash-verified

242// The router middleware (subsystem 2 of the routing plan) populates
243// these; until it lands they are equal.
244func modelsFromContext(c echo.Context, fallback string) (string, string) {
245 requested := fallback
246 served := fallback
247 if v, ok := c.Get(ContextKeyRequestedModel).(string); ok && v != "" {
248 requested = v
249 }
250 if v, ok := c.Get(ContextKeyServedModel).(string); ok && v != "" {
251 served = v
252 }
253 return requested, served
254}
255
256func promptTokensFromContext(c echo.Context, fallback int64) (int64, int64) {
257 pre := fallback

Callers 1

UsageMiddlewareFunction · 0.85

Calls 1

GetMethod · 0.65

Tested by

no test coverage detected