MCPcopy Create free account
hub / github.com/Louisym/MiniCC / format_compact_summary

Function format_compact_summary

tutorials/16_prompt_building_and_compaction.py:659–673  ·  view source on GitHub ↗

格式化压缩摘要 — 源码 compact.rs:38-50 处理 XML 标签: 1. 删除 ... 块(这是给内部用的分析) 2. 把 ... 替换成 "Summary:\n" 前缀

(summary: str)

Source from the content-addressed store, hash-verified

657
658
659def format_compact_summary(summary: str) -> str:
660 """格式化压缩摘要 — 源码 compact.rs:38-50
661
662 处理 XML 标签:
663 1. 删除 <analysis>...</analysis> 块(这是给内部用的分析)
664 2. 把 <summary>...</summary> 替换成 "Summary:\n" 前缀
665 """
666 # 删除 <analysis> 块
667 result = re.sub(r'<analysis>.*?</analysis>', '', summary, flags=re.DOTALL)
668 # 替换 <summary> 标签
669 match = re.search(r'<summary>(.*?)</summary>', result, flags=re.DOTALL)
670 if match:
671 content = match.group(1).strip()
672 result = result.replace(match.group(0), f"Summary:\n{content}")
673 return _collapse_blank_lines(result).strip()
674
675
676def get_compact_continuation_message(

Callers 2

compact_sessionFunction · 0.70

Calls 1

_collapse_blank_linesFunction · 0.70

Tested by

no test coverage detected