From fb0ddf305cdf833afd8643e421be85fa745875eb Mon Sep 17 00:00:00 2001 From: OG T Date: Tue, 31 Mar 2026 14:03:34 +0800 Subject: [PATCH] fix(api): fix dockerfile to include models.json, remove huge prompt example to fit 4K limit --- apps/api/Dockerfile | 3 ++- apps/api/src/core/prompts.py | 42 ++---------------------------------- 2 files changed, 4 insertions(+), 41 deletions(-) diff --git a/apps/api/Dockerfile b/apps/api/Dockerfile index 6626259f..50f8a246 100644 --- a/apps/api/Dockerfile +++ b/apps/api/Dockerfile @@ -39,8 +39,9 @@ WORKDIR /app COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages COPY --from=builder /usr/local/bin /usr/local/bin -# Copy application code +# Copy application code and models config COPY apps/api/src/ ./src/ +COPY apps/api/models.json ./models.json # Create non-root user RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app diff --git a/apps/api/src/core/prompts.py b/apps/api/src/core/prompts.py index b1a623ab..cfa9f135 100644 --- a/apps/api/src/core/prompts.py +++ b/apps/api/src/core/prompts.py @@ -102,46 +102,8 @@ For each optimization suggestion, provide EXECUTABLE kubectl commands: } ``` -## 🔥 Example: High CPU with SignOz Data -Given SignOz metrics: RPS=150 (↑), Error=0.5%, P99=450ms (↑) - -```json -{ - "action_title": "擴展副本數 + 配置 HPA 自動擴展", - "description": "api-gateway CPU 飆高,SignOz 顯示 RPS 從 80 飆升至 150 (+87%),P99 從 200ms 升至 450ms。流量突增導致資源不足。", - "suggested_action": "SCALE_DEPLOYMENT", - "kubectl_command": "kubectl scale deployment/api-gateway --replicas=4 -n production", - "target_resource": "api-gateway", - "namespace": "production", - "risk_level": "medium", - "blast_radius": { - "affected_pods": 0, - "estimated_downtime": "0", - "related_services": [], - "data_impact": "NONE" - }, - "primary_responsibility": "INFRA", - "responsibility_reasoning": "流量突增但 HPA 未配置,屬基礎設施團隊責任", - "secondary_teams": ["BE"], - "optimization_suggestions": [ - { - "type": "HPA", - "description": "配置 CPU 基準 HPA,閾值 70%,基於 SignOz RPS 趨勢", - "kubectl_or_config": "kubectl autoscale deployment api-gateway --cpu-percent=70 --min=2 --max=10 -n production" - }, - { - "type": "RESOURCE_LIMIT", - "description": "增加 CPU limit 以應對流量峰值", - "kubectl_or_config": "kubectl set resources deployment/api-gateway --requests=cpu=500m --limits=cpu=2000m -n production" - } - ], - "reasoning": "SignOz 數據顯示流量突增為主因,非代碼問題。先擴容緩解,再配置 HPA 防止復發。", - "deviation_analysis": "RPS +87%,P99 延遲 +125%,超出基準線達 +4.2σ", - "confidence": 0.91, - "affected_services": ["api-gateway"], - "signoz_correlation": "RPS 與 CPU 使用率高度相關 (r=0.94),P99 上升為資源競爭導致" -} -``` +## 🔥 Short Example: High CPU -> SCALE_DEPLOYMENT, HPA, risk_level=medium +Please carefully justify your confidence between 0.0 and 1.0 (e.g. 0.82) based on symptoms and metrics. Now analyze the following alert with SignOz data: """