Skip to content

API Reference parrot.stores.abstract

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.stores.abstract

View source

Class AbstractStore

AbstractStore class.

Base class for all Database Vector Stores.

Args: embeddings (str): Embedding name.

Parameter Type Default Description
embedding_model Union[dict, str] None
embedding Union[dict, Callable] None
**kwargs {}

Attributes:

Attribute Type Description
client Callable
vector Callable
embedding_model Union[dict, str, None]
collection_name str
dimension int
database str
contextual_embedding bool
contextual_template ContextualTemplate
contextual_max_header_tokens int
connected bool

Method AbstractStore.is_connected

is_connected()

Method AbstractStore.connection

connection() -> tuple

Returns: tuple

Method AbstractStore.get_connection

get_connection() -> Any

Returns: Any

Method AbstractStore.engine

engine()

Method AbstractStore.disconnect

disconnect() -> None

Method AbstractStore.get_vector

get_vector(metric_type: str = None, **kwargs)

Parameter Type Default Description
metric_type str None
**kwargs {}

Method AbstractStore.get_vectorstore

get_vectorstore()

Method AbstractStore.similarity_search

Perform a vector similarity search.

By default, parent rows (is_full_document=True or document_type='parent'/'parent_chunk') are excluded from the candidate set so they never compete with child chunks on score. Legacy chunks that have no marker at all ARE included (backward compatibility for collections ingested before FEAT-128).

similarity_search(query: str, collection: Union[str, None] = None, limit: int = 2, similarity_threshold: float = 0.0, search_strategy: str = 'auto', metadata_filters: Union[dict, None] = None, include_parents: bool = False, **kwargs) -> list

Parameter Type Default Description
query str
collection Union[str, None] None
limit int 2
similarity_threshold float 0.0
search_strategy str 'auto'
metadata_filters Union[dict, None] None
include_parents bool False When True, the parent-exclusion filter is bypassed and all rows — including parents — are returned. Use this for internal tooling that needs the old behaviour, or for explicitly fetching parent documents.
**kwargs {}

Returns: list — List of search result objects.

Method AbstractStore.from_documents

Create Vector Store from Documents.

from_documents(documents: List[Any], collection: Union[str, None] = None, **kwargs) -> Callable

Parameter Type Default Description
documents List[Any] List of Documents.
collection Union[str, None] None Collection Name.
**kwargs {} Additional Arguments.

Returns: Callable — Callable VectorStore.

Method AbstractStore.create_collection

Create Collection in Vector Store.

create_collection(collection: str) -> None

Parameter Type Default Description
collection str Collection Name.

Returns: None — None.

Method AbstractStore.add_documents

Add Documents to Vector Store.

add_documents(documents: List[Any], collection: Union[str, None] = None, **kwargs) -> None

Parameter Type Default Description
documents List[Any] List of Documents.
collection Union[str, None] None Collection Name.
**kwargs {} Additional Arguments.

Returns: None — None.

Method AbstractStore.create_embedding

Create Embedding Model (via EmbeddingRegistry for deduplication).

Returns a cached model instance when possible so that multiple stores using the same model share a single object (saves GPU/CPU memory).

create_embedding(embedding_model: dict, **kwargs)

Parameter Type Default Description
embedding_model dict Embedding Model Configuration with optional keys model_type (default "huggingface") and model_name (default EMBEDDING_DEFAULT_MODEL).
**kwargs {} Additional Arguments forwarded to the model constructor on first load.

Method AbstractStore.get_default_embedding

Return the default embedding model via the registry.

get_default_embedding()

Method AbstractStore.generate_embedding

generate_embedding(documents: List[Any]) -> List[Any]

Parameter Type Default Description
documents List[Any]

Returns: List[Any]

Method AbstractStore.prepare_embedding_table

