Commit 8650aca7 by wangzhiyang

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

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