Skip to content

Build Router

Shared helpers for building routers from RouterConfig instances.

build_domain_specific_router(router_config)

Build a domain-specific router from a RouterConfig instance.

The router's valid routes are the route_mapping keys, and it falls back to the general_image route.

Parameters:

Name Type Description Default
router_config RouterConfig

Router configuration.

required

Returns:

Name Type Description
LMBasedRouter 'LMBasedRouter'

The constructed router instance.

Raises:

Type Description
ComponentConfigError

If route_mapping does not include the general_image route.

build_multimodal_router(router_config)

Build a multimodal router from a RouterConfig instance.

If both es_url and es_index_name are provided, an Elasticsearch vector data store is attached to the router.

Parameters:

Name Type Description Default
router_config RouterConfig

Router configuration.

required

Returns:

Name Type Description
AurelioSemanticRouter 'AurelioSemanticRouter'

The constructed router instance.

Raises:

Type Description
ComponentConfigError

If the model ID, the model parameters, the Elasticsearch options, or the embedding model options are invalid.

MediaBackendUnavailableError

If the Elasticsearch server cannot be reached while the router is built.

CoreImportError

If gllm-datastore, the embedding SDK, or the Elasticsearch client is not installed.

build_router(router_config)

Build a router from a RouterConfig instance.

Parameters:

Name Type Description Default
router_config RouterConfig

Router configuration.

required

Returns:

Name Type Description
BaseRouter 'BaseRouter'

The constructed router instance.

Raises:

Type Description
ComponentConfigError

If router_config is not a RouterConfig, its modality is not image, or its preset is not supported. Also raised for the errors of the preset's builder.

CoreImportError

If gllm-pipeline is not installed.