Skip to content

ontocast.prompt.render_facts

build_citation_metadata_instruction(vocabulary)

Render the citation-metadata prompt block for a configured vocabulary.

The bibliographic terms are configuration, not retrieval: a reference list is not domain content, so its vocabulary never reaches the catalog. Keeping them out of the prompt literal is what lets a non-schema.org catalog (bibo, FaBiO, DCMI) describe citations in its own terms.

Parameters:

Name Type Description Default
vocabulary dict[str, str]

Role -> term mapping (CHUNK_CITATION_VOCABULARY). An empty mapping emits the routing guidance with no term list.

required

Returns:

Name Type Description
str str

The prompt block, or the header alone when no terms are configured.

Source code in ontocast/prompt/render_facts.py
def build_citation_metadata_instruction(vocabulary: dict[str, str]) -> str:
    """Render the citation-metadata prompt block for a configured vocabulary.

    The bibliographic terms are configuration, not retrieval: a reference list
    is not domain content, so its vocabulary never reaches the catalog. Keeping
    them out of the prompt literal is what lets a non-schema.org catalog (bibo,
    FaBiO, DCMI) describe citations in its own terms.

    Args:
        vocabulary: Role -> term mapping (``CHUNK_CITATION_VOCABULARY``). An
            empty mapping emits the routing guidance with no term list.

    Returns:
        str: The prompt block, or the header alone when no terms are configured.
    """
    if not vocabulary:
        return _CITATION_METADATA_HEADER
    fallback = vocabulary.get("fallback_class", "")
    filled = {
        "work_class": vocabulary.get("work_class", "the cited-work class"),
        "fallback_clause": (
            f" (or {fallback} when clearly not an article)" if fallback else ""
        ),
        "title": vocabulary.get("title", "the title property"),
        "author": vocabulary.get("author", "the author property"),
        "author_name": vocabulary.get("author_name", "the name property"),
        "date_published": vocabulary.get(
            "date_published", "the publication-date property"
        ),
        "venue": vocabulary.get("venue", "the venue property"),
        "identifier": vocabulary.get("identifier", "the identifier property"),
        "cites": vocabulary.get("cites", "the citation property"),
    }
    return _CITATION_METADATA_HEADER + _CITATION_VOCABULARY_TEMPLATE.format(**filled)