Use a preset
Add entity types to DEFAULT_SCHEMA with a preset. A preset adds new types. It does not add relations or change descriptions. The default relations do not accept the new types.
Before you start
- Install Agentic GraphRAG. These steps do not need a database.
- Choose the types you need. The default schema reference lists them.
Add one preset
from agrag.common.data_models import DEFAULT_SCHEMA, OPERATIONS
schema = OPERATIONS.apply(DEFAULT_SCHEMA)
print(schema.name)
print([entity.label for entity in schema.entities])
apply returns a new schema. It does not change DEFAULT_SCHEMA.
Add two presets
from agrag.common.data_models import DEFAULT_SCHEMA, LEGAL, OPERATIONS
schema = LEGAL.apply(OPERATIONS.apply(DEFAULT_SCHEMA))
print(len(schema.entities), len(schema.relations))
The result has 14 entity types and 8 relation types.
Give the schema to a graph
Pass the new schema to Graph.open in place of DEFAULT_SCHEMA. Search with the same schema, so the engine searches the labels in the graph.
See Ingest documents for a complete Graph.open call.
Limits
- Each label adds extraction time. Add only the presets you need.
- Apply each preset once. Applying the same preset again raises
ValueError. - A preset cannot reuse a label that the schema already declares.
Related
- Reference: Default schema
- Guide: Define a graph schema