chore(align): sync Git with running container as authoritative source

Standards alignment (STANDARDS_AUDIT_2026-07-24): Phase 1 标准化核心 +
Phase 2 质量层 landed in the running container and captured in Git so the
three sources (container := image := Git) agree.

Backend (Phase 1 标准化核心):
- mcp_client.py: replaced hand-rolled JSON-RPC with official `mcp` SDK
  (ClientSession, streamable_http/sse transports, protocol auto-negotiation)
- core/otel.py + core/observability.py: standard OpenTelemetry SDK bridge
  (OTLP gRPC), wired to Grafana Alloy (qihu-aiflow-alloy:4317) which forwards
  metrics to Prometheus; emits aiflow_span_duration_ms / aiflow_span_count
- deployments: Grafana Alloy container + Prometheus remote-write receiver

Backend (Phase 2 质量层):
- core/rag_pipeline.py: standardized RAG (recursive overlap chunking +
  rerank hook) reusing pgvector_search
- core/llm_client.py: SDK-ified LLM + embeddings (aembed/embed) collapsing
  hand-rolled httpx calls; trust_env=False to bypass container proxy

Migrations:
- 018_normalize_marketapp_scene.sql: fixed capability allowlist
  (prevents capability wipe on restart)

Alignment performed 2026-07-24 12:18:51. No deletions; secrets/venv/node_modules/
caches were not touched (tracked-source-only copy).
This commit is contained in:
QihuAI Design committed 2026-07-24 12:18:52 +08:00
1 parent acde481bed
commit e8a1791c9f
8 files changed
+5031 -4779

No files matched your search

+10 -21
View File
@@ -135,27 +135,16 @@ async def get_embedding(text: str) -> Optional[List[float]]:
if cached:
return cached
try:
import httpx
async with httpx.AsyncClient(timeout=30, trust_env=False) as client:
resp = await client.post(
f"{EMBEDDING_API_URL}/v1/embeddings",
headers={
"Authorization": f"Bearer {EMBEDDING_API_KEY}",
"Content-Type": "application/json",
},
json={
"model": EMBEDDING_MODEL,
"input": text[:8000], # 截断防止超长
},
)
if resp.status_code == 200:
data = resp.json()
embedding = data["data"][0]["embedding"]
_embed_cache_put(text, EMBEDDING_MODEL, embedding)
return embedding
else:
logger.error(f"Embedding API error: {resp.status_code} {resp.text[:200]}")
return None
# 收敛到共享标准模型层(app.core.llm_client.aembed),与聊天共用代理/超时/failover 语义
from app.core.llm_client import aembed
embedding = await aembed(
EMBEDDING_API_URL, EMBEDDING_API_KEY, text[:8000], EMBEDDING_MODEL, timeout=30
)
if embedding:
_embed_cache_put(text, EMBEDDING_MODEL, embedding)
return embedding
logger.error("Embedding API returned empty")
return None
except Exception as e:
logger.error(f"Embedding generation failed: {e}")
return None