command/bin/bash -lc "nl -ba backend/api/v1/endpoints.py | sed -n '489,535p;865,924p;1288,1302p;1378,1392p'"
exit code 0
Output: 489 def build_chat_sources(retrieval_results: List[Dict[str, Any]]) -> List[Dict[str, Any]]: 490 """Build normalized source payloads for chat responses.""" 491 sources: List[Dict[str, Any]] = [] 492 493 for result in retrieval_results: 494 snippet = result.get("content", "")[:200].strip() 495 if snippet and len(result.get("content", "")) > 200: 496 snippet += "..." 497 498 if result["type"] == "url": 499 sources.append( 500 { 501 "type": "url", 502 "title": result.get("metadata", {}).get("title", "文档"), 503 "url": result.get("metadata", {}).get("url", ""), 504 "snippet": snippet or None, 505 } 506 ) 507 508 return sources 509 510 511 _SOURCE_PLACEHOLDER_PATTERN = re.compile(r"\[([^\]]+)\]\(#source-(\d+)\)") 512 513 514 def replace_source_placeholders(reply: str, sources: List[Dict[str, Any]]) -> str: 515 """Replace trusted source placeholders with real URLs and strip invalid ones.""" 516