diff --git a/app/search/summarizer.py b/app/search/summarizer.py index 5a10377..6ce15ec 100644 --- a/app/search/summarizer.py +++ b/app/search/summarizer.py @@ -93,9 +93,7 @@ def _expand_anchor_ids(group_text: str) -> list[str]: return ids -def check_anchors( - summary: str, anchor_map: dict[str, str] -) -> tuple[str, dict[str, int]]: +def check_anchors(summary: str, anchor_map: dict[str, str]) -> tuple[str, dict[str, int]]: """校验行号引注:非法行号删锚不删断言。 参数: @@ -235,9 +233,7 @@ async def _call_llm( {"role": "system", "content": system_prompt}, {"role": "user", "content": user_text}, ] - response = await llm.chat( - messages, session_id=session_id, parent_call_id=parent_call_id - ) + response = await llm.chat(messages, session_id=session_id, parent_call_id=parent_call_id) return response.content @@ -315,9 +311,7 @@ async def summarize_node( verify_result = "跳过(调用失败)" if anchor_map is not None: - raw_summary, asm_stats = assemble_anchored_output( - raw_summary, anchor_map, assemble_mode - ) + raw_summary, asm_stats = assemble_anchored_output(raw_summary, anchor_map, assemble_mode) anchor_stats.update(asm_stats) result = f"[内容摘要] {raw_summary}\n[核实] {verify_result}" @@ -358,9 +352,7 @@ async def summarize_children( lines = [] for child in children_info: t_start, t_end = child["time_range"] - lines.append( - f"- {child['id']} ({t_start:.0f}-{t_end:.0f}s): {child['summary']}" - ) + lines.append(f"- {child['id']} ({t_start:.0f}-{t_end:.0f}s): {child['summary']}") children_text = "\n".join(lines) extract_input = f"问题: {question}\n\n{children_text}" @@ -417,9 +409,7 @@ async def _summarize_search_result( 返回: "[内容摘要] {提取结果}\\n[核实] {验证结果}" 或错误信息。 """ - extract_input = ( - f"问题: {question}\n\n以下是语义搜索命中的视频节点描述和字幕:\n{raw_text}" - ) + extract_input = f"问题: {question}\n\n以下是语义搜索命中的视频节点描述和字幕:\n{raw_text}" try: raw_summary = await _call_llm( llm, @@ -487,9 +477,7 @@ async def summarize_nodes_batch( ) return idx, node_id, summary - tasks = [ - _worker(i, nid, text) for i, (nid, text, _) in enumerate(items) - ] + tasks = [_worker(i, nid, text) for i, (nid, text, _) in enumerate(items)] results_raw = await asyncio.gather(*tasks) results: dict[int, tuple[str, str]] = {}