mirror of
https://github.com/lllin000/PaperForge.git
synced 2026-07-22 06:50:53 +00:00
fix: address 4 review items — remove dead INTENTS dict, drop unused --limit from paper-navigation, add -> int return types, guard subsection section_path
This commit is contained in:
parent
1e6edad7ba
commit
4dbeb5ae50
5 changed files with 4 additions and 11 deletions
|
|
@ -464,7 +464,6 @@ def build_parser() -> argparse.ArgumentParser:
|
|||
p_paper_navigation = sub.add_parser("paper-navigation", help="Navigate paper structure through the Layer 4 gateway")
|
||||
p_paper_navigation.add_argument("query", help="Paper identifier or DOI for structural navigation")
|
||||
p_paper_navigation.add_argument("--json", action="store_true", help="Output JSON")
|
||||
p_paper_navigation.add_argument("--limit", type=int, default=5, help="Max results (default 5)")
|
||||
|
||||
p_scoped_fetch = sub.add_parser("scoped-fetch", help="Fetch paper content scoped by query through the Layer 4 gateway")
|
||||
p_scoped_fetch.add_argument("query", help="Paper identifier, title, or scoped query for targeted fetch")
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ from __future__ import annotations
|
|||
from paperforge.retrieval import gateway
|
||||
|
||||
|
||||
def run(args):
|
||||
def run(args) -> int:
|
||||
"""Execute ``content-discovery`` via the Layer 4 gateway."""
|
||||
result = gateway.route_gateway(
|
||||
args.vault_path,
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ from __future__ import annotations
|
|||
from paperforge.retrieval import gateway
|
||||
|
||||
|
||||
def run(args):
|
||||
def run(args) -> int:
|
||||
"""Execute ``paper-lookup`` via the Layer 4 gateway."""
|
||||
result = gateway.route_gateway(
|
||||
args.vault_path,
|
||||
|
|
|
|||
|
|
@ -18,13 +18,6 @@ from paperforge.memory.db import get_connection, get_memory_db_path
|
|||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Map gateway intent names to build_query_plan intent strings
|
||||
INTENTS: dict[str, str] = {
|
||||
"paper-lookup": "known-paper",
|
||||
"content-discovery": "content",
|
||||
"paper-navigation": "known-paper",
|
||||
"scoped-fetch": "known-paper",
|
||||
}
|
||||
|
||||
|
||||
def route_gateway(
|
||||
|
|
|
|||
|
|
@ -13,12 +13,13 @@ def build_structure_tree(structured_blocks: list[dict[str, Any]]) -> dict[str, A
|
|||
role = block.get("role")
|
||||
text = str(block.get("text", "")).strip()
|
||||
if role in {"section_heading", "subsection_heading", "introduction_heading", "abstract_heading"} and text:
|
||||
parent_title = nodes[-1]["title"] if nodes else ""
|
||||
current_section = {
|
||||
"node_id": f"sec:{block.get('block_id')}",
|
||||
"kind": "section",
|
||||
"title": text,
|
||||
"level": 1 if role != "subsection_heading" else 2,
|
||||
"section_path": [text] if role != "subsection_heading" else [nodes[-1]["title"], text] if nodes else [text],
|
||||
"section_path": [text] if role != "subsection_heading" else [parent_title, text],
|
||||
"page_span": [block.get("page", 0), block.get("page", 0)],
|
||||
"block_span": [[block.get("page", 0), block.get("block_id", "")]],
|
||||
"children": [],
|
||||
|
|
|
|||
Loading…
Reference in a new issue