Skip to main content

OntoCast OntoCast logo

Ontology-guided extraction of RDF knowledge graphs from documents.

tests pre-commit PyPI Python Downloads Docs License DOI

OntoCast reads documents and writes an RDF knowledge graph: an ontology that describes the domain, and the facts the documents state in its terms. Give it your ontologies and it extracts facts against them; give it none and it builds one as it reads. Run it as an HTTP service, as a batch command, or inside your own LangChain or LangGraph agent.

Documentation: growgraph.github.io/ontocast · Project page: growgraph.dev/open-source/ontocast

Features

  • Ontology and facts together. Each part of a document goes through a language model in a render-and-critique loop, in parallel; ontology changes are merged, versioned and checked before facts are extracted against them.
  • Patches, not rewrites. The model emits insert/delete updates to a graph rather than regenerating it.
  • Entity disambiguation. Mentions of the same entity across a document are merged into one.
  • Validation. Deterministic checks, SHACL shapes, and repairs that need no extra model call.
  • Provenance. Facts carry RDF 1.2 provenance back to the text, which you can strip on output.
  • Ontology context. Each part of a document is shown the ontology it needs: chosen from your catalog, retrieved from a vector store (LanceDB or Qdrant), or fixed.
  • Storage. In memory by default, Apache Jena Fuseki for persistence, partitioned by tenant and project.
  • A light core. The base install embeds without a document-processing stack or an ML runtime; those are extras.

Install

pip install "ontocast[server,openai,doc-processing]"

server provides the ontocast command and HTTP API, openai the model provider (anthropic, google and ollama also exist), and doc-processing the document converter (PDF, Office, HTML, Markdown, images). All extras: Installation.

Quick start

OntoCast reads its settings from environment variables:

export LLM_API_KEY=sk-...
ontocast serve
curl -X POST http://127.0.0.1:8999/process -F "file=@document.pdf" -o result.json

The response holds the facts and the ontology as Turtle. To process files without a server:

ontocast process --input-path ./papers --output-dir ./out

To keep settings in a file, copy .env.example.minimal, edit it, and pass it with ontocast --env-file my.env serve (repeatable; later files win). Step by step: Quick start.

Your own ontologies

Put Turtle files in a directory and pass it at startup, or upload them to a running server:

ontocast serve --ontology-dir ./my-ontologies
curl -X POST http://127.0.0.1:8999/ontologies -F "file=@my-ontology.ttl"

Embed in your agent

pip install "ontocast[openai]" langchain
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)],
    system_prompt="Edit the ontology from the user's text.",
)

run_unit_pipeline processes a single passage, and make_ontocast_node adds OntoCast to your own LangGraph. See Embedding OntoCast.

How it works

The OntoCast pipeline: convert, chunk, then the ontology stages and the facts stages, then serialize

A document is converted to text and cut into parts. Each part updates the ontology; the updates are normalized, consolidated and checked. Each part then yields facts in the ontology's terms; the facts are merged, disambiguated and validated, and the result is written to the triple store. How OntoCast works.

Documentation

Getting started Installation · Quick start
Concepts How OntoCast works · Ontologies and facts
Guides Configuring OntoCast · Recipes · Validation and SHACL · Triple stores
Reference Configuration · HTTP API · Python API

Release notes: CHANGELOG.md

Contributing

See Contributing. Issues and discussion: GitHub. Contributors accept the Contributor License Agreement once, by commenting on their first pull request.

License

Apache License 2.0; see LICENSE.

Metadata

Release files for ontocast 0.9.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ontocast 0.9.1
File Size Uploaded Provenance Actions
ontocast-0.9.1.tar.gz 1.6 MB Without provenance Details for ontocast-0.9.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ontocast 0.9.1
File Interpreter ABI Platform Actions
ontocast-0.9.1-py3-none-any.whl Python 3 none any Details for ontocast-0.9.1-py3-none-any.whl

Total release size: 2.6 MB

Release files / ontocast-0.9.1.tar.gz

Download URL ontocast-0.9.1.tar.gz
Size 1.6 MB
Tags Source
SHA-256 checksum
How to use checksums
ed5e080679959d8d8b6acdddb9da847e39bc4a603658e0ed0b81e49470a06c77
BLAKE2b-256 checksum
How to use checksums
0c17ccdc7488c7a8d91d396493aac9c10a000964ba11887a7f605cd221134d47
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.21 {"installer":{"name":"uv","version":"0.12.21","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}

Release files / ontocast-0.9.1-py3-none-any.whl

Download URL ontocast-0.9.1-py3-none-any.whl
Size 1.0 MB
Tags Python 3
SHA-256 checksum
How to use checksums
af6d6343ff9b53e45bffeac1732ef225e7a745bdca6c6713c93732584535422c
BLAKE2b-256 checksum
How to use checksums
57789df7dce1d8d1541db9a9f9338bf829a15d1d267df27f408646453336bf22
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.21 {"installer":{"name":"uv","version":"0.12.21","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}

Security for ontocast 0.9.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page