# Create a source reference to external datasample_text =b"Laying Plans Sun Tzu said, The art of war is of vital importance..."content_hash = SourceRef.compute_hash(sample_text)source = SourceRef( plugin_name="cjm-transcription-plugin-voxtral-hf", table_name="transcriptions", row_id="job-123", content_hash=content_hash, segment_slice="timestamp:00:10-00:30")# Convert with provenance trackinggraph_node = alice.to_graph_node(sources=[source])print(f"Sources: {len(graph_node.sources)}")print(f"Source ref: {graph_node.sources[0]}")
The to_graph_node() method automatically normalizes the name property for consistent display. If no name field exists, it falls back to title, label, or truncated text.
# Domain node with 'title' instead of 'name'class Book(DomainNode): title: str author: Optional[str] =Nonebook = Book(title="The Art of War", author="Sun Tzu")graph_node = book.to_graph_node()# 'name' is auto-populated from 'title'print(f"Properties: {graph_node.properties}")assert graph_node.properties['name'] =="The Art of War"
Properties: {'title': 'The Art of War', 'author': 'Sun Tzu', 'name': 'The Art of War'}
# Domain node with 'text' field (truncated to 50 chars)class Quote(DomainNode): text: strquote = Quote(text="This is a very long quote that exceeds fifty characters and will be truncated for the name field.")graph_node = quote.to_graph_node()print(f"Name (truncated): '{graph_node.properties['name']}'")assertlen(graph_node.properties['name']) ==50
Name (truncated): 'This is a very long quote that exceeds fifty chara'