Skip to content

API Reference parrot.registry.routing.store_router

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

parrot.registry.routing.store_router

View source

StoreRouter core orchestrator (FEAT-111 Module 7).

Integrates all sub-modules (cache, rules, ontology, LLM helper) into the end-to-end store-routing decision + execution pipeline.

Usage::

from parrot.registry.routing import StoreRouter, StoreRouterConfig

router = StoreRouter(config)
decision = await router.route("what is an endcap?", [StoreType.PGVECTOR])
results  = await router.execute(decision, query, stores_dict)

Alias AbstractStore

Re-exported from parrot.stores.abstract.AbstractStore.

Alias DEFAULT_STORE_RULES

Re-exported from parrot.registry.routing.rules.DEFAULT_STORE_RULES.

Alias DecisionCache

Re-exported from parrot.registry.routing.cache.DecisionCache.

Alias MultiSearch

Re-exported from parrot.models.MultiSearch.

Class NoSuitableStoreError

Raised by StoreRouter.execute when fallback_policy=RAISE and no store scored above the confidence floor.

Alias OntologyPreAnnotator

Re-exported from parrot.registry.routing.ontology_signal.OntologyPreAnnotator.

Alias StoreFallbackPolicy

Re-exported from parrot.registry.routing.models.StoreFallbackPolicy.

Class StoreRouter

Store-level router activated via AbstractBot.configure_store_router().

Orchestration order within :meth:route:

  1. LRU cache lookup.
  2. Ontology pre-annotation (when enable_ontology_signal=True).
  3. Fast-path rules evaluation.
  4. Margin check → LLM path (when margin is too narrow and invoke_fn is provided).
  5. Confidence floor filtering.
  6. Decision assembly + cache write.

:meth:execute drives retrieval according to the decision's rankings and StoreFallbackPolicy.

Parameter Type Default Description
config StoreRouterConfig Full router configuration.
ontology_resolver Optional[Any] None Optional resolver passed through to :class:~parrot.registry.routing.OntologyPreAnnotator.

Method StoreRouter.route

Produce a :class:StoreRoutingDecision for query.

route(query: str, available_stores: list[StoreType], invoke_fn: Optional[Callable] = None) -> StoreRoutingDecision

Parameter Type Default Description
query str User query string.
available_stores list[StoreType] Stores configured on the calling bot.
invoke_fn Optional[Callable] None Async callable used for the LLM fallback path (usually bot.invoke). None disables the LLM path.

Returns: StoreRoutingDecision — A fully-assembled :class:StoreRoutingDecision.

Method StoreRouter.execute

Execute retrieval according to decision.

execute(decision: StoreRoutingDecision, query: str, stores: dict[StoreType, 'AbstractStore'], multistore_tool: Optional[MultiSearch] = None, **search_kwargs: Any) -> list

Parameter Type Default Description
decision StoreRoutingDecision The routing decision from :meth:route.
query str The user query (forwarded to similarity_search).
stores dict[StoreType, 'AbstractStore'] Dict of available :class:~parrot.stores.abstract.AbstractStore instances keyed by :class:~parrot.models.StoreType.
multistore_tool Optional[MultiSearch] None Optional :class:~parrot.models.MultiSearch-satisfying instance used when fallback_policy=FAN_OUT.
**search_kwargs Any {} Extra keyword arguments forwarded to similarity_search (e.g. limit, score_threshold).

Returns: list — List of results (may be empty). Deduplication is the caller's responsibility.

Alias StoreRouterConfig

Re-exported from parrot.registry.routing.models.StoreRouterConfig.

Alias StoreRoutingDecision

Re-exported from parrot.registry.routing.models.StoreRoutingDecision.

Alias StoreScore

Re-exported from parrot.registry.routing.models.StoreScore.

Alias StoreType

Re-exported from parrot.models.StoreType.

Alias apply_rules

Re-exported from parrot.registry.routing.rules.apply_rules.

Alias build_cache_key

Re-exported from parrot.registry.routing.cache.build_cache_key.

Alias run_llm_ranking

Re-exported from parrot.registry.routing.llm_helper.run_llm_ranking.

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