Skip to main content

GraphModel

Trait GraphModel 

Source
pub trait GraphModel:
    Serialize
    + DeserializeOwned
    + JsonSchema
    + Clone
    + Send
    + Sync
    + 'static {
    // Provided method
    fn is_default_knowledge_graph() -> bool { ... }
}
Expand description

Marker trait for types that can be used as graph extraction models.

Types implementing this trait can be extracted from text via LLM structured output. The LLM generates JSON conforming to the type’s JsonSchema, which is then deserialized into the concrete type.

The built-in KnowledgeGraph model implements this trait with is_default_knowledge_graph() == true, which triggers additional post-processing (entity/edge expansion, deduplication, graph DB storage). Custom models return false, causing the extracted value to be stored directly in [DocumentChunk::contains] as serialized JSON — mirroring the Python branching at extract_graph_from_data.py:99-103.

§Required bounds

Serialize + DeserializeOwned + JsonSchema + Clone + Send + Sync + 'static

Provided Methods§

Source

fn is_default_knowledge_graph() -> bool

Returns true if this is the built-in KnowledgeGraph model.

Custom models should leave the default (false), which changes the processing flow: extracted data is stored as-is in chunk metadata instead of being expanded into graph nodes and edges.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§