Prepare a Table as an embedding table with advanced features. This method prepares a table with the following columns:

  • id: unique identifier (String)
  • embedding: the vector column (Vector(dimension) or JSONB)
  • document: text column containing the document
  • collection_id: UUID column for collection identification.
  • metadata: JSONB column for metadata
  • Additional columns based on the provided columns list
  • Enhanced indexing strategies for efficient querying
  • Support for multiple distance strategies (COSINE, L2, IP, etc.) Args:
  • tablename (str): Name of the table to create.
  • embedding_column (str): Name of the column for storing embeddings.
  • document_column (str): Name of the column for storing document text.
  • metadata_column (str): Name of the column for storing metadata.
  • dimension (int): Dimension of the embedding vector.
  • id_column (str): Name of the column for storing unique identifiers.
  • use_jsonb (bool): Whether to use JSONB for metadata storage.
  • drop_columns (bool): Whether to drop existing columns.
  • create_all_indexes (bool): Whether to create all distance strategies.

prepare_embedding_table(tablename: str, conn: Any = None, embedding_column: str = 'embedding', document_column: str = 'document', metadata_column: str = 'cmetadata', dimension: int = None, id_column: str = 'id', use_jsonb: bool = True, drop_columns: bool = False, create_all_indexes: bool = True, **kwargs)

Parameter Type Default Description
tablename str
conn Any None
embedding_column str 'embedding'
document_column str 'document'
metadata_column str 'cmetadata'
dimension int None
id_column str 'id'
use_jsonb bool True
drop_columns bool False
create_all_indexes bool True
**kwargs {}

Method AbstractStore.delete_documents

Delete Documents from the Vector Store. Args: documents (Optional[Any]): Documents to delete. pk (str): Primary key field. values (Optional[Union[str, List[str]]]): Values to match for deletion. table (Optional[str]): Table name. schema (Optional[str]): Schema name. collection (Optional[str]): Collection name. kwargs: Additional arguments. Returns: int: Number of deleted documents.

delete_documents(documents: Optional[Any] = None, pk: str = 'source_type', values: Optional[Union[str, List[str]]] = None, table: Optional[str] = None, schema: Optional[str] = None, collection: Optional[str] = None, **kwargs) -> int

Parameter Type Default Description
documents Optional[Any] None
pk str 'source_type'
values Optional[Union[str, List[str]]] None
table Optional[str] None
schema Optional[str] None
collection Optional[str] None
**kwargs {}

Returns: int

Method AbstractStore.delete_documents_by_filter

Delete Documents by filter. Args: search_filter (Dict[str, Union[str, List[str]]]): Filter criteria. table (Optional[str]): Table name. schema (Optional[str]): Schema name. collection (Optional[str]): Collection name. kwargs: Additional arguments. Returns: int: Number of deleted documents.

delete_documents_by_filter(search_filter: Dict[str, Union[str, List[str]]], table: Optional[str] = None, schema: Optional[str] = None, collection: Optional[str] = None, **kwargs) -> int

Parameter Type Default Description
search_filter Dict[str, Union[str, List[str]]]
table Optional[str] None
schema Optional[str] None
collection Optional[str] None
**kwargs {}

Returns: int

Alias ConfigError

Re-exported from parrot.exceptions.ConfigError.

Alias ContextualTemplate

Re-exported from parrot.stores.utils.contextual.ContextualTemplate.

Alias DEFAULT_MAX_HEADER_TOKENS

Re-exported from parrot.stores.utils.contextual.DEFAULT_MAX_HEADER_TOKENS.

Alias DEFAULT_TEMPLATE

Re-exported from parrot.stores.utils.contextual.DEFAULT_TEMPLATE.

Alias EMBEDDING_DEFAULT_MODEL

Re-exported from parrot.conf.EMBEDDING_DEFAULT_MODEL.

Alias build_contextual_text

Re-exported from parrot.stores.utils.contextual.build_contextual_text.

Alias supported_embeddings

Re-exported from parrot.embeddings.supported_embeddings.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally