LocalAI/core/http/middleware
Richard Palethorpe c60ed75258 feat(middleware): Model routing, PII filtering, Cloud model proxies
Add a routing middleware stack and a cloud-proxy backend.

* cloud-proxy: a Go gRPC backend that forwards OpenAI- and
  Anthropic-shaped chat requests to upstream providers, with an
  optional translate mode (OpenAI request -> Anthropic /v1/messages
  -> OpenAI response) and full tool-calling support.

* routing: admission control, content-aware model routing
  (embedding cache + classifier + rerank + Arch-Router score),
  PII detection/redaction (regex + NER) with streaming filter and
  OpenAI/Anthropic adapters, and a per-user/per-key billing recorder
  backed by GORM or in-memory storage.

* middleware: UsageMiddleware records usage via the billing recorder,
  plus admission, route-model, usage-stamp and trace middlewares.

* observability: BackendTrace ring buffer stores full request bodies
  (capped), MITM proxy emits structured trace events, and router
  classifier decisions surface at /api/router/decide.

* gallery: Arch-Router-1.5B (Q4_K_M and Q8_0).

* UI: cloud-proxy model-editor fields, classifier system-prompt and
  score-normalization config, and a Traces page rendering request
  bodies.

Assisted-by: claude-code:claude-opus-4-7 [Read] [Edit] [Bash]
Signed-off-by: Richard Palethorpe <io@richiejp.com>
2026-05-24 09:42:31 +01:00
..
admission.go feat(middleware): Model routing, PII filtering, Cloud model proxies 2026-05-24 09:42:31 +01:00
admission_test.go feat(middleware): Model routing, PII filtering, Cloud model proxies 2026-05-24 09:42:31 +01:00
baseurl.go fix(http): honor X-Forwarded-Prefix when proxy strips the prefix (#9614) 2026-05-13 21:59:33 +02:00
baseurl_test.go fix(http): honor X-Forwarded-Prefix when proxy strips the prefix (#9614) 2026-05-13 21:59:33 +02:00
context_keys.go feat(middleware): Model routing, PII filtering, Cloud model proxies 2026-05-24 09:42:31 +01:00
forwarded_prefix.go chore: Security hardening (#9719) 2026-05-08 16:25:45 +02:00
forwarded_prefix_test.go chore: Security hardening (#9719) 2026-05-08 16:25:45 +02:00
middleware_suite_test.go feat: migrate to echo and enable cancellation of non-streaming requests (#7270) 2025-11-14 22:57:53 +01:00
request.go feat(middleware): Model routing, PII filtering, Cloud model proxies 2026-05-24 09:42:31 +01:00
request_test.go feat(middleware): Model routing, PII filtering, Cloud model proxies 2026-05-24 09:42:31 +01:00
route_model.go feat(middleware): Model routing, PII filtering, Cloud model proxies 2026-05-24 09:42:31 +01:00
route_model_test.go feat(middleware): Model routing, PII filtering, Cloud model proxies 2026-05-24 09:42:31 +01:00
security_headers.go chore: Security hardening (#9719) 2026-05-08 16:25:45 +02:00
security_headers_test.go chore: Security hardening (#9719) 2026-05-08 16:25:45 +02:00
strippathprefix.go chore: Security hardening (#9719) 2026-05-08 16:25:45 +02:00
strippathprefix_test.go feat: migrate to echo and enable cancellation of non-streaming requests (#7270) 2025-11-14 22:57:53 +01:00
trace.go feat(middleware): Model routing, PII filtering, Cloud model proxies 2026-05-24 09:42:31 +01:00
trace_body_cap_test.go fix(traces): cap captured body size to keep admin Traces UI responsive (#9946) 2026-05-22 15:29:24 +02:00
trace_redact_test.go chore: Security hardening (#9719) 2026-05-08 16:25:45 +02:00
usage.go feat(middleware): Model routing, PII filtering, Cloud model proxies 2026-05-24 09:42:31 +01:00
usage_stamp.go feat(middleware): Model routing, PII filtering, Cloud model proxies 2026-05-24 09:42:31 +01:00
usage_test.go feat(middleware): Model routing, PII filtering, Cloud model proxies 2026-05-24 09:42:31 +01:00