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

Function _persist_chat_turn

deployments/desktop/shared/agents.py:4544–4571  ·  view source on GitHub ↗
(
    user_id: str,
    session_id: str,
    question: str,
    result: Dict[str, Any],
)

Source from the content-addressed store, hash-verified

4542 if node_id in seen:
4543 continue
4544 seen.add(node_id)
4545 authors = _compact_list(paper.get("authors"), limit=6)
4546 subjects = _compact_list(paper.get("subjects") or paper.get("categories"), limit=8)
4547 abstract = str(paper.get("abstract") or paper.get("summary") or "").strip()
4548 raw_metadata = paper.get("metadata") or {}
4549 metadata = raw_metadata if isinstance(raw_metadata, dict) else _load_json(raw_metadata, {})
4550 if not isinstance(metadata, dict):
4551 metadata = {}
4552 push_id = paper.get("push_id") or metadata.get("push_id")
4553 rank = paper.get("rank") or metadata.get("rank")
4554 score = paper.get("score") or paper.get("relevance") or metadata.get("score")
4555 category = paper.get("category") or metadata.get("category")
4556 body_parts = [
4557 f"Recent PaperFlow pushed paper #{index}.",
4558 f"Title: {title}",
4559 f"Authors: {', '.join(authors)}" if authors else "",
4560 f"Subjects: {', '.join(subjects)}" if subjects else "",
4561 f"Category: {category}" if category else "",
4562 f"Rank: {rank}" if rank else "",
4563 f"Score: {score}" if score else "",
4564 f"Push batch: {push_id}" if push_id else "",
4565 f"Abstract: {abstract}" if abstract else "Abstract: no abstract stored; use title/category as weak evidence.",
4566 ]
4567 nodes.append(
4568 {
4569 "node_id": node_id,
4570 "node_type": "paper",
4571 "title": title,
4572 "body": "\n".join(part for part in body_parts if part),
4573 "keywords": " ".join([title, category or "", " ".join(subjects), "recent trend daily push"]).strip(),
4574 "file_path": "",

Callers 1

_attach_chat_sessionFunction · 0.85

Calls 2

_chat_turn_metadataFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected