MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / _direct_answer_stream

Function _direct_answer_stream

deployments/desktop/shared/agents.py:4589–4659  ·  view source on GitHub ↗
(question: str, response_language: str = "zh")

Source from the content-addressed store, hash-verified

4587 "source": "recent_daily_push",
4588 },
4589 "score": _to_float(score, 1.0),
4590 "updated_at": paper.get("pushed_at") or paper.get("updated_at") or "",
4591 }
4592 )
4593 if len(nodes) >= max(1, int(limit or 8)):
4594 break
4595 return nodes
4596
4597
4598def _chat_pinned_nodes(
4599 *,
4600 user_id: str,
4601 question: str,
4602 resolved_nodes: List[Dict[str, Any]],
4603 limit: int,
4604 scope: str = "all",
4605) -> List[Dict[str, Any]]:
4606 pinned = list(resolved_nodes or [])
4607 if _should_pin_recent_papers(question, scope) or pinned:
4608 seen = {str(node.get("node_id") or "") for node in pinned}
4609 remaining = max(0, int(limit or 8) - len(pinned))
4610 query = question if _local_paper_query_tokens(question) else ""
4611 for entry in _daily_note_reading_entries(scope="all", query=query, limit=remaining or int(limit or 8)):
4612 node = _daily_note_reading_node(entry)
4613 node_id = str(node.get("node_id") or "")
4614 if node_id and node_id not in seen:
4615 pinned.append(node)
4616 seen.add(node_id)
4617 return pinned
4618
4619
4620def _chat_allowed_node_ids(user_id: str, pinned_nodes: List[Dict[str, Any]]) -> Set[str]:
4621 del user_id
4622 return {str(node.get("node_id") or "") for node in pinned_nodes if str(node.get("node_id") or "").strip()}
4623
4624
4625def _citation_source_payload(citation: Dict[str, Any]) -> Dict[str, Any]:
4626 metadata = citation.get("metadata") or {}
4627 node_type = str(citation.get("node_type") or "").strip()
4628 source_type = str(citation.get("source_type") or "").strip()
4629 source_id = str(citation.get("source_id") or "").strip()
4630 source_label = {
4631 "reading_report": "精读报告",
4632 "daily_push": "论文推荐",
4633 "manual": "手动导入",
4634 }.get(source_type, "")
4635 meta_parts = [part for part in [source_label, source_id] if part]
4636 return {
4637 "index": citation.get("index"),
4638 "node_id": citation.get("node_id"),
4639 "node_type": node_type,
4640 "title": citation.get("title") or citation.get("node_id") or "未命名来源",
4641 "meta": " · ".join(meta_parts) if meta_parts else "参考文献",
4642 "snippet": citation.get("excerpt") or "",
4643 "excerpt": citation.get("excerpt") or "",
4644 "source_type": source_type,
4645 "source_id": source_id,
4646 "anchor": citation.get("anchor"),

Callers 1

wiki_ask_streamFunction · 0.85

Calls 6

build_llm_providerFunction · 0.90
_text_chunksFunction · 0.85
_direct_answer_promptFunction · 0.85
stream_generateMethod · 0.45

Tested by

no test coverage detected