mirror of
https://github.com/primedigitaltech/market-assistant.git
synced 2026-07-25 01:34:47 +08:00
fix(strategy): 探针模式下从 structured_brief 再移除策略提示与情感词表
与第八章条形图同源的策略提示句和规则情感词表不再传入策略大模型;导出脚本与快照已同步,单测覆盖省略字段。 Made-with: Cursor
This commit is contained in:
parent
ce4cef3235
commit
7506f9795c
@ -69,7 +69,6 @@ def main() -> int:
|
|||||||
from pipeline.reporting.report_strategy_excerpt import load_report_strategy_excerpt
|
from pipeline.reporting.report_strategy_excerpt import load_report_strategy_excerpt
|
||||||
from pipeline.reporting.strategy_draft import (
|
from pipeline.reporting.strategy_draft import (
|
||||||
build_strategy_draft_markdown,
|
build_strategy_draft_markdown,
|
||||||
filter_strategy_hints_for_ch8_probe,
|
|
||||||
report_uses_chapter8_text_mining_probe,
|
report_uses_chapter8_text_mining_probe,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -168,10 +167,6 @@ def main() -> int:
|
|||||||
if report_uses_chapter8_text_mining_probe(rc):
|
if report_uses_chapter8_text_mining_probe(rc):
|
||||||
compact = dict(compact)
|
compact = dict(compact)
|
||||||
_omit_ch8_probe_wordchart_fields(compact)
|
_omit_ch8_probe_wordchart_fields(compact)
|
||||||
if isinstance(compact.get("strategy_hints"), list):
|
|
||||||
compact["strategy_hints"] = filter_strategy_hints_for_ch8_probe(
|
|
||||||
compact["strategy_hints"]
|
|
||||||
)
|
|
||||||
ex = (
|
ex = (
|
||||||
_truncate_strategy_narrative(excerpt_raw, excerpt_max)
|
_truncate_strategy_narrative(excerpt_raw, excerpt_max)
|
||||||
if excerpt_raw
|
if excerpt_raw
|
||||||
@ -200,8 +195,8 @@ def main() -> int:
|
|||||||
}
|
}
|
||||||
if report_uses_chapter8_text_mining_probe(rc):
|
if report_uses_chapter8_text_mining_probe(rc):
|
||||||
payload["structured_brief_omission_note"] = (
|
payload["structured_brief_omission_note"] = (
|
||||||
"已启用第八章文本挖掘(探针为主):structured_brief 已省略顶层「关注词/场景子串计数」、按细类 feedback 中的 focus_keyword_hits/scenarios_top,"
|
"已启用第八章文本挖掘(探针为主):structured_brief 已省略「关注词/场景子串计数」、按细类 feedback 中的 focus_keyword_hits/scenarios_top、"
|
||||||
"以及「与条形图同源的 strategy_hints 句子」,避免与报告 §8 主口径冲突。**不得**再以这类子串计数或预设场景占比作为论据。"
|
"`strategy_hints`、`comment_sentiment_lexicon`(规则词表/条形图同源),避免与报告 §8 文本挖掘主口径冲突。**不得**再以这类子串计数或预设场景占比作为论据。"
|
||||||
"用户与评论侧须依报告 §8 文本挖掘归纳及 `report_matrix_group_evidence_md`;**促销、满减、券价差**须与报告第六章、`price_promotion_signals` 及下方 `report_strategy_excerpt`(第九章)对齐,不得省略报告已写明的活动建议。"
|
"用户与评论侧须依报告 §8 文本挖掘归纳及 `report_matrix_group_evidence_md`;**促销、满减、券价差**须与报告第六章、`price_promotion_signals` 及下方 `report_strategy_excerpt`(第九章)对齐,不得省略报告已写明的活动建议。"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,6 @@ from typing import Any
|
|||||||
from ..reporting.brief_compact import compact_brief_for_llm
|
from ..reporting.brief_compact import compact_brief_for_llm
|
||||||
from ..reporting.strategy_draft import (
|
from ..reporting.strategy_draft import (
|
||||||
build_strategy_draft_markdown,
|
build_strategy_draft_markdown,
|
||||||
filter_strategy_hints_for_ch8_probe,
|
|
||||||
report_uses_chapter8_text_mining_probe,
|
report_uses_chapter8_text_mining_probe,
|
||||||
)
|
)
|
||||||
from .llm_client import call_llm, estimate_chat_input_tokens, llm_context_window_size
|
from .llm_client import call_llm, estimate_chat_input_tokens, llm_context_window_size
|
||||||
@ -26,6 +25,8 @@ def _omit_ch8_probe_wordchart_fields(compact: dict[str, Any]) -> None:
|
|||||||
"usage_scenarios",
|
"usage_scenarios",
|
||||||
"usage_scenarios_denominator",
|
"usage_scenarios_denominator",
|
||||||
"usage_scenarios_by_matrix_group",
|
"usage_scenarios_by_matrix_group",
|
||||||
|
"comment_sentiment_lexicon",
|
||||||
|
"strategy_hints",
|
||||||
):
|
):
|
||||||
compact.pop(k, None)
|
compact.pop(k, None)
|
||||||
cfb = compact.get("consumer_feedback_by_matrix_group")
|
cfb = compact.get("consumer_feedback_by_matrix_group")
|
||||||
@ -187,10 +188,6 @@ def generate_strategy_draft_markdown_llm(
|
|||||||
if report_uses_chapter8_text_mining_probe(report_config):
|
if report_uses_chapter8_text_mining_probe(report_config):
|
||||||
compact = dict(compact)
|
compact = dict(compact)
|
||||||
_omit_ch8_probe_wordchart_fields(compact)
|
_omit_ch8_probe_wordchart_fields(compact)
|
||||||
if isinstance(compact.get("strategy_hints"), list):
|
|
||||||
compact["strategy_hints"] = filter_strategy_hints_for_ch8_probe(
|
|
||||||
compact["strategy_hints"]
|
|
||||||
)
|
|
||||||
ex = (
|
ex = (
|
||||||
_truncate_strategy_narrative(excerpt_raw, excerpt_max)
|
_truncate_strategy_narrative(excerpt_raw, excerpt_max)
|
||||||
if excerpt_raw
|
if excerpt_raw
|
||||||
@ -222,8 +219,8 @@ def generate_strategy_draft_markdown_llm(
|
|||||||
}
|
}
|
||||||
if report_uses_chapter8_text_mining_probe(report_config):
|
if report_uses_chapter8_text_mining_probe(report_config):
|
||||||
payload["structured_brief_omission_note"] = (
|
payload["structured_brief_omission_note"] = (
|
||||||
"已启用第八章文本挖掘(探针为主):structured_brief 已省略顶层「关注词/场景子串计数」、按细类 feedback 中的 focus_keyword_hits/scenarios_top,"
|
"已启用第八章文本挖掘(探针为主):structured_brief 已省略「关注词/场景子串计数」、按细类 feedback 中的 focus_keyword_hits/scenarios_top、"
|
||||||
"以及「与条形图同源的 strategy_hints 句子」,避免与报告 §8 主口径冲突。**不得**再以这类子串计数或预设场景占比作为论据。"
|
"``strategy_hints``、``comment_sentiment_lexicon``(规则词表/条形图同源),避免与报告 §8 文本挖掘主口径冲突。**不得**再以这类子串计数、短语条形图或预设场景占比作为论据。"
|
||||||
"用户与评论侧须依报告 §8 文本挖掘归纳及 `report_matrix_group_evidence_md`;**促销、满减、券价差**须与报告第六章、`price_promotion_signals` 及下方 `report_strategy_excerpt`(第九章)对齐,不得省略报告已写明的活动建议。"
|
"用户与评论侧须依报告 §8 文本挖掘归纳及 `report_matrix_group_evidence_md`;**促销、满减、券价差**须与报告第六章、`price_promotion_signals` 及下方 `report_strategy_excerpt`(第九章)对齐,不得省略报告已写明的活动建议。"
|
||||||
)
|
)
|
||||||
raw = json.dumps(payload, ensure_ascii=False)
|
raw = json.dumps(payload, ensure_ascii=False)
|
||||||
|
|||||||
@ -169,6 +169,8 @@ class StrategyDraftTests(SimpleTestCase):
|
|||||||
compact = {
|
compact = {
|
||||||
"comment_focus_keywords": [{"word": "x", "count": 1}],
|
"comment_focus_keywords": [{"word": "x", "count": 1}],
|
||||||
"usage_scenarios": [],
|
"usage_scenarios": [],
|
||||||
|
"comment_sentiment_lexicon": {"pos": ["好"], "neg": ["差"]},
|
||||||
|
"strategy_hints": ["条形图同源句子"],
|
||||||
"consumer_feedback_by_matrix_group": [
|
"consumer_feedback_by_matrix_group": [
|
||||||
{
|
{
|
||||||
"group": "饼干",
|
"group": "饼干",
|
||||||
@ -180,6 +182,8 @@ class StrategyDraftTests(SimpleTestCase):
|
|||||||
}
|
}
|
||||||
_omit_ch8_probe_wordchart_fields(compact)
|
_omit_ch8_probe_wordchart_fields(compact)
|
||||||
self.assertNotIn("comment_focus_keywords", compact)
|
self.assertNotIn("comment_focus_keywords", compact)
|
||||||
|
self.assertNotIn("comment_sentiment_lexicon", compact)
|
||||||
|
self.assertNotIn("strategy_hints", compact)
|
||||||
self.assertNotIn("focus_keyword_hits", compact["consumer_feedback_by_matrix_group"][0])
|
self.assertNotIn("focus_keyword_hits", compact["consumer_feedback_by_matrix_group"][0])
|
||||||
self.assertNotIn("scenarios_top", compact["consumer_feedback_by_matrix_group"][0])
|
self.assertNotIn("scenarios_top", compact["consumer_feedback_by_matrix_group"][0])
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user