Skip to content

ontocast.onto.llm_graph_payload

Strict LLM wire coercion for RDF graph fields on canonical Pydantic models.

coerce_llm_graph_wire(value)

Coerce LLM wire payloads to RDFGraph using llm_graph_format_ctx.

Source code in ontocast/onto/llm_graph_payload.py
def coerce_llm_graph_wire(value: Any) -> RDFGraph:
    """Coerce LLM wire payloads to RDFGraph using ``llm_graph_format_ctx``."""
    fmt = llm_graph_format_ctx.get()
    if fmt == LLMGraphFormat.TURTLE:
        return _coerce_turtle_graph_payload(value)
    return _coerce_jsonld_graph_payload(value)