pub struct Entity {
pub base: DataPoint,
pub name: String,
pub is_a: Option<Uuid>,
pub description: String,
}Expand description
Storage-layer entity model.
Represents an entity (e.g., “TechCorp”, “Alice”, “London”) extracted from text. Each entity has a name, description, and a reference to its EntityType (e.g., “Organization”, “Person”, “Location”).
Fields§
§base: DataPointBase data point fields (id, timestamps, metadata, etc.)
name: StringEntity name (e.g., “TechCorp”)
is_a: Option<Uuid>Reference to EntityType UUID (e.g., UUID of “Organization” type)
description: StringEntity description from LLM extraction
Implementations§
Source§impl Entity
impl Entity
Sourcepub const INDEX_FIELDS: &'static [&'static str]
pub const INDEX_FIELDS: &'static [&'static str]
Index fields to embed for vector search.
Sourcepub fn id_for(value: &str) -> Uuid
pub fn id_for(value: &str) -> Uuid
Deterministic, class-namespaced id for an Entity identity value.
Mirrors Python’s Entity.id_for(value) (identity_fields=["name"]):
uuid5(NAMESPACE_OID, "Entity:<normalized_value>"). This is the single
source of truth for “what id does the entity with this identity have”,
used both when constructing entities and when looking them up from a raw
string before an instance exists.
Sourcepub fn new(
name: impl Into<String>,
entity_type_id: Option<Uuid>,
description: impl Into<String>,
dataset_id: Option<Uuid>,
) -> Self
pub fn new( name: impl Into<String>, entity_type_id: Option<Uuid>, description: impl Into<String>, dataset_id: Option<Uuid>, ) -> Self
Create a new Entity.
§Arguments
name- Entity nameentity_type_id- Optional reference to EntityTypedescription- Entity descriptiondataset_id- Dataset UUID
Sourcepub fn from_node(
node_id: impl Into<String>,
node_name: impl Into<String>,
node_description: impl Into<String>,
entity_type_id: Uuid,
dataset_id: Option<Uuid>,
) -> Self
pub fn from_node( node_id: impl Into<String>, node_name: impl Into<String>, node_description: impl Into<String>, entity_type_id: Uuid, dataset_id: Option<Uuid>, ) -> Self
Create Entity from LLM-extracted Node.
§Arguments
node_id- Original node ID from LLM extractionnode_name- Node namenode_description- Node descriptionentity_type_id- EntityType UUIDdataset_id- Dataset UUID
Sourcepub fn get_embeddable_text(&self) -> String
pub fn get_embeddable_text(&self) -> String
Get the entity name (for embedding).
Sourcepub fn set_description(&mut self, description: impl Into<String>)
pub fn set_description(&mut self, description: impl Into<String>)
Update entity description.
Sourcepub fn set_entity_type(&mut self, entity_type_id: Uuid)
pub fn set_entity_type(&mut self, entity_type_id: Uuid)
Update entity type reference.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Entity
impl<'de> Deserialize<'de> for Entity
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl HasDataPoint for Entity
impl HasDataPoint for Entity
Source§fn data_point(&self) -> &DataPoint
fn data_point(&self) -> &DataPoint
DataPoint of this container.Source§fn data_point_mut(&mut self) -> &mut DataPoint
fn data_point_mut(&mut self) -> &mut DataPoint
DataPoint of this container.Source§fn for_each_child_mut(&mut self, _visit: &mut dyn FnMut(&mut dyn HasDataPoint))
fn for_each_child_mut(&mut self, _visit: &mut dyn FnMut(&mut dyn HasDataPoint))
HasDataPoint.
Default: no children. Override on container types whose fields
own (rather than reference by Uuid) another HasDataPoint.