feat(kb-deep-analyzer): Enhance template and metadata
- Add complete metadata to frontmatter (bvid, cvid, mid, platform) - Add AI-generated tags in analysis prompt - Update templates to include full metadata - Add tags_string for YAML array format
This commit is contained in:
@@ -406,7 +406,8 @@ class DeepAnalyzer:
|
||||
"summary": "整体摘要(100字以内)",
|
||||
"topics": ["主题1", "主题2", "主题3"],
|
||||
"insights": ["见解1", "见解2"],
|
||||
"actions": ["建议1"]
|
||||
"actions": ["建议1"],
|
||||
"tags": ["标签1", "标签2", "标签3", "标签4", "标签5"]
|
||||
}}"""
|
||||
|
||||
try:
|
||||
@@ -417,7 +418,8 @@ class DeepAnalyzer:
|
||||
"summary": title,
|
||||
"topics": ["主题1", "主题2", "主题3"],
|
||||
"insights": ["无法获取深入见解"],
|
||||
"actions": []
|
||||
"actions": [],
|
||||
"tags": []
|
||||
}
|
||||
|
||||
def _get_text_sample(self, text: str, max_chars: int) -> str:
|
||||
@@ -500,6 +502,17 @@ class TemplateLoader:
|
||||
TEMPLATES = {
|
||||
"video": """# {{title}}
|
||||
|
||||
---
|
||||
title: "{{title}}"
|
||||
date: {{date}}
|
||||
duration: {{duration}}
|
||||
author: {{author}}
|
||||
source: {{source}}
|
||||
tags: [{{tags_string}}]
|
||||
bvid: {{bvid}}
|
||||
platform: {{platform}}
|
||||
---
|
||||
|
||||
## 基本信息
|
||||
- **时长**: {{duration}}
|
||||
- **作者**: {{author}}
|
||||
@@ -538,9 +551,26 @@ class TemplateLoader:
|
||||
- {{tag}}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
---
|
||||
|
||||
*元数据*
|
||||
- **平台**: {{platform}}
|
||||
- **BV号**: {{bvid}}
|
||||
- **原始文件**: {{source_file}}
|
||||
""",
|
||||
"article": """# {{title}}
|
||||
|
||||
---
|
||||
title: "{{title}}"
|
||||
date: {{date}}
|
||||
author: {{author}}
|
||||
source: {{source}}
|
||||
tags: [{{tags_string}}]
|
||||
cvid: {{cvid}}
|
||||
platform: {{platform}}
|
||||
---
|
||||
|
||||
## 基本信息
|
||||
- **作者**: {{author}}
|
||||
- **来源**: {{source}}
|
||||
@@ -570,6 +600,13 @@ class TemplateLoader:
|
||||
- {{tag}}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
---
|
||||
|
||||
*元数据*
|
||||
- **平台**: {{platform}}
|
||||
- **CV号**: {{cvid}}
|
||||
- **原始文件**: {{source_file}}
|
||||
"""
|
||||
}
|
||||
|
||||
@@ -738,6 +775,7 @@ def main():
|
||||
|
||||
variables = {
|
||||
"title": metadata.get('title', '未命名'),
|
||||
"date": datetime.now().strftime('%Y-%m-%d'),
|
||||
"duration": format_duration(metadata.get('duration', 0)),
|
||||
"author": metadata.get('author', '未知'),
|
||||
"source": metadata.get('source', ''),
|
||||
@@ -747,7 +785,15 @@ def main():
|
||||
"insights": result.key_insights,
|
||||
"actions": result.action_items,
|
||||
"tags": result.recommended_tags,
|
||||
"timeline": result.timeline
|
||||
"tags_string": ', '.join(f'"{t}"' for t in (result.recommended_tags or [])),
|
||||
"timeline": result.timeline,
|
||||
# 扩展元数据
|
||||
"bvid": metadata.get('bvid', ''),
|
||||
"cvid": metadata.get('cvid', ''),
|
||||
"mid": metadata.get('mid', ''),
|
||||
"platform": metadata.get('platform', 'bilibili'),
|
||||
"source_file": metadata.get('source_file', ''),
|
||||
"aid": str(metadata.get('aid', '')),
|
||||
}
|
||||
|
||||
markdown_content = renderer.render(template, variables)
|
||||
|
||||
Reference in New Issue
Block a user