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

Function _recent_paper_context_nodes

deployments/desktop/shared/agents.py:4288–4369  ·  view source on GitHub ↗
(user_id: str, question: str = "", limit: int = 8)

Source from the content-addressed store, hash-verified

4286 "介绍下",
4287 "如何理解",
4288 "define ",
4289 "what is ",
4290 "explain ",
4291)
4292
4293DIRECT_ANSWER_PROMPT_ZH = """You are PaperFlow's desktop research assistant.
4294
4295The user asked a general question that does not require local Wiki retrieval.
4296Answer directly and concisely in Chinese by default. Do not add fake citations
4297or [N] markers. If the question asks for local papers, reports, user profile,
4298or Wiki evidence, say that local Wiki retrieval is required instead."""
4299
4300DIRECT_ANSWER_PROMPT_EN = """You are PaperFlow's desktop research assistant.
4301
4302The user asked a general question that does not require local Wiki retrieval.
4303Answer directly and concisely in English. Do not add fake citations or [N]
4304markers. If the question asks for local papers, reports, user profile, or Wiki
4305evidence, say that local Wiki retrieval is required instead."""
4306
4307DIRECT_ANSWER_PROMPT = DIRECT_ANSWER_PROMPT_ZH
4308
4309
4310def _direct_answer_prompt(response_language: str) -> str:
4311 return DIRECT_ANSWER_PROMPT_EN if _normalize_response_language(response_language) == "en" else DIRECT_ANSWER_PROMPT_ZH
4312
4313
4314def _direct_answer_max_tokens() -> int:
4315 return _env_int("PAPERFLOW_DIRECT_ANSWER_MAX_TOKENS", 1400, min_value=512, max_value=4096)
4316
4317
4318def _extract_question_mentions(question: str) -> List[Dict[str, str]]:
4319 text = str(question or "")
4320 mentions: List[Dict[str, str]] = []
4321 for match in _MENTION_LINK_RE.finditer(text):
4322 mentions.append({"title": match.group(1).strip(), "node_id": match.group(2).strip()})
4323 stripped = _MENTION_LINK_RE.sub(" ", text)
4324 for match in _MENTION_TOKEN_RE.finditer(stripped):
4325 token = match.group(1).strip()
4326 if token:
4327 mentions.append({"title": token, "node_id": ""})
4328 return mentions
4329
4330
4331def _normalize_requested_mentions(mentions: Any) -> List[Dict[str, str]]:
4332 normalized: List[Dict[str, str]] = []
4333 if not isinstance(mentions, list):
4334 return normalized
4335 for item in mentions:
4336 if isinstance(item, dict):
4337 title = str(item.get("title") or item.get("label") or "").strip()
4338 node_id = str(item.get("node_id") or item.get("id") or "").strip()
4339 if title or node_id:
4340 normalized.append({"title": title, "node_id": node_id})
4341 else:
4342 token = str(item or "").strip()
4343 if token:
4344 normalized.append({"title": token, "node_id": ""})
4345 return normalized

Callers

nothing calls this directly

Calls 8

_paper_query_haystackFunction · 0.85
_paper_arxiv_idFunction · 0.85
_compact_listFunction · 0.85
_to_floatFunction · 0.85
getMethod · 0.80
encodeMethod · 0.80
_load_jsonFunction · 0.70

Tested by

no test coverage detected