fix(ai): enforce ollama first for drift governance
This commit is contained in:
@@ -21,7 +21,7 @@ from typing import TYPE_CHECKING
|
||||
|
||||
import structlog
|
||||
|
||||
from src.models.drift import DriftIntent, DriftInterpretation, DriftItem
|
||||
from src.models.drift import DriftIntent, DriftInterpretation
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from src.models.drift import DriftReport
|
||||
@@ -62,7 +62,7 @@ class NemotronDriftInterpreter:
|
||||
❌ 不直接呼叫 kubectl 或 git
|
||||
"""
|
||||
|
||||
async def analyze(self, report: "DriftReport") -> DriftInterpretation:
|
||||
async def analyze(self, report: DriftReport) -> DriftInterpretation:
|
||||
"""
|
||||
分析漂移意圖
|
||||
|
||||
@@ -85,7 +85,7 @@ class NemotronDriftInterpreter:
|
||||
result = await self._call_nemotron(prompt)
|
||||
return result
|
||||
|
||||
def _format_diff_for_prompt(self, report: "DriftReport") -> str:
|
||||
def _format_diff_for_prompt(self, report: DriftReport) -> str:
|
||||
"""格式化 diff 給 Nemotron 分析用"""
|
||||
lines = []
|
||||
for item in report.items[:10]: # 最多 10 項避免 token 過多
|
||||
@@ -111,7 +111,17 @@ class NemotronDriftInterpreter:
|
||||
try:
|
||||
from src.services.openclaw import get_openclaw
|
||||
openclaw = get_openclaw()
|
||||
response_text, _provider, success = await openclaw.call(prompt)
|
||||
response_text, _provider, success = await openclaw.call(
|
||||
prompt,
|
||||
alert_context={
|
||||
"intent_hint": "config",
|
||||
"task_type": "diagnose",
|
||||
"enforce_ollama_first": True,
|
||||
"allow_gcp_heavy_model": True,
|
||||
"target_resource": "config-drift",
|
||||
"alert_type": "ConfigDriftInternalScan",
|
||||
},
|
||||
)
|
||||
|
||||
if not success or not response_text:
|
||||
logger.warning("drift_interpreter_openclaw_failed", provider=_provider)
|
||||
|
||||
Reference in New Issue
Block a user