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

@@ -20,11 +20,10 @@ from pathlib import Path
import httpx
import structlog
from src.core.config import get_settings
import src.repositories.rag_chunk_repository as rag_repo
from src.services.ollama_endpoint_resolver import resolve_ollama_endpoint
logger = structlog.get_logger(__name__)
settings = get_settings()
_EMBED_MODEL = "nomic-embed-text"
_GEN_MODEL = "qwen2.5:7b-instruct"
@@ -131,7 +130,7 @@ class KnowledgeRAGService:
try:
http = await self._get_http()
resp = await http.post(
f"{settings.OLLAMA_URL}/api/embeddings",
f"{resolve_ollama_endpoint('embedding')}/api/embeddings",
json={"model": _EMBED_MODEL, "prompt": text},
)
if resp.status_code == 200:
@@ -150,7 +149,7 @@ class KnowledgeRAGService:
try:
http = await self._get_http()
resp = await http.post(
f"{settings.OLLAMA_URL}/api/generate",
f"{resolve_ollama_endpoint('rag')}/api/generate",
json={
"model": _GEN_MODEL,
"prompt": prompt,