|
|
@@ -1,3 +1,98 @@
|
|
|
+# DemandAgentV2 分支说明
|
|
|
+
|
|
|
+这个分支保存的是 2026-06 当前 DemandAgent New 的 V2 实现路线。
|
|
|
+
|
|
|
+V2 的核心目标不是回到最早的自由生成逻辑,而是优先保证给下游 ContentFindAgent 的需求单具备可回溯证据链:
|
|
|
+
|
|
|
+```text
|
|
|
+Hive 供需 gap
|
|
|
+ -> 选择 PG Pattern V2 success execution
|
|
|
+ -> 按 merge_leve2/platform 过滤 PG topic itemset
|
|
|
+ -> LLM 从候选 itemset 中挑选需求
|
|
|
+ -> 代码强校验 PG evidence
|
|
|
+ -> 写 MySQL demand_content.ext_data.evidence_pack
|
|
|
+```
|
|
|
+
|
|
|
+## V2 路线
|
|
|
+
|
|
|
+### 输入
|
|
|
+
|
|
|
+- Hive/ODPS 供需缺口表:
|
|
|
+ - `loghubods.video_dimension_detail_add_column`
|
|
|
+ - 用于得到 `merge二级品类`、缺量和请求生成数量。
|
|
|
+- PG Pattern V2 主事实表:
|
|
|
+ - `pattern_mining_execution`
|
|
|
+ - `pattern_itemset`
|
|
|
+ - `pattern_itemset_item`
|
|
|
+ - `pattern_itemset_post`
|
|
|
+ - `pattern_mining_category`
|
|
|
+ - `pattern_mining_element`
|
|
|
+ - `post`
|
|
|
+
|
|
|
+### 中间逻辑
|
|
|
+
|
|
|
+- 不再调用旧 MySQL Pattern 链路的 `run_mining()`。
|
|
|
+- 不再新建 `topic_pattern_execution`。
|
|
|
+- 默认读取最新 `status='success'` 且有 topic itemset 的 PG execution,也支持手工传 `--execution-id`。
|
|
|
+- 对每个 Hive gap 品类,用 `merge_leve2 + platform` 过滤该品类相关的 PG topic itemset。
|
|
|
+- 当前 V2 要求每条 DemandItem 绑定且只绑定一个 `itemset_id`。
|
|
|
+- `seed_terms`、`query_seed_points`、`demand_scope`、`source_certainty`、`validation_status` 都由代码从 PG DB 校验后补齐,不信任 LLM 生成。
|
|
|
+
|
|
|
+### 输出
|
|
|
+
|
|
|
+- 云端/测试服写 MySQL 单表:
|
|
|
+ - `content-deconstruction-supply.demand_content`
|
|
|
+- 核心字段:
|
|
|
+ - `id`
|
|
|
+ - `merge_leve2`
|
|
|
+ - `name`
|
|
|
+ - `reason`
|
|
|
+ - `suggestion`
|
|
|
+ - `score`
|
|
|
+ - `dt`
|
|
|
+ - `ext_data`
|
|
|
+- `ext_data.evidence_pack` 是 V2 的关键新增结构,包含:
|
|
|
+ - `pattern_source_system = "pg_pattern_v2"`
|
|
|
+ - `pattern_execution_id`
|
|
|
+ - `itemset_ids`
|
|
|
+ - `itemset_items`
|
|
|
+ - `matched_post_ids`
|
|
|
+ - `category_bindings`
|
|
|
+ - `element_bindings`
|
|
|
+ - `query_seed_points`
|
|
|
+ - `demand_scope`
|
|
|
+ - `source_certainty = "db_validated"`
|
|
|
+ - `validation_status = "passed"`
|
|
|
+
|
|
|
+### 优点
|
|
|
+
|
|
|
+- 每条入库需求都能 exact 回溯到 PG Pattern V2、分类树节点、支撑帖子和点位证据。
|
|
|
+- 下游 ContentFindAgent 可以直接消费 `query_seed_points` 做首轮搜索词池。
|
|
|
+- `element_bindings` 用于证明需求来源和 source post 的元素证据可以闭合。
|
|
|
+
|
|
|
+### 局限
|
|
|
+
|
|
|
+- 当前 V2 的生成逻辑偏“Pattern itemset 驱动”,不是最老版那种“高权重元素/分类 + 频繁项集综合探索”。
|
|
|
+- 每条需求强制绑定单个 itemset,证据清楚,但生成自由度比最老版低。
|
|
|
+- 需求名仍可能出现真实但偏泛的 Pattern item,例如 `群体`、`时间`、`分享`,后续 main 分支计划继续迭代质量筛选。
|
|
|
+
|
|
|
+## 与 DemandAgentOld 分支的区别
|
|
|
+
|
|
|
+`DemandAgentOld` 分支保存的是最早业务逻辑路线:
|
|
|
+
|
|
|
+```text
|
|
|
+Hive 供需 gap
|
|
|
+ -> 每个缺口品类调用 piaoquan_prepare()
|
|
|
+ -> run_mining() 新建 MySQL topic_pattern_execution
|
|
|
+ -> prepare() 生成高权重元素/分类分数
|
|
|
+ -> LLM 综合高权重元素、分类、共现和频繁项集
|
|
|
+ -> 写 demand_content
|
|
|
+```
|
|
|
+
|
|
|
+旧路线更像“需求生成脑子”,V2 路线更像“证据链骨架”。接下来 main 分支会继续尝试把两者合并:保留 V2 的 PG evidence,同时把最老版的高权重元素/分类判断能力补回来。
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
# Reson Agent
|
|
|
|
|
|
可扩展的 Agent 框架。支持多步工具调用、计划管理、子 Agent 协作、回溯重跑和上下文压缩。
|