Stores
Vector stores and graph stores — abstract base classes, all provider implementations, and configuration examples.
Vector Stores
All vector store implementations extend BaseVectorStore. Select a provider via the vector_store key in LibraryConfig or pass directly to RAGLibrary.
BaseVectorStore ABC
-
def upsert_chunks(self, chunks: list[SemanticChunk]) -> None abstractInsert or update a batch of semantic chunks in the vector store. Uses chunk ID as the upsert key.
-
def query_chunks(self, embedding: list[float], top_k: int, filters: dict | None = None) -> list[RetrievalResult] abstractNearest-neighbour search over chunk embeddings. Accepts optional metadata
filters(provider-specific syntax). -
def query_by_chunk_ids(self, chunk_ids: list[str]) -> list[RetrievalResult] abstractFetch chunks by their explicit IDs. Used by the bridge channel in
HybridGraphRetriever. -
def upsert_community(self, community: CommunityInfo) -> None abstractStore a community summary embedding alongside its metadata. Called after
detect_communities(). -
def query_communities(self, embedding: list[float], top_k: int) -> list[RetrievalResult] abstractSemantic search over community summaries. Drives CH3 (community channel) in
HybridGraphRetriever. -
def delete_by_doc_id(self, doc_id: str) -> None abstractRemove all chunks associated with
doc_id. Used during document deprecation and replacement. -
def count(self) -> int abstractReturn the total number of chunk vectors currently stored.
from abc import ABC, abstractmethod
from cognity_ai.models import SemanticChunk, RetrievalResult, CommunityInfo
class BaseVectorStore(ABC):
@abstractmethod
def upsert_chunks(self, chunks: list[SemanticChunk]) -> None: ...
@abstractmethod
def query_chunks(
self, embedding: list[float], top_k: int, filters: dict | None = None
) -> list[RetrievalResult]: ...
@abstractmethod
def query_by_chunk_ids(self, chunk_ids: list[str]) -> list[RetrievalResult]: ...
@abstractmethod
def upsert_community(self, community: CommunityInfo) -> None: ...
@abstractmethod
def query_communities(
self, embedding: list[float], top_k: int
) -> list[RetrievalResult]: ...
@abstractmethod
def delete_by_doc_id(self, doc_id: str) -> None: ...
@abstractmethod
def count(self) -> int: ...
Vector Store Providers
Select a provider by passing its key string or the concrete class. All providers implement BaseVectorStore in full unless noted.
| Key | Class | Install Extra | Type | Notes |
|---|---|---|---|---|
chroma DEFAULT |
ChromaStore |
cognity-ai[chroma] |
Local persistent | Zero setup; best for dev and small corpora. |
qdrant |
QdrantStore |
cognity-ai[qdrant] |
Local or cloud | Fast, production-ready; named vector support. |
pinecone |
PineconeStore |
cognity-ai[pinecone] |
Cloud-only | Fully managed; serverless tier available. |
faiss |
FAISSStore |
cognity-ai[faiss] |
Local in-memory / disk | Fastest local option. Community search disabled — no metadata store. Use with naive or vector_only retrievers. |
weaviate |
WeaviateStore |
cognity-ai[weaviate] |
Local or cloud | Built-in hybrid BM25 + vector search. |
milvus |
MilvusStore |
cognity-ai[milvus] |
Local or Zilliz cloud | Enterprise scale; GPU index support. |
pgvector |
PgVectorStore |
cognity-ai[pgvector] |
PostgreSQL extension | SQL + vector in one database; uses asyncpg. |
azure_search |
AzureSearchStore |
cognity-ai[azure-search] |
Azure cloud | Azure Cognitive Search; suited for Azure enterprise environments. |
upsert_community and query_communities are no-ops. Pair FAISS with
the naive or vector_only retriever — 4-channel hybrid retrieval is not available.
Graph Stores
Graph stores persist entities, relations, and community structures. All implementations extend BaseGraphStore. Select a provider via the graph_store key.
BaseGraphStore ABC
-
def upsert_entity(self, entity: Entity) -> None abstractInsert or update an entity node. Merges on entity name + type.
-
def upsert_relation(self, relation: Relation) -> None abstractInsert or update a directed relation edge between two entities.
-
def link_chunk_to_entities(self, chunk_id: str, doc_id: str, entity_names: list[str]) -> None abstractCreate
MENTIONED_INedges from entity nodes to a chunk node. Enables the CH4 bridge channel. -
def retrieve_subgraph(self, entity_names: list[str], hops: int = 2, limit: int = 50) -> list[RetrievalResult] abstractTraverse the graph from seed entities up to
hopssteps, returning scored paths as retrieval results. -
def global_community_search(self, top_n: int = 10) -> list[RetrievalResult] abstractReturn the top-N community summaries ranked by size and centrality. Used for broad thematic queries.
-
def detect_communities(self) -> list[dict] abstractRun community detection (Leiden algorithm in Neo4j/GDS). Returns list of community dicts with members and summaries.
-
def confirm_source(self, doc_id: str) -> None abstractMark a document source as confirmed, promoting its entities and relations to full confidence.
-
def deprecate_source(self, doc_id: str) -> None abstractMark a source as deprecated. Associated entities reduce confidence; relations are flagged for pruning.
-
def prune_low_confidence(self, threshold: float) -> int abstractDelete all entities and relations with confidence below
threshold. Returns the count of deleted nodes/edges. -
def health_report(self) -> dict abstractReturn a diagnostic dict with counts of nodes, edges, communities, and store connectivity status.
from abc import ABC, abstractmethod
from cognity_ai.models import Entity, Relation, RetrievalResult
class BaseGraphStore(ABC):
@abstractmethod
def upsert_entity(self, entity: Entity) -> None: ...
@abstractmethod
def upsert_relation(self, relation: Relation) -> None: ...
@abstractmethod
def link_chunk_to_entities(
self, chunk_id: str, doc_id: str, entity_names: list[str]
) -> None: ...
@abstractmethod
def retrieve_subgraph(
self, entity_names: list[str], hops: int = 2, limit: int = 50
) -> list[RetrievalResult]: ...
@abstractmethod
def global_community_search(self, top_n: int = 10) -> list[RetrievalResult]: ...
@abstractmethod
def detect_communities(self) -> list[dict]: ...
@abstractmethod
def confirm_source(self, doc_id: str) -> None: ...
@abstractmethod
def deprecate_source(self, doc_id: str) -> None: ...
@abstractmethod
def prune_low_confidence(self, threshold: float) -> int: ...
@abstractmethod
def health_report(self) -> dict: ...
Graph Store Providers
All providers implement BaseGraphStore. Community detection capability varies by backend.
| Key | Class | Install Extra | Type | Notes |
|---|---|---|---|---|
neo4j DEFAULT |
Neo4jStore |
cognity-ai[neo4j] |
Dedicated graph DB | Full GDS (Leiden communities) and APOC support. Recommended for production. |
microsoft_graphrag |
MicrosoftGraphRAGStore |
cognity-ai[microsoft-graphrag] |
Wraps ms/graphrag | Official Microsoft GraphRAG local and global search. Requires graphrag>=0.3.0. |
memgraph |
MemgraphStore |
cognity-ai[memgraph] |
Open-source graph | Neo4j-compatible Cypher dialect; supports in-memory mode for testing. |
arangodb |
ArangoDBStore |
cognity-ai[arangodb] |
Multi-model graph | AQL queries; graph and document storage in a single database. |
networkx |
NetworkXStore |
cognity-ai[networkx] |
In-memory Python | Zero external dependencies. Community detection disabled. Use for testing and small corpora only. |
NetworkXStore does not support community detection, so the community channel (CH3) and global community search are disabled.
Only 2-channel retrieval (vector + graph subgraph) is available — the CH3 bridge channel is also skipped.
Pair with rag_method="naive" for simplest setup.
Configuration Examples
Pass a store key string for defaults, or construct a LibraryConfig with a provider-specific config object for full control.
# Qdrant — local in-memory (no config needed)
rag = RAGLibrary(vector_store="qdrant")
# Qdrant cloud
from cognity_ai.config import LibraryConfig, QdrantConfig
config = LibraryConfig(
vector_store="qdrant",
qdrant=QdrantConfig(url="https://xyz.qdrant.tech", api_key="..."),
)
# pgvector
from cognity_ai.config import PgVectorConfig
config = LibraryConfig(
vector_store="pgvector",
pgvector=PgVectorConfig(
dsn="postgresql://user:password@localhost:5432/mydb"
),
)
# NetworkX — zero-dependency testing
rag = RAGLibrary(
graph_store="networkx",
rag_method="naive", # no 4-channel retrieval without Neo4j
)
chroma + neo4j) require no extra configuration beyond a running Neo4j instance. Run
docker run -p 7687:7687 neo4j:latest and you are ready.
BaseVectorStore or BaseGraphStore and pass the instance directly to RAGLibrary(vector_store=my_store).
The library accepts both key strings and concrete instances interchangeably.