API Reference

Complete API reference for cognity-ai. All public classes, methods, and configuration options.

Python 3.11+ Stable Type-annotated

Modules

cognity-ai is organized into focused modules. Each module exposes a clean public API. Click any card to see the full reference for that module.


Common Import Patterns

The most frequently used symbols are importable directly from cognity-ai and its top-level submodules.

python
# Core facade — start here
from cognity_ai import RAGLibrary

# Full configuration via dataclasses
from cognity_ai.config import LibraryConfig

# Loader factory for custom pipelines
from cognity_ai.loaders import LoaderFactory

# Core data models
from cognity_ai.models import Document, SemanticChunk, RetrievalResult

Base classes for plugin authors

Extend these abstract base classes to register custom implementations via register_* methods.

python
from cognity_ai.loaders import BaseLoader
from cognity_ai.embedders import BaseEmbedder
from cognity_ai.generators import BaseGenerator
from cognity_ai.retrievers import BaseRetriever
from cognity_ai.stores import BaseVectorStore, BaseGraphStore

Core Data Models

All data exchanged between components uses these typed dataclasses from cognity_ai.models.

Document

Represents a raw ingested source document before chunking.

Field Type Description
doc_idstrUnique document identifier. Derived from filename or supplied by caller.
contentstrFull extracted text content of the document.
metadatadictArbitrary key-value metadata (source path, page count, author, etc.).
source_pathstr | NoneFilesystem path or URI to the original file.
statusstrLifecycle status: active, confirmed, or deprecated.

SemanticChunk

A chunk of text produced by a chunker, with embeddings and graph metadata attached.

Field Type Description
chunk_idstrUnique chunk identifier.
doc_idstrParent document identifier.
textstrThe chunk's text content.
embeddinglist[float] | NoneDense vector embedding. Populated after the embed step.
entitieslist[str]Named entities extracted from this chunk.
metadatadictPosition, page number, section heading, and other loader-specific metadata.

RetrievalResult

A single ranked result returned by a retriever, combining a chunk with its relevance score.

Field Type Description
chunkSemanticChunkThe matched chunk.
scorefloatRelevance score in [0, 1]; higher is more relevant.
methodstrThe retrieval method that produced this result.
graph_contextdict | NoneGraph neighbourhood context (entities, relationships) when using graph-aware methods.

Next Steps

Start with the RAGLibrary reference for the complete facade API, or dive into a specific subsystem below.

📚
RAGLibrary
Full facade API, all methods and parameters
🚀
Getting Started
Installation, configuration, first query
🏛
Architecture
System design and component diagram