Skip to main content
cognee-rust mirrors two Python cognify knobs that swap the LLM’s structured output shape: graph_model (graph extraction) and summarization_model (summaries). Their wiring status differs — read carefully.

Summarization schema — wired

What it does

Replaces the default SummarizedContent shape requested from the LLM during the summarization stage with your own JSON Schema. Mirrors Python’s CognifyConfig.summarization_model.

Requirement

The schema must contain a string summary property — the pipeline reads summary to build each TextSummary. This is validated up front by validate_summary_schema, so a bad schema fails at config time rather than mid-pipeline.

Example (programmatic)

use cognee_cognify::CognifyConfig;
use serde_json::json;

let schema = json!({
    "type": "object",
    "properties": {
        "summary":  { "type": "string" },
        "keywords": { "type": "array", "items": { "type": "string" } }
    },
    "required": ["summary"]
});

let config = CognifyConfig::default()
    .with_summary_schema(schema)?;   // returns Err if `summary` is missing/non-string
This path is consumed: the summarization task constructs SummaryExtractor::new_with_schema(llm, config.summary_schema) (crates/cognify/src/tasks.rs), and the extractor requests the custom schema when it is Some (crates/cognify/src/summarization/extractor.rs).

Via top-level config

cognee-lib exposes a runtime setter mirroring Python’s cognee.config.set_summarization_model(...):
settings.set_summarization_schema(schema)?;  // crates/lib/src/config.rs

Graph extraction schema — set but NOT consumed (standalone pipeline)

What it does (in Python)

Python’s graph_model lets you replace the default KnowledgeGraph extraction shape with a custom Pydantic model.

Status in Rust

CognifyConfig.graph_schema exists and has a builder (CognifyConfig::with_graph_schema), but the standalone cognify graph-extraction task does not read it. A graph_schema you set on CognifyConfig is effectively a no-op for the in-process pipeline. Its only live consumers today are: See docs/roadmap/cognify-compatibility-plan.md — wiring graph_schema into the extraction task is tracked as follow-up work. To customize extraction today, use a custom prompt instead.

Pointers