Skip to content

API Reference parrot.rerankers.factory

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

parrot.rerankers.factory

View source

Factory for creating AbstractReranker instances from a config dict.

This module resolves a JSONB reranker_config dict (as stored in navigator.ai_bots) into a concrete AbstractReranker instance. An empty dict means "no reranker" and returns None. Unknown type values raise ConfigError immediately (fail-loud, per FEAT-133 G5).

Lazy imports keep this module cheap to import — transformers / torch are never loaded unless type=local_cross_encoder is actually requested.

Usage::

from parrot.rerankers.factory import create_reranker

reranker = create_reranker({"type": "local_cross_encoder",
                            "model_name": "cross-encoder/ms-marco-MiniLM-L-6-v2",
                            "device": "cpu"})

Alias AbstractClient

Re-exported from parrot.clients.abstract_client.AbstractClient.

Alias AbstractReranker

Re-exported from parrot.rerankers.abstract.AbstractReranker.

Alias ConfigError

Re-exported from parrot.exceptions.ConfigError.

Attribute RERANKER_TYPES

Type: dict[str, Callable[[dict, Optional['AbstractClient']], AbstractReranker]]

Function create_reranker

Instantiate a reranker from a config dict.

create_reranker(config: dict, *, bot_llm_client: Optional['AbstractClient'] = None) -> Optional[AbstractReranker]

Parameter Type Default Description
config dict Reranker config (typically loaded from navigator.ai_bots.reranker_config). An empty dict means "no reranker" and returns None.
bot_llm_client Optional['AbstractClient'] None Reused for type=llm when client_ref="bot" (avoids a second LLM client instantiation).

Returns: Optional[AbstractReranker] — The reranker instance, or None if config is empty.

Raises:

  • ConfigError — If config['type'] is missing or unknown, or if a required dependency (e.g. LLM client) is absent.

Attribute logger

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