Skip to main content

OntoCast OntoCast logo

Agentic ontology-assisted extraction of RDF knowledge graphs from documents.

Python PyPI version PyPI Downloads Docs License pre-commit DOI

OntoCast turns unstructured text into queryable RDF: it co-evolves domain ontologies and fact graphs in a parallel map/reduce pipeline, with RDF 1.2 provenance, entity disambiguation across chunks, and optional vector-backed ontology retrieval. Run it as a REST service, a batch CLI, or embed the pipeline in your own LangChain / LangGraph agent.

Documentation: growgraph.github.io/ontocast


Why OntoCast

Most extractors dump triples and leave ontology drift to you. OntoCast treats schema and instance data as one loop: per-chunk render → critic → merge, with GraphUpdate patches (insert/delete) instead of regenerating whole graphs, SHACL validation with LLM-free autofix, and a light install so you can embed the core without pulling Docling, gRPC, or ONNX.


Features

  • Parallel ontology + facts loops — concurrent per-unit render/critic with configurable workers
  • GraphUpdate patches — token-efficient insert/delete ops, not full-graph regeneration
  • Entity disambiguation — embedding + symbolic alignment across chunks
  • RDF 1.2 provenance — quoted triples / provenance artifacts; optional strip_provenance
  • Ontology context — catalog selection, vector retrieval (LanceDB or Qdrant), or a fixed ontology
  • Facts validation — invariants, SHACL, and machine repairs without an extra LLM pass
  • Stores — in-memory pyoxigraph by default; Fuseki for persistence; tenancy by tenant/project
  • LLM caching — disk cache, in-flight limits, optional read-only / batch pre-warm
  • Embeddableontocast_tools, run_unit_pipeline, or a LangGraph node

Install

Pick at least one LLM provider extra. Add server for the CLI and HTTP API:

uv add "ontocast[server,openai]"
# or: pip install "ontocast[server,openai]"

Common add-ons: doc-processing (PDF/DOCX), lancedb or qdrant (ontology retrieval), shacl (shape validation).

uv add "ontocast[server,openai,doc-processing,lancedb,shacl]"

Full extras table: Installation.


Quick start

cp .env.example .env
# Set LLM_API_KEY (and LLM_PROVIDER / LLM_MODEL_NAME as needed)

ontocast serve
curl -X POST http://localhost:8999/process -F "file=@document.pdf"

Batch without a server:

ontocast process --input-path ./document.pdf --head-chunks 5 --output-dir ./out

Omit FUSEKI_URI for in-memory pyoxigraph. Details: Quick Start.

Supplying Your Ontologies

OntoCast uses seed ontologies (in Turtle .ttl format) to guide extraction. Provide yours in two ways:

  1. Directory Seed: Set ONTOCAST_ONTOLOGY_DIRECTORY=/path/to/your/ontologies in your .env. All .ttl files in that folder sync automatically on startup.
  2. API Upload: Register schemas dynamically with the running server:
    curl -X POST "http://localhost:8999/ontologies?tenant=ontocast&project=test" -F "file=@my_ontology.ttl"
    

Embed in your agent

from langchain.agents import create_agent
from ontocast import Config, ToolBox, ontocast_tools

tools = await ToolBox.acreate(Config.in_memory())
await tools.initialize()

agent = create_agent(
    model,
    tools=[*ontocast_tools(tools)],
    prompt="Edit the ontology from the user's text.",
)

Also: run_unit_pipeline for a single passage, or make_ontocast_node inside your own LangGraph — see Embedding OntoCast.


Workflow

Workflow diagram

  1. Convert → chunk prepare (segment, tag, filter, size)
  2. Parallel ontology render → normalize → consolidate → structural check → critic
  3. Parallel facts render → merge / disambiguate → validate (invariants, SHACL, autofix)
  4. Serialize to the triple store; return Turtle from the API

Workflow guide · landscape: graph.lr.png · per-unit: ontology_loop, facts_loop


Documentation

Everything lives at growgraph.github.io/ontocast:

Installation · Quick Start Getting started
Core Concepts · Workflow · Configuration How it works
API · Embedding · Tenancy Integrate
Ontology Context · Validation / SHACL · Triple Stores Operate
API Reference Python API

Release notes: CHANGELOG.md


Contributing

See Contributing. Issues and discussion: GitHub.

License

Apache License 2.0 — see LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ontocast-0.6.0.tar.gz (795.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ontocast-0.6.0-py3-none-any.whl (581.2 kB view details)

Uploaded Python 3

File details

Details for the file ontocast-0.6.0.tar.gz.

File metadata

  • Download URL: ontocast-0.6.0.tar.gz
  • Upload date:
  • Size: 795.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for ontocast-0.6.0.tar.gz
Algorithm Hash digest
SHA256 9a265e05e4279536d4e59477de3ffeb710a82f6c0243ffd5302c95ad01a037b5
MD5 52c7daf1cc447bad4753051c444942f0
BLAKE2b-256 d521860caf32762457878465a2d59a1aebf6570fa8bf640936a07fe1649454de

See more details on using hashes here.

File details

Details for the file ontocast-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: ontocast-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 581.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for ontocast-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4796d288aac1eda3824d1f02102ee167451231052bf9cfd2f20d9aa578ac70c7
MD5 f01ca61f2a1bfdd8ceffab36093fd47c
BLAKE2b-256 3721938227a99eabcbd117311e6bacc561d94e83e258bc2197216a8ecec1e9ab

See more details on using hashes here.

Release history Release notifications | RSS feed

0.6.1

2 files

This release

0.6.0 This release

2 files

0.4.3

2 files

0.4.0

2 files

0.3.0

2 files

0.2.5

2 files

0.2.4

2 files

0.2.2

2 files

0.2.1

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page