Commit eaac3c18 by wangzhiyang Committed by 胡悦

fix(meeting_minutes): 修复会议纪要格式规则,添加ffmpeg依赖并优化音视频检测逻辑

- 新增imageio-ffmpeg依赖,支持跨平台音视频时长检测,同时兼容系统安装的ffmpeg
- 更新会议Agent提示模板,严格禁止所有markdown格式输出,链接直接使用纯文本
- 移除旧的链接包装函数,调整导出接口返回纯URL而非带<link>包装的格式
- 重构音视频时长检测逻辑,更新相关文档与使用说明
1 parent 5655dd10
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
"name": "会议Agent", "name": "会议Agent",
"code": "17", "code": "17",
"role": "会议纪要助手", "role": "会议纪要助手",
"prompt_template": "你是广联数科的会议纪要助手,职责包括:{duties}。请根据用户的需求,帮助处理会议纪要相关的任务。格式规则(必须遵守)回复用户时链接不要使用markdown包裹,维持工具输出的格式。", "prompt_template": "你是广联数科的会议纪要助手,职责包括:{duties}。请根据用户的需求,帮助处理会议纪要相关的任务。\n\n## 格式规则(必须遵守)\n\n回复用户时**严禁使用任何 markdown 格式**,包括但不限于:# 标题、** 加粗、- 列表、``` 代码块、[文字](链接) 超链接。链接直接输出纯 URL 文本即可,不要用 markdown 链接语法包裹。",
"skills": ["meeting_minutes"] "skills": ["meeting_minutes"]
} }
} }
......
...@@ -24,12 +24,12 @@ pytest-mock==3.15.1 ...@@ -24,12 +24,12 @@ pytest-mock==3.15.1
# AI/ML APIs # AI/ML APIs
openai>=1.0.0 openai>=1.0.0
dashscope>=1.20.0 dashscope>=1.20.0
agentscope==1.0.19.post1 agentscope>=1.0.0
numpy==1.26.4 numpy==1.26.4
# Document processing # Document processing
python-docx>=1.1.0 python-docx>=1.1.0
imageio-ffmpeg==0.6.0 imageio-ffmpeg>=0.4.9
# OSS storage # OSS storage
oss2>=2.19.0 oss2>=2.19.0
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
name: meeting_minutes name: meeting_minutes
description: 会议录音转写、纪要生成与文件导出。上传音视频文件 → Fun-ASR 转写 → Qwen3.6-plus 生成结构化 Markdown 会议纪要 → 导出 docx → 上传 OSS 返回查看链接 description: 会议录音转写、纪要生成与文件导出。上传音视频文件 → Fun-ASR 转写 → Qwen3.6-plus 生成结构化 Markdown 会议纪要 → 导出 docx → 上传 OSS 返回查看链接
--- ---
# 会议纪要助手 # 会议纪要助手
你是会议纪要助手,职责是将用户提供的会议录音转化为结构化会议纪要并导出为 docx 文件。 你是会议纪要助手,职责是将用户提供的会议录音转化为结构化会议纪要并导出为 docx 文件。
...@@ -12,6 +11,7 @@ description: 会议录音转写、纪要生成与文件导出。上传音视频 ...@@ -12,6 +11,7 @@ description: 会议录音转写、纪要生成与文件导出。上传音视频
## 输入识别 ## 输入识别
从用户消息中提取以下信息: 从用户消息中提取以下信息:
- **音频文件 URL**:必填,公网可访问的音视频文件地址 - **音频文件 URL**:必填,公网可访问的音视频文件地址
- **模板偏好**:可选,A=需求评审 / B=管理例会 / C=通用会议 / D=复盘 / E=商务沟通。未指定则模型自动匹配 - **模板偏好**:可选,A=需求评审 / B=管理例会 / C=通用会议 / D=复盘 / E=商务沟通。未指定则模型自动匹配
...@@ -30,16 +30,19 @@ python skills/meeting_minutes/scripts/generate_minutes.py "<audio_url>" \ ...@@ -30,16 +30,19 @@ python skills/meeting_minutes/scripts/generate_minutes.py "<audio_url>" \
``` ```
参数说明: 参数说明:
- `audio_url`:必填,用户提供的音频文件 URL - `audio_url`:必填,用户提供的音频文件 URL
- `--template`:用户指定模板时传入,未指定则省略 - `--template`:用户指定模板时传入,未指定则省略
- `--language-hints`:默认 `'["zh","en"]'` - `--language-hints`:默认 `'["zh","en"]'`
脚本执行过程: 脚本执行过程:
1. 调用 Fun-ASR 异步转写音频 1. 调用 Fun-ASR 异步转写音频
2. 将转写文本传入 Qwen3.6-plus 生成结构化 Markdown 会议纪要 2. 将转写文本传入 Qwen3.6-plus 生成结构化 Markdown 会议纪要
3. 对生成的纪要进行结构化校验 3. 对生成的纪要进行结构化校验
注意事项: 注意事项:
- 转写为异步任务,需等待 Fun-ASR 完成,可能需要几分钟 - 转写为异步任务,需等待 Fun-ASR 完成,可能需要几分钟
- 脚本通过 stdout 输出 Markdown 纪要,stderr 输出进度信息 - 脚本通过 stdout 输出 Markdown 纪要,stderr 输出进度信息
- 如果执行失败,将错误信息汇报给管家 Agent 并终止 - 如果执行失败,将错误信息汇报给管家 Agent 并终止
...@@ -59,6 +62,7 @@ echo "<Step1的Markdown内容>" | python skills/meeting_minutes/scripts/export_m ...@@ -59,6 +62,7 @@ echo "<Step1的Markdown内容>" | python skills/meeting_minutes/scripts/export_m
``` ```
注意事项: 注意事项:
- 确保 Markdown 内容中的特殊字符(双引号、反斜杠、$ 等)已正确转义 - 确保 Markdown 内容中的特殊字符(双引号、反斜杠、$ 等)已正确转义
- 脚本通过 stdout 输出 OSS 的 URL,stderr 输出进度信息 - 脚本通过 stdout 输出 OSS 的 URL,stderr 输出进度信息
- 如果 Markdown 内容很长,建议先写入临时文件,再通过 `cat tmp.md | python ...` 执行 - 如果 Markdown 内容很长,建议先写入临时文件,再通过 `cat tmp.md | python ...` 执行
...@@ -69,9 +73,7 @@ echo "<Step1的Markdown内容>" | python skills/meeting_minutes/scripts/export_m ...@@ -69,9 +73,7 @@ echo "<Step1的Markdown内容>" | python skills/meeting_minutes/scripts/export_m
将以下信息整理后交给管家 Agent: 将以下信息整理后交给管家 Agent:
**docx 查看链接**:必须单独占一行输出,使用 `<link>...</link>` 包裹 URL,且链接前后不要加任何标点、反引号或代码块 **docx 查看链接**:必须单独占一行输出 URL,且链接前后不要加任何标点、反引号或代码块
询问用户是否需要修改或重新生成。
## 注意事项 ## 注意事项
......
...@@ -30,19 +30,6 @@ logger = logging.getLogger(__name__) ...@@ -30,19 +30,6 @@ logger = logging.getLogger(__name__)
OSS_DIR_PREFIX = "meeting-minutes" OSS_DIR_PREFIX = "meeting-minutes"
def _wrap_link(url: str) -> str:
cleaned = url.replace("\r", "").replace("\n", "").strip()
if cleaned.startswith("<link>") and cleaned.endswith("</link>"):
inner = cleaned[len("<link>"):-len("</link>")].strip()
else:
inner = cleaned
if inner.startswith("`") and inner.endswith("`") and len(inner) >= 2:
inner = inner[1:-1].strip()
return f"<link>{inner}</link>"
# ────────────────────── OSS 上传 ────────────────────── # ────────────────────── OSS 上传 ──────────────────────
...@@ -353,8 +340,7 @@ def export_and_upload(markdown_content: str) -> dict: ...@@ -353,8 +340,7 @@ def export_and_upload(markdown_content: str) -> dict:
size_kb = len(docx_result["data"]) / 1024 size_kb = len(docx_result["data"]) / 1024
return { return {
"success": True, "success": True,
"raw_url": upload_result["url"], "url": upload_result["url"],
"url": _wrap_link(upload_result["url"]),
"filename": docx_result["filename"], "filename": docx_result["filename"],
"size_kb": round(size_kb, 1), "size_kb": round(size_kb, 1),
} }
......
...@@ -69,19 +69,24 @@ def _get_remote_size_bytes(url: str) -> Optional[int]: ...@@ -69,19 +69,24 @@ def _get_remote_size_bytes(url: str) -> Optional[int]:
return None return None
def _probe_duration_seconds_ffprobe(url: str) -> Optional[float]: def _get_ffmpeg_exe() -> Optional[str]:
ffprobe = os.getenv("FFPROBE_PATH") or shutil.which("ffprobe") try:
if not ffprobe: import imageio_ffmpeg
return imageio_ffmpeg.get_ffmpeg_exe()
except Exception:
return shutil.which("ffmpeg")
def _probe_duration_seconds(url: str) -> Optional[float]:
ffmpeg = _get_ffmpeg_exe()
if not ffmpeg:
return None return None
cmd = [ cmd = [
ffprobe, ffmpeg,
"-v", "-hide_banner",
"error", "-nostdin",
"-show_entries", "-i",
"format=duration",
"-of",
"default=noprint_wrappers=1:nokey=1",
url, url,
] ]
try: try:
...@@ -95,16 +100,18 @@ def _probe_duration_seconds_ffprobe(url: str) -> Optional[float]: ...@@ -95,16 +100,18 @@ def _probe_duration_seconds_ffprobe(url: str) -> Optional[float]:
except Exception: except Exception:
return None return None
out = (res.stdout or "").strip() output = f"{res.stdout or ''}\n{res.stderr or ''}"
if not out: m = re.search(r"Duration:\s*(\d+):(\d+):(\d+(?:\.\d+)?)", output)
if not m:
return None return None
try:
sec = float(out) hours = int(m.group(1))
except ValueError: minutes = int(m.group(2))
return None seconds = float(m.group(3))
if sec <= 0: duration_seconds = hours * 3600 + minutes * 60 + seconds
if duration_seconds <= 0:
return None return None
return sec return duration_seconds
def _probe_media_limits(url: str) -> dict: def _probe_media_limits(url: str) -> dict:
...@@ -115,11 +122,11 @@ def _probe_media_limits(url: str) -> dict: ...@@ -115,11 +122,11 @@ def _probe_media_limits(url: str) -> dict:
"error": f"音视频文件过大:{round(size_bytes / 1024 / 1024 / 1024, 2)} GB,超过 2 GB", "error": f"音视频文件过大:{round(size_bytes / 1024 / 1024 / 1024, 2)} GB,超过 2 GB",
} }
duration_seconds = _probe_duration_seconds_ffprobe(url) duration_seconds = _probe_duration_seconds(url)
if duration_seconds is None: if duration_seconds is None:
return { return {
"success": False, "success": False,
"error": "无法获取音视频时长(需要安装 ffprobe,或提供支持 Range/直链可探测的 URL)", "error": "无法获取音视频时长(请 pip install imageio-ffmpeg,或在系统安装 ffmpeg,并确保 URL 可被探测)",
} }
if duration_seconds > _MAX_MEDIA_DURATION_SECONDS: if duration_seconds > _MAX_MEDIA_DURATION_SECONDS:
...@@ -148,7 +155,7 @@ def transcribe_audio( ...@@ -148,7 +155,7 @@ def transcribe_audio(
) -> dict: ) -> dict:
"""使用 Fun-ASR 异步转写音视频文件。""" """使用 Fun-ASR 异步转写音视频文件。"""
try: try:
import dashscope # noqa: F401 import dashscope
except ImportError: except ImportError:
return {"success": False, "error": "dashscope SDK 未安装,请执行: pip install dashscope"} return {"success": False, "error": "dashscope SDK 未安装,请执行: pip install dashscope"}
...@@ -329,9 +336,8 @@ MEETING_MINUTES_PROMPT = """你将根据"会议基本信息 + 转写文本"生 ...@@ -329,9 +336,8 @@ MEETING_MINUTES_PROMPT = """你将根据"会议基本信息 + 转写文本"生
2. `**【会议主题】**`:可采用"项目名称/部门+议题"形式,例如《优加平台战略与运营落地 会议纪要》。 2. `**【会议主题】**`:可采用"项目名称/部门+议题"形式,例如《优加平台战略与运营落地 会议纪要》。
3. `**【会议日期】**`:YYYY-MM-DD HH:MM-HH:MM(缺失则 [未提及]) 3. `**【会议日期】**`:YYYY-MM-DD HH:MM-HH:MM(缺失则 [未提及])
4. `**【参会人】**`:说话人 1、说话人 2…… 4. `**【参会人】**`:说话人 1、说话人 2……
5. `**【缺席人】**`:无 / [未提及] 5. `**【本次会议要点】**`:3~6 条(方向/决策/指标/资源/关键动作)
6. `**【本次会议要点】**`:3~6 条(方向/决策/指标/资源/关键动作) 6. `**【详细任务列表】**`:任务表格(类别示例:平台政策/数据分析/制度管理/业务拓展/财务与行政/团队建设),任务事项包含「做什么 + 成果/标准 + 关键约束」,以动词开头
7. `**【详细任务列表】**`:任务表格(类别示例:平台政策/数据分析/制度管理/业务拓展/财务与行政/团队建设),任务事项包含「做什么 + 成果/标准 + 关键约束」,以动词开头
例如: 例如:
**会议纪要** **会议纪要**
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!