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字以内)",
|
"summary": "整体摘要(100字以内)",
|
||||||
"topics": ["主题1", "主题2", "主题3"],
|
"topics": ["主题1", "主题2", "主题3"],
|
||||||
"insights": ["见解1", "见解2"],
|
"insights": ["见解1", "见解2"],
|
||||||
"actions": ["建议1"]
|
"actions": ["建议1"],
|
||||||
|
"tags": ["标签1", "标签2", "标签3", "标签4", "标签5"]
|
||||||
}}"""
|
}}"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -417,7 +418,8 @@ class DeepAnalyzer:
|
|||||||
"summary": title,
|
"summary": title,
|
||||||
"topics": ["主题1", "主题2", "主题3"],
|
"topics": ["主题1", "主题2", "主题3"],
|
||||||
"insights": ["无法获取深入见解"],
|
"insights": ["无法获取深入见解"],
|
||||||
"actions": []
|
"actions": [],
|
||||||
|
"tags": []
|
||||||
}
|
}
|
||||||
|
|
||||||
def _get_text_sample(self, text: str, max_chars: int) -> str:
|
def _get_text_sample(self, text: str, max_chars: int) -> str:
|
||||||
@@ -500,6 +502,17 @@ class TemplateLoader:
|
|||||||
TEMPLATES = {
|
TEMPLATES = {
|
||||||
"video": """# {{title}}
|
"video": """# {{title}}
|
||||||
|
|
||||||
|
---
|
||||||
|
title: "{{title}}"
|
||||||
|
date: {{date}}
|
||||||
|
duration: {{duration}}
|
||||||
|
author: {{author}}
|
||||||
|
source: {{source}}
|
||||||
|
tags: [{{tags_string}}]
|
||||||
|
bvid: {{bvid}}
|
||||||
|
platform: {{platform}}
|
||||||
|
---
|
||||||
|
|
||||||
## 基本信息
|
## 基本信息
|
||||||
- **时长**: {{duration}}
|
- **时长**: {{duration}}
|
||||||
- **作者**: {{author}}
|
- **作者**: {{author}}
|
||||||
@@ -538,9 +551,26 @@ class TemplateLoader:
|
|||||||
- {{tag}}
|
- {{tag}}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
*元数据*
|
||||||
|
- **平台**: {{platform}}
|
||||||
|
- **BV号**: {{bvid}}
|
||||||
|
- **原始文件**: {{source_file}}
|
||||||
""",
|
""",
|
||||||
"article": """# {{title}}
|
"article": """# {{title}}
|
||||||
|
|
||||||
|
---
|
||||||
|
title: "{{title}}"
|
||||||
|
date: {{date}}
|
||||||
|
author: {{author}}
|
||||||
|
source: {{source}}
|
||||||
|
tags: [{{tags_string}}]
|
||||||
|
cvid: {{cvid}}
|
||||||
|
platform: {{platform}}
|
||||||
|
---
|
||||||
|
|
||||||
## 基本信息
|
## 基本信息
|
||||||
- **作者**: {{author}}
|
- **作者**: {{author}}
|
||||||
- **来源**: {{source}}
|
- **来源**: {{source}}
|
||||||
@@ -570,6 +600,13 @@ class TemplateLoader:
|
|||||||
- {{tag}}
|
- {{tag}}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
*元数据*
|
||||||
|
- **平台**: {{platform}}
|
||||||
|
- **CV号**: {{cvid}}
|
||||||
|
- **原始文件**: {{source_file}}
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -738,6 +775,7 @@ def main():
|
|||||||
|
|
||||||
variables = {
|
variables = {
|
||||||
"title": metadata.get('title', '未命名'),
|
"title": metadata.get('title', '未命名'),
|
||||||
|
"date": datetime.now().strftime('%Y-%m-%d'),
|
||||||
"duration": format_duration(metadata.get('duration', 0)),
|
"duration": format_duration(metadata.get('duration', 0)),
|
||||||
"author": metadata.get('author', '未知'),
|
"author": metadata.get('author', '未知'),
|
||||||
"source": metadata.get('source', ''),
|
"source": metadata.get('source', ''),
|
||||||
@@ -747,7 +785,15 @@ def main():
|
|||||||
"insights": result.key_insights,
|
"insights": result.key_insights,
|
||||||
"actions": result.action_items,
|
"actions": result.action_items,
|
||||||
"tags": result.recommended_tags,
|
"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)
|
markdown_content = renderer.render(template, variables)
|
||||||
|
|||||||
Reference in New Issue
Block a user