fix(ai): isolate heavy Ollama workloads from GCP alert lane
All checks were successful
CD Pipeline / tests (push) Successful in 54s
Code Review / ai-code-review (push) Successful in 10s
CD Pipeline / build-and-deploy (push) Successful in 3m19s
CD Pipeline / post-deploy-checks (push) Successful in 3m12s

This commit is contained in:
Your Name
2026-05-05 23:05:59 +08:00
parent 1dcc6d61dc
commit c4854bb355
17 changed files with 146 additions and 84 deletions

View File

@@ -16,27 +16,37 @@ from src.core.config import settings
OllamaWorkloadType = Literal[
"interactive",
"healthcheck",
"alert_fast",
"batch",
"embedding",
"rag",
"code_review",
"shadow",
"canary",
"deep_rca",
"image_analysis",
"hermes",
"local_required",
"privacy_sensitive",
"dr",
]
_GCP_B_PREFERRED_WORKLOADS = {
_GCP_A_PREFERRED_WORKLOADS = {
"interactive",
"healthcheck",
"alert_fast",
}
_LOCAL_PREFERRED_WORKLOADS = {
"batch",
"embedding",
"rag",
"code_review",
"shadow",
"canary",
}
_LOCAL_PREFERRED_WORKLOADS = {
"deep_rca",
"image_analysis",
"hermes",
"local_required",
"privacy_sensitive",
"dr",
@@ -68,20 +78,28 @@ def resolve_ollama_selection(
secondary = cfg.OLLAMA_SECONDARY_URL
fallback = cfg.OLLAMA_FALLBACK_URL
if workload_type in _GCP_B_PREFERRED_WORKLOADS and secondary:
if workload_type in _LOCAL_PREFERRED_WORKLOADS:
if fallback:
return OllamaEndpointSelection(
url=fallback,
provider_name="ollama_local",
workload_type=workload_type,
reason="local_heavy_or_privacy_lane",
)
if secondary:
return OllamaEndpointSelection(
url=secondary,
provider_name="ollama_gcp_b",
workload_type=workload_type,
reason="local_missing_gcp_b_fallback",
)
if workload_type not in _GCP_A_PREFERRED_WORKLOADS and secondary:
return OllamaEndpointSelection(
url=secondary,
provider_name="ollama_gcp_b",
workload_type=workload_type,
reason="gcp_b_batch_lane",
)
if workload_type in _LOCAL_PREFERRED_WORKLOADS and fallback:
return OllamaEndpointSelection(
url=fallback,
provider_name="ollama_local",
workload_type=workload_type,
reason="local_privacy_or_dr_lane",
reason="gcp_b_default_non_alert_lane",
)
return OllamaEndpointSelection(