fix(ai): isolate heavy Ollama workloads from GCP alert lane
This commit is contained in:
@@ -26,7 +26,7 @@ from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import re
|
||||
from dataclasses import dataclass, field
|
||||
from dataclasses import dataclass
|
||||
from typing import TYPE_CHECKING, Any, Literal
|
||||
|
||||
import httpx
|
||||
@@ -125,7 +125,7 @@ class DecisionFusionAdapter:
|
||||
# Public API
|
||||
# =========================================================================
|
||||
|
||||
async def fuse_decision(self, event: "AiGovernanceEvent") -> FusedDecision:
|
||||
async def fuse_decision(self, event: AiGovernanceEvent) -> FusedDecision:
|
||||
"""三維融合:LLM × Playbook × MCP → FusedDecision。
|
||||
|
||||
三個維度並行評估(asyncio.gather),任一失敗靜默降為 0.5。
|
||||
@@ -226,7 +226,7 @@ class DecisionFusionAdapter:
|
||||
# =========================================================================
|
||||
|
||||
async def _score_llm(
|
||||
self, event: "AiGovernanceEvent"
|
||||
self, event: AiGovernanceEvent
|
||||
) -> tuple[float, str, dict[str, Any]]:
|
||||
"""Ollama LLM 推理:治理事件情境 → 建議動作 + 信心度。
|
||||
|
||||
@@ -254,7 +254,9 @@ class DecisionFusionAdapter:
|
||||
"只輸出 CONFIDENCE 和 ACTION 兩行,不要其他解釋。"
|
||||
)
|
||||
|
||||
ollama_url = getattr(self._settings, "OLLAMA_URL", "http://192.168.0.111:11434") # 2026-05-04 ogt: ADR-110 修正 — 111 primary
|
||||
from src.services.ollama_endpoint_resolver import resolve_ollama_endpoint
|
||||
|
||||
ollama_url = resolve_ollama_endpoint("deep_rca")
|
||||
|
||||
try:
|
||||
async with httpx.AsyncClient(
|
||||
@@ -320,7 +322,7 @@ class DecisionFusionAdapter:
|
||||
# =========================================================================
|
||||
|
||||
async def _score_playbook(
|
||||
self, event: "AiGovernanceEvent"
|
||||
self, event: AiGovernanceEvent
|
||||
) -> tuple[float, str | None, float | None]:
|
||||
"""Playbook 相似度比對 → 取最高 trust_score。
|
||||
|
||||
@@ -373,7 +375,7 @@ class DecisionFusionAdapter:
|
||||
# =========================================================================
|
||||
|
||||
async def _score_mcp(
|
||||
self, event: "AiGovernanceEvent"
|
||||
self, event: AiGovernanceEvent
|
||||
) -> tuple[float, dict[str, Any]]:
|
||||
"""Prometheus 情報採集 → MCP 感官品質分數。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user