Skip to content

API Reference parrot.knowledge.bookstore.models

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.knowledge.bookstore.models

View source

Pydantic models for the Bookstore catalog (the "ficha hemeroteca").

:class:BookCard is the durable catalog card persisted per book in library.db; :class:CardDraft is the structured-output target the LLM fills during carding (:mod:parrot.knowledge.bookstore.carding).

Class Anchor

One reference from a notebook node into a book (optionally into a node of it).

Fields:

Field Type Default Description
book_id str
scope Literal['project', 'global'] 'project'
node_id Optional[str] None
doc_id Optional[str] None
revision Optional[str] None

Class Annotation

A notebook node as returned next to a book section.

Fields:

Field Type Default Description
note_tree str
node_id str
title str
body str
note_kind Literal['footnote', 'note', 'sector', 'sheet'] 'note'
origin Literal['human', 'agent', 'draft'] 'human'
anchor_status Literal['current', 'remapped', 'stale'] 'current'

Class BookCard

The catalog card ("ficha hemeroteca") for one indexed book.

book_id doubles as the PageIndex tree_name — one slug, one tree, one card.

Fields:

Field Type Default Description
book_id str
title str
authors list[str]
year Optional[int] None
language Optional[str] None
topics list[str]
summary str ''
toc_digest str ''
toc list[TocEntry]
tree_name str
scope Literal['project', 'global'] 'project'
source_path str
source_sha256 str
source_format Literal['pdf', 'md', 'txt', 'epub', 'mobi', 'docx', 'tree']
page_count Optional[int] None
chapter_count int 0
added_at str
card_origin Literal['llm', 'fallback', 'manual'] 'llm'
genre Genre 'other'
traditions list[str]
period Optional[str] None
community_id Optional[str] None
community_label Optional[str] None
kind Literal['book', 'notes'] 'book'
notes_for Optional[str] None

Method BookCard.brief

Compact dict for catalog listings (small tool outputs).

brief() -> dict

Returns: dict — The fields an agent needs to pick a book, without the full ToC payload.

Class BookCommunity

One persisted community partition entry.

Fields:

Field Type Default Description
community_id str
label str
label_origin Literal['llm', 'derived', 'title']
description str ''
algorithm Literal['leiden', 'louvain']
size int
cohesion float
centroid_book_id str
member_book_ids list[str]
inter_relations list[dict]
computed_at str

Class BookRelation

One typed, provenance-bearing edge in the book graph.

Symmetric relations (everything in :data:RelationKind except influenced_by/responds_to — see :data:SYMMETRIC_RELS) are canonicalised src_book_id < dst_book_id before persistence so (a, b) and (b, a) collapse to a single row.

Fields:

Field Type Default Description
src_book_id str
dst_book_id str
rel RelationKind
weight float 1.0
origin Literal['deterministic', 'llm', 'community', 'manual']
confidence Optional[float] None
rationale str ''
computed_at str

Class CardDraft

LLM structured-output draft of the descriptive card fields.

Produced by carding.generate_card_fields (or its no-LLM fallback) and merged into a :class:BookCard by the ingestion flow.

Fields:

Field Type Default Description
title str Full book title.
authors list[str] Author names, best effort.
year Optional[int] None Publication year when identifiable.
language Optional[str] None Primary language, ISO 639-1 (e.g. 'en', 'es').
topics list[str] 5-10 research topics/keywords this book is useful for.
summary str '' One-paragraph librarian summary: what the book covers and what kind of questions it can answer.
genre Genre 'other' Closed literary genre classification.
traditions list[str] Philosophical/literary traditions or schools this book belongs to (e.g. 'stoicism', 'spanish golden age').
period Optional[str] None Historical period or era (e.g. 'siglo de oro', 'han dynasty').

Class CommunityLabelDraft

Structured LLM output: a label for one community.

Fields:

Field Type Default Description
label str Community label, 6 words or fewer.
description str '' One-sentence description of the community.

Attribute Genre

Attribute REL_WEIGHTS

Type: dict[str, float]

Class RelateSummary

Outcome of one :meth:Bookstore.relate_books batch run.

Fields:

Field Type Default Description
targets list[str]
deterministic_edges int 0
llm_prompts int 0
llm_edges int 0
skipped_llm_reason Optional[str] None
failed dict[str, str]
communities Optional[int] None
notes list[str]

Class RelationDraft

Structured LLM output: every judged candidate for one source book.

Returned by one ask_structured call per source book in Stage 2 (spec §2 step 3); judgements may be empty when the model found no candidates worth judging.

Fields:

Field Type Default Description
judgements list[RelationJudgement]

Class RelationJudgement

One LLM verdict on one candidate pair, logged regardless of outcome.

Every candidate considered by Stage 2 (conceptual relations) is logged here — including rel="none" verdicts and below-floor confidences — so :meth:CatalogStore.judged_pairs can skip already-asked pairs on the next bookstore relate run.

Fields:

Field Type Default Description
dst_book_id str
rel Literal['influenced_by', 'responds_to', 'parallels', 'contrasts_with', 'none']
confidence float
rationale str ''

Attribute RelationKind

Attribute SYMMETRIC_RELS

Type: frozenset[str]

Class SectorDraft

LLM-proposed sector for the library notebook.

Fields:

Field Type Default Description
code str
title str
rationale str ''
books list[Anchor]

Class TocEntry

One table-of-contents row derived from a PageIndex tree node.

Fields:

Field Type Default Description
node_id str
title str
depth int 1
start_page Optional[int] None
end_page Optional[int] None

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally