Skip to content

Commit 794dee9

Browse files
Update user guide
1 parent cec1088 commit 794dee9

File tree

1 file changed

+28
-15
lines changed

1 file changed

+28
-15
lines changed

docs/source/user_guide_kg_builder.rst

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,18 @@ with, optionally, a list of their expected properties)
7979
and instructions on how to connect them (patterns).
8080
Node and relationship types can be represented
8181
as either simple strings (for their labels) or dictionaries. If using a dictionary,
82-
it must include a label key and can optionally include description and properties keys,
82+
it must include a ``label`` key and can optionally include ``description`` and ``properties`` keys,
8383
as shown below:
8484

8585
.. code:: python
8686
8787
NODE_TYPES = [
88-
# node types can be defined with a simple label...
88+
# node types can be defined with a simple label string...
8989
"Person",
90-
# ... or with a dict if more details are needed,
91-
# such as a description:
90+
# ... or with a dict for more detail such as a description.
91+
# When no properties key is provided, a default "name" property is added automatically.
9292
{"label": "House", "description": "Family the person belongs to"},
93-
# or a list of properties the LLM will try to attach to the entity:
93+
# or with an explicit list of properties the LLM will try to attach to the entity:
9494
{"label": "Planet", "properties": [{"name": "name", "type": "STRING", "required": True}, {"name": "weather", "type": "STRING"}]},
9595
]
9696
# same thing for relationships:
@@ -912,19 +912,32 @@ For improved reliability with :ref:`OpenAILLM <openaillm>` or :ref:`VertexAILLM
912912
Schema Validation and Node Properties
913913
--------------------------------------
914914

915-
**Important:** All node types must have at least one property defined. When using string shorthand for node types (e.g., ``"Person"``), a default ``"name"`` property is automatically added with ``additional_properties=True`` to allow flexible LLM extraction:
915+
All node types must have at least one property defined. When no properties are provided,
916+
a default ``name: STRING`` property is added automatically and ``additional_properties``
917+
is set to ``True`` to allow the LLM to extract additional properties freely.
918+
919+
This applies to both the **string shorthand** and the **long dict syntax** when the
920+
``properties`` key is omitted:
916921

917922
.. code:: python
918923
919-
# String shorthand - automatically gets default property
920-
NodeType("Person") # Becomes: properties=[{"name": "name", "type": "STRING"}], additional_properties=True
921-
922-
# Explicit definition - must include at least one property
923-
NodeType(
924-
label="Person",
925-
properties=[PropertyType(name="name", type="STRING")],
926-
additional_properties=True # Allow LLM to extract additional properties
927-
)
924+
# String shorthand — "name" property added automatically
925+
"Person"
926+
# equivalent to:
927+
NodeType(label="Person", properties=[PropertyType(name="name", type="STRING")], additional_properties=True)
928+
929+
# Long syntax without a properties key — same auto-addition applies
930+
{"label": "House", "description": "Family the person belongs to"}
931+
# equivalent to:
932+
NodeType(label="House", description="Family the person belongs to",
933+
properties=[PropertyType(name="name", type="STRING")], additional_properties=True)
934+
935+
Passing ``properties`` explicitly as an empty list raises a ``ValidationError``:
936+
937+
.. code:: python
938+
939+
# Raises ValidationError — empty list is not auto-filled
940+
{"label": "House", "properties": []}
928941
929942
**Relationship types** with no properties automatically set ``additional_properties=True`` to preserve LLM-extracted properties during graph construction.
930943

0 commit comments

Comments
 (0)