Skip to content

docs: migrate to v1.2 ontology vocabulary - #279

Open
galshubeli wants to merge 3 commits into
mainfrom
docs/ontology-vocab-rename
Open

docs: migrate to v1.2 ontology vocabulary#279
galshubeli wants to merge 3 commits into
mainfrom
docs/ontology-vocab-rename

Conversation

@galshubeli

@galshubeli galshubeli commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

The documentation, README, and runnable examples still used the pre-v1.2 class names — GraphSchema / EntityType / RelationType / PropertyType — and the deprecated schema= kwarg. Copy-pasting any docs example on a current SDK emits DeprecationWarnings, and the aliases are slated for removal.

This PR migrates everything to the current vocabulary (Ontology / Entity / Relation / Attribute, ontology=), matching the v1.2.x rename (commit 363a53d):

  • Docs + README (8 files): all examples, type hints, and prose renamed; docs/graph-schema.md filename (and its published URL) intentionally unchanged; api-reference ## Schema section renamed to ## Ontology
  • Examples 02/03/06: renamed + imports re-sorted; all three compile-checked. 08_ontology_lifecycle.py intentionally untouched — its step 8 demonstrates that the legacy names still work
  • Alignment fix found during verification: api-reference documented required: bool = False on Attribute, but that field does not exist in core/models.py — removed
  • Legitimate uses of "schema" left alone (JSON schema in benchmark.md, DB schema prompt in retrieval.md, SchemaExtensionProposal which is a real class)

Every renamed reference was verified against graphrag_sdk/src on main: GraphRAG(ontology=...) + deprecated schema= shim, public attribute self.ontology, extract(..., ontology, ...), ontology.entities precedence, model fields of Entity/Relation/Attribute/Ontology, the 11 default entity types list, and the __init__ exports (old names exist only in _LEGACY_MODEL_ALIASES).

Ruff on the touched example files: 5 findings on this branch vs 6 on main — all pre-existing, none introduced.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Updated guides and API reference to use ontology-based configuration (Ontology, Entity, Relation, Attribute) instead of the legacy schema terminology.
    • Revised extraction, ingestion, and strategy documentation to accept and prioritize ontology inputs (including “open schema mode” using an empty Ontology()).
    • Refreshed all related examples to construct an Ontology and pass it into GraphRAG via the ontology= argument.

…ttribute)

The docs still used the pre-v1.2 names (GraphSchema/EntityType/
RelationType/PropertyType) and the deprecated schema= kwarg, which
now emit DeprecationWarnings when copy-pasted. Updated all examples,
type hints, and prose to the current vocabulary; the graph-schema
page URL is unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The documentation and executable examples replace GraphSchema terminology with Ontology, update documented API parameters and models, and revise configuration, extraction, onboarding, README, schema-reference, and GraphRAG usage examples.

Changes

Ontology documentation update

Layer / File(s) Summary
Documented ontology API contracts
docs/api-reference.md
The API reference documents Ontology, Entity, Relation, and Attribute, and changes documented schema parameters and attributes to ontology.
Configuration and extraction guidance
docs/configuration.md, docs/extraction.md, docs/ingestion.md, docs/strategies.md
Configuration and extraction examples use ontology definitions, update entity precedence, and describe open-schema behavior with Ontology().
README and getting-started examples
README.md, docs/getting-started.md
User-facing examples construct Ontology objects and pass them to GraphRAG through ontology=.
Schema reference examples
docs/graph-schema.md
Schema reference examples and documented model exports use the Ontology API and terminology.
Executable ontology examples
graphrag_sdk/examples/02_pdf_with_schema.py, graphrag_sdk/examples/03_custom_strategies.py, graphrag_sdk/examples/06_markdown_document_aware.py
SDK examples replace schema factories and constants with Ontology definitions and pass them to GraphRAG through ontology=.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

  • FalkorDB/GraphRAG-SDK#256: Introduces the ontology-driven code and API changes reflected by these documentation and example updates.

Suggested reviewers: naseem77

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the PR’s main change: migrating docs and examples to the v1.2 ontology vocabulary.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/ontology-vocab-rename

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

The Attribute model on main has only name/type/description; the
required field documented here does not exist in the code.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/api-reference.md`:
- Around line 524-535: Update the ontology example’s graphrag_sdk import
statement to include Attribute alongside Ontology, Entity, and Relation, so the
Entity.properties annotation references an imported symbol.
- Line 47: Update the constructor parameter table in docs/api-reference.md to
rename schema to ontology, matching the constructor and public attribute names
while preserving the existing type, default, and description.
- Around line 540-544: Update the Relation model documentation in the API
reference to include the missing properties field as a list of Attribute values,
matching the model definition and configuration documentation; leave the
existing label, description, and patterns entries unchanged.

In `@docs/configuration.md`:
- Around line 359-361: Complete the schema-to-ontology terminology migration
across the documented sites: in docs/configuration.md lines 359-361, rename
“Open Schema Mode” and “open-schema mode”; in docs/ingestion.md line 148, rename
“Open schema mode”; in docs/strategies.md lines 263-275, replace “schema types”
in the explanation and example comment; and in docs/getting-started.md lines
66-69, change “Define a Schema” to “Define an Ontology.”
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 81363f18-a962-4403-b3c5-f718eb97e2fe

📥 Commits

Reviewing files that changed from the base of the PR and between 0ab92ba and 74c9c21.

📒 Files selected for processing (8)
  • README.md
  • docs/api-reference.md
  • docs/configuration.md
  • docs/extraction.md
  • docs/getting-started.md
  • docs/graph-schema.md
  • docs/ingestion.md
  • docs/strategies.md

Comment thread docs/api-reference.md
| `llm` | `LLMInterface` | required | LLM provider |
| `embedder` | `Embedder` | required | Embedding provider |
| `schema` | `GraphSchema \| None` | `None` | Schema constraints for extraction (empty = unconstrained) |
| `schema` | `Ontology \| None` | `None` | Schema constraints for extraction (empty = unconstrained) |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Rename the constructor parameter in the parameter table.

The constructor and public attributes use ontology, but the table still documents schema. Copying this table would encourage use of the deprecated keyword and contradict the API signature.

Proposed fix
-| `schema` | `Ontology \| None` | `None` | Schema constraints for extraction (empty = unconstrained) |
+| `ontology` | `Ontology \| None` | `None` | Ontology constraints for extraction (empty = unconstrained) |
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
| `schema` | `Ontology \| None` | `None` | Schema constraints for extraction (empty = unconstrained) |
| `ontology` | `Ontology \| None` | `None` | Ontology constraints for extraction (empty = unconstrained) |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/api-reference.md` at line 47, Update the constructor parameter table in
docs/api-reference.md to rename schema to ontology, matching the constructor and
public attribute names while preserving the existing type, default, and
description.

Comment thread docs/api-reference.md
Comment on lines 524 to 535
```python
from graphrag_sdk import GraphSchema, EntityType, RelationType
from graphrag_sdk import Ontology, Entity, Relation
```

### EntityType
### Entity

```python
class EntityType(DataModel):
class Entity(DataModel):
label: str # e.g. "Person"
description: str | None = None # Helps LLM understand what to extract
properties: list[PropertyType] = [] # Optional property definitions
properties: list[Attribute] = [] # Optional property definitions
```

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Import Attribute in the ontology example.

The snippet references Attribute in Entity.properties but does not import it, so a reader copying the example gets an undefined name.

Proposed fix
-from graphrag_sdk import Ontology, Entity, Relation
+from graphrag_sdk import Ontology, Entity, Relation, Attribute
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
```python
from graphrag_sdk import GraphSchema, EntityType, RelationType
from graphrag_sdk import Ontology, Entity, Relation
```
### EntityType
### Entity
```python
class EntityType(DataModel):
class Entity(DataModel):
label: str # e.g. "Person"
description: str | None = None # Helps LLM understand what to extract
properties: list[PropertyType] = [] # Optional property definitions
properties: list[Attribute] = [] # Optional property definitions
```
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/api-reference.md` around lines 524 - 535, Update the ontology example’s
graphrag_sdk import statement to include Attribute alongside Ontology, Entity,
and Relation, so the Entity.properties annotation references an imported symbol.

Comment thread docs/api-reference.md
Comment on lines +540 to 544
class Relation(DataModel):
label: str # e.g. "WORKS_AT"
description: str | None = None
patterns: list[tuple[str, str]] = [] # Allowed (source_label, target_label) pairs
```

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== Relevant docs snippets ==\n'
for f in docs/api-reference.md docs/configuration.md; do
  echo "--- $f ---"
  if [ -f "$f" ]; then
    # show only the likely relevant area if present
    rg -n -C 4 'Relation|properties|patterns|Attribute' "$f" || true
  else
    echo "missing"
  fi
done

printf '\n== Search for Relation model definition/usages ==\n'
rg -n -C 3 'class Relation|Relation\(|properties: list\[Attribute\]|patterns: list\[tuple\[str, str\]\]' . || true

Repository: FalkorDB/GraphRAG-SDK

Length of output: 50379


🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n -C 4 'class Relation\b|properties: list\[Attribute\]|patterns: list\[tuple\[str, str\]\]' graphrag_sdk/src docs --glob '!**/node_modules/**'

Repository: FalkorDB/GraphRAG-SDK

Length of output: 6750


Document Relation.properties in the API reference
In docs/api-reference.md:540-544, add properties: list[Attribute] to match docs/configuration.md and graphrag_sdk/src/graphrag_sdk/core/models.py.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/api-reference.md` around lines 540 - 544, Update the Relation model
documentation in the API reference to include the missing properties field as a
list of Attribute values, matching the model definition and configuration
documentation; leave the existing label, description, and patterns entries
unchanged.

Comment thread docs/configuration.md
Comment on lines 359 to +361
### Open Schema Mode

If no entity types or relation types are defined (empty `GraphSchema()`), the extraction operates in open-schema mode and the pruning step is skipped. This lets the LLM extract any entities and relationships it finds.
If no entity types or relation types are defined (empty `Ontology()`), the extraction operates in open-schema mode and the pruning step is skipped. This lets the LLM extract any entities and relationships it finds.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Complete the schema-to-ontology terminology migration.

Several ontology sections still retain deprecated “schema” wording, which makes the documentation inconsistent with the v1.2 API vocabulary.

  • docs/configuration.md#L359-L361: Rename “Open Schema Mode” and “open-schema mode” to ontology terminology.
  • docs/ingestion.md#L148-L148: Rename “Open schema mode.”
  • docs/strategies.md#L263-L275: Replace “schema types” in the explanation and example comment.
  • docs/getting-started.md#L66-L69: Rename the section heading from “Define a Schema” to “Define an Ontology.”
📍 Affects 4 files
  • docs/configuration.md#L359-L361 (this comment)
  • docs/ingestion.md#L148-L148
  • docs/strategies.md#L263-L275
  • docs/getting-started.md#L66-L69
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/configuration.md` around lines 359 - 361, Complete the
schema-to-ontology terminology migration across the documented sites: in
docs/configuration.md lines 359-361, rename “Open Schema Mode” and “open-schema
mode”; in docs/ingestion.md line 148, rename “Open schema mode”; in
docs/strategies.md lines 263-275, replace “schema types” in the explanation and
example comment; and in docs/getting-started.md lines 66-69, change “Define a
Schema” to “Define an Ontology.”

08_ontology_lifecycle.py intentionally untouched — its step 8
demonstrates that the legacy names still work.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant