From f1016b610ad3b7d425bacc3f5caaa340c49f1982 Mon Sep 17 00:00:00 2001 From: shangfangjian Date: Tue, 22 Sep 2026 01:19:19 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20predict.py=20docstring=20=E8=A1=A5?= =?UTF-8?q?=E8=90=BD=E5=BA=93=E5=B1=82=E7=BA=A7=E8=A1=A8=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 明确 single/multi/baseline 均在服务层(_upsert_prediction)落库, 路由层永不写入 predictions,仅做 result → PredictOut 映射。 --- src/llm/predict.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/llm/predict.py b/src/llm/predict.py index c582df4..7220571 100644 --- a/src/llm/predict.py +++ b/src/llm/predict.py @@ -1,4 +1,16 @@ -"""预测服务:拼上下文 → 调 LLM → 存预测。""" +"""预测服务:拼上下文 → 调 LLM → 存预测。 + +落库层级(table: predictions): + +| 模式 | 落库位置(服务层) | 路由层(routes/predict.py) | +|-----------|-------------------------------------------------------------|---------------------------| +| single | `_predict_single` → `_upsert_prediction` | 不读 DB,仅映射 result → PredictOut | +| multi | `orchestrator.predict_match_multi` → `_upsert_prediction` | 不读 DB,仅映射 result → PredictOut | +| baseline | `predict_baseline` → `_upsert_prediction` | 不读 DB,仅映射 result → PredictOut | + +三种模式统一在服务层经 UnitOfWork 落库并回填真实 prediction_id; +路由层永不写入 predictions,只读 result.prediction_id 做响应映射。 +""" from __future__ import annotations import functools