Skip to main content

Crate cognee_lib

Crate cognee_lib 

Source
Expand description

Unified public API for Cognee-Rust.

This crate provides a single entry point by re-exporting the core operations:

  • add (AddPipeline)
  • cognify (cognify() free function and related types)
  • search (SearchBuilder/SearchOrchestrator and related types)

§OpenTelemetry support

Cognee emits structured spans for every pipeline stage, search retriever, and HTTP route. To export them to an OTLP collector (Grafana Tempo, Honeycomb, Dash0, in-cluster otel-collector, …), enable the telemetry cargo feature and set OTEL_EXPORTER_OTLP_ENDPOINT:

use cognee_lib::telemetry::{init_telemetry, TelemetryGuard};
use cognee_lib::config::{ConfigManager, Settings};
use tracing_subscriber::Registry;

let settings: Settings = ConfigManager::from_env().settings().clone();
let (_layer, _guard) = init_telemetry::<Registry>(&settings)
    .expect("telemetry init");
// ... compose `_layer` onto your subscriber; spans are flushed when
// `_guard` is dropped.

See docs/observability/opentelemetry.md for the full operator guide, env-var reference, and deployment recipes.

Re-exports§

pub use api::notebooks::NotebookError;
pub use api::notebooks::create_notebook;
pub use api::notebooks::delete_notebook;
pub use api::notebooks::list_notebooks;
pub use api::notebooks::update_notebook;
pub use api::DatasetDb;
pub use api::DatasetError;
pub use api::DatasetManager;
pub use component_manager::ComponentManager;
pub use config::ConfigError;
pub use config::ConfigManager;
pub use config::Settings;
pub use context::PipelineContext;
pub use error::ComponentError;
pub use cognee_core;
pub use cognee_database;
pub use cognee_delete;
pub use cognee_embedding;
pub use cognee_graph;
pub use cognee_llm;
pub use cognee_models;
pub use cognee_ontology;
pub use cognee_session;
pub use cognee_storage;
pub use cognee_vector;
pub use uuid;

Modules§

add
Data ingestion (add) pipeline.
api
Top-level API functions mirroring the Python SDK. High-level API functions for Cognee-Rust.
cognify
Knowledge-graph extraction (cognify) pipeline.
component_manager
Component lifecycle management. ComponentManager: lazy-initializing, shared component store.
config
Runtime configuration management. Shared configuration types for cognee-rust.
context
Pipeline execution context. Pipeline context trait for shared component access.
core
Core pipeline orchestration primitives.
database
Metadata database abstraction.
delete
Data and dataset deletion pipeline.
embedding
Embedding engine abstraction and providers.
error
Component error types. Error types for the cognee-lib crate.
graph
Graph database abstraction.
llm
LLM provider abstraction.
models
Core data models.
ontology
Ontology resolution.
prelude
Convenience re-exports for common usage.
search
Search pipeline and retrieval strategies.
session
Session management. Public session management API — thin wrappers over SessionManager.
storage
File storage abstraction.
telemetry
Product-analytics telemetry. Telemetry surface for embedders.
vector
Vector database abstraction.
visualization
Knowledge-graph visualization (requires visualization feature).

Structs§

AddParams
Optional parameters for the AddPipeline::add method.
AddPipeline
Ingest pipeline driven by the cognee-core task framework.
ContentHasher
ProcessedInput
Metadata extracted from a DataInput during streaming processing.

Enums§

VisualizationError
Errors that can occur while generating an HTML graph visualization.

Functions§

build_add_pipeline
Build a complete ingest Pipeline: DataInputProcessedInputData.
generate_dataset_id
Generate a deterministic dataset ID matching Python’s formula: uuid5(NAMESPACE_OID, f"{dataset_name}{str(user_id)}{str(tenant_id)}")
make_persist_data_task
Build a TypedTask that resolves or creates the dataset, deduplicates by content hash, persists a new Data record if needed, and returns it.
make_process_input_task
Build a TypedTask that streams a DataInput to storage, hashes its content, and returns a self-contained ProcessedInput.
persist_data
Persist a ProcessedInput as a Data record: resolve or create the dataset, deduplicate by content hash, create the record if new, and attach it to the dataset.
process_input
Process a single DataInput: resolve URLs, stream to storage, compute content hash, and extract all metadata needed to create a Data record.
visualize
Generate an interactive HTML knowledge-graph visualization of the supplied graph database.