ResolvePIIPolicy resolves the effective request-side PII policy for a consuming model, layering the instance-wide default detector (PIIDefaultDetectors, set via POST /api/settings) on top of the per-model config. It is the single decision point shared by the chat middleware (via WithPolicyResolver)
(cfg *config.ModelConfig)
| 341 | // appConfig is read live, so changes via the settings API take effect on the |
| 342 | // next request without a restart. |
| 343 | func (a *Application) ResolvePIIPolicy(cfg *config.ModelConfig) (enabled bool, detectors []string) { |
| 344 | if cfg == nil { |
| 345 | return false, nil |
| 346 | } |
| 347 | appCfg := a.ApplicationConfig() |
| 348 | |
| 349 | // PIIIsEnabled already encodes "explicit pii.enabled wins, else backend |
| 350 | // default (cloud-proxy)" — the single source of that rule. |
| 351 | enabled = cfg.PIIIsEnabled() |
| 352 | if !enabled { |
| 353 | return false, nil |
| 354 | } |
| 355 | |
| 356 | detectors = cfg.PIIDetectors() |
| 357 | if len(detectors) == 0 { |
| 358 | detectors = append([]string(nil), appCfg.PIIDefaultDetectors...) |
| 359 | } |
| 360 | return true, detectors // enabled is necessarily true past the !enabled guard |
| 361 | } |
| 362 | |
| 363 | // PIIPolicyResolver adapts ResolvePIIPolicy to pii.PolicyResolver for |
| 364 | // pii.WithPolicyResolver. The middleware carries the resolved model config as |
no test coverage detected