API reference (auto-generated)¶
Generated from docstrings in src/akms_nodes_gen/ via
mkdocstrings.
batch_picker.config¶
batch_picker.plan_parser¶
Parse generation_plan.md into a list of batch records.
The plan file has a regular structure:
# Round N: Title
**Theme:** ...
**Subdomain:** ...
**Dependencies:** ...
## Rn_Bm — Batch Title (K nodes)
**PDF folder:** AKMS_Sources/new/Rn_Bm_<slug>/
**Sources:** <free text>
**ZotSums:** <free text> (optional)
**Missing sources (...):** <free text> (optional)
**Cross-references:** <free text> (optional)
| # | Node ID | Title | Key Concepts | Size |
|---|---------|-------|--------------|------|
| 14 | `kinematics-...` | Title | concepts | medium |
...
We are tolerant about minor format drift.
batch_picker.loaders¶
Load Zotero BetterBibTeX export and ZotSums Obsidian frontmatter into a single in-memory paper catalog keyed by Better-BibTeX citation key.
batch_picker.state¶
Read/write the durable batch_assignments.json state file.
Schema (v1):
{
"version": 1,
"batches": {
"R3_B2": {
"papers": ["citekey1", "citekey2", ...],
"nlm_notebook_id": "nb_abc...",
"nlm_notebook_url": "...",
"synced_at": "2026-05-07T15:30:00Z",
"uploaded_papers": ["citekey1", ...],
"notes": ""
}
}
}
batch_picker.queries¶
Saved-query persistence.
A saved query is a named filter spec that can be re-applied later or used
for bulk-add to a batch. Storage: saved_queries.json next to
batch_assignments.json.
Schema (v1)::
{
"version": 1,
"updated_at": "...",
"queries": {
"<name>": {
"filter": { ... FilterSpec ... },
"created_at": "...",
"updated_at": "..."
}
}
}
batch_picker.exporters¶
Side-effecting actions: write per-batch plan JSON, stage PDFs into the
batch source folder, drive the nlm CLI to create a notebook + upload sources.
write_plan_json
¶
write_plan_json(
batch: Batch,
assignment: BatchAssignment,
catalog: Catalog,
inputs_dir: Path,
) -> Path
Write a node-gen-invoker plan JSON for a single batch.
Source code in packages/akms_nodes_gen/src/akms_nodes_gen/batch_picker/exporters.py
stage_pdfs
¶
stage_pdfs(
batch: Batch,
assignment: BatchAssignment,
catalog: Catalog,
sources_dir: Path,
use_symlink: bool = True,
) -> ActionResult
Drop PDFs into AKMS_Sources/new/
Source code in packages/akms_nodes_gen/src/akms_nodes_gen/batch_picker/exporters.py
create_notebook_and_upload
¶
create_notebook_and_upload(
batch: Batch,
assignment: BatchAssignment,
catalog: Catalog,
sources_dir: Path,
upload: bool = True,
wait: bool = False,
) -> ActionResult
Run nlm notebook create and (optionally) upload all PDFs.
The notebook ID is captured into the assignment for durability. If the notebook already exists on the assignment, we reuse it and only upload the missing PDFs.
Source code in packages/akms_nodes_gen/src/akms_nodes_gen/batch_picker/exporters.py
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 | |
batch_picker.server¶
FastAPI server for the AKMS batch-picker UI.
FilterSpec
¶
Bases: BaseModel
Re-usable paper-search filter. Same shape that /api/papers accepts as query parameters and that saved queries persist.
nlm_batch¶
Serial NotebookLM batch generator for AKMS node YAML.
This module is intentionally separate from generate_nodes_pipeline.py:
Python orchestrates the batch, NotebookLM performs source-grounded synthesis,
and local gates handle parsing, schema checks, edge checks, cache/resume, and
optional conversion/validation.
NodeRequest
dataclass
¶
A single node request from a batch plan.
BatchSpec
dataclass
¶
BatchSpec(
plan_name: str,
batch_id: str,
name: str,
notebook_id: str,
nodes: list[NodeRequest],
known_edge_targets: set[str],
)
Resolved batch metadata and node list.
QueryOptions
dataclass
¶
QueryOptions(
notebook_id: str,
source_ids: list[str],
timeout: float,
output_format: OutputFormat,
profile: str | None = None,
)
Runtime options passed to nlm notebook query.
BatchRunConfig
dataclass
¶
BatchRunConfig(
plan_path: Path,
out_dir: Path,
prompt_file: Path,
output_format: OutputFormat,
timeout: float,
source_ids: list[str] = list(),
template_file: Path | None = None,
batch_id: str | None = None,
notebook_id: str | None = None,
profile: str | None = None,
cache_dir: Path | None = None,
max_retries: int = 2,
require_source_refs: bool = True,
allow_invented_edges: bool = False,
force: bool = False,
dry_run: bool = False,
converter: Path | None = _USE_DEFAULT,
validator: Path | None = _USE_DEFAULT,
)
Top-level run configuration.
load_batch
¶
Load one batch/cluster from a node extraction plan.
Source code in packages/akms_nodes_gen/src/akms_nodes_gen/nlm_batch.py
parse_structured_response
¶
Extract and parse a fenced YAML/JSON object from a NotebookLM answer.
Source code in packages/akms_nodes_gen/src/akms_nodes_gen/nlm_batch.py
extract_answer_text
¶
Return the answer text from either plain output or nlm --json output.
Source code in packages/akms_nodes_gen/src/akms_nodes_gen/nlm_batch.py
extract_fenced_block
¶
Extract the first matching fenced block, preferring the requested format.
Source code in packages/akms_nodes_gen/src/akms_nodes_gen/nlm_batch.py
validate_node_data
¶
validate_node_data(
data: dict,
spec: NodeRequest,
known_edge_targets: set[str],
require_source_refs: bool,
allow_invented_edges: bool = False,
) -> list[str]
Validate local AKMS constraints before writing output.
Source code in packages/akms_nodes_gen/src/akms_nodes_gen/nlm_batch.py
build_generation_prompt
¶
build_generation_prompt(
spec: NodeRequest,
batch: BatchSpec,
prompt_file: Path,
output_format: OutputFormat,
template_file: Path | None,
) -> str
Build a NotebookLM prompt from external prompt/template files and node metadata.
Source code in packages/akms_nodes_gen/src/akms_nodes_gen/nlm_batch.py
run_nlm_query
¶
Run nlm notebook query and return stdout.
Source code in packages/akms_nodes_gen/src/akms_nodes_gen/nlm_batch.py
run_batch
¶
Run one batch serially and write canonical YAML outputs.
Source code in packages/akms_nodes_gen/src/akms_nodes_gen/nlm_batch.py
537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 | |