Repository: meta-llama/llama-stack
File: llama_stack/core/routers/__init__.py (Python)

Code before:
    return impl


async def get_auto_router_impl(
    api: Api, routing_table: RoutingTable, deps: dict[str, Any], run_config: StackRunConfig, policy: list[AccessRule]
) -> Any:
    from .datasets import DatasetIORouter
    from .eval_scoring import EvalRouter, ScoringRouter
    from .inference import InferenceRouter
    from .safety import SafetyRouter
    from .tool_runtime import ToolRuntimeRouter
    from .vector_io import VectorIORouter

    api_to_routers = {
        "vector_io": VectorIORouter,
        "inference": InferenceRouter,
        "safety": SafetyRouter,
        "datasetio": DatasetIORouter,
        "scoring": ScoringRouter,
        "eval": EvalRouter,
        "tool_runtime": ToolRuntimeRouter,
    }
    if api.value not in api_to_routers:
        raise ValueError(f"API {api.value} not found in router map")

    if run_config.telemetry and run_config.telemetry.enabled:
        api_to_deps = {
            "inference": {"telemetry": Api.telemetry},
        }
        api_to_dep_impl = {}
        for dep_name, dep_api in api_to_deps.get(api.value, {}).items():
            if dep_api in deps:
                api_to_dep_impl[dep_name] = deps[dep_api]

    api_to_dep_impl = {}
    # TODO: move pass configs to routers instead
    if api == Api.inference and run_config.inference_store:
        inference_store = InferenceStore(
            config=run_config.inference_store,
            policy=policy,
        )
        await inference_store.initialize()
        api_to_dep_impl["store"] = inference_store

    impl = api_to_routers[api.value](routing_table, **api_to_dep_impl)
    await impl.initialize()
    return impl


Review comment (suggestion):
can remove with a default config.telemetry
```suggestion
    if run_config.telemetry.enabled:
```

Code after:
    return impl


async def get_auto_router_impl(
    api: Api, routing_table: RoutingTable, deps: dict[str, Any], run_config: StackRunConfig, policy: list[AccessRule]
) -> Any:
    from .datasets import DatasetIORouter
    from .eval_scoring import EvalRouter, ScoringRouter
    from .inference import InferenceRouter
    from .safety import SafetyRouter
    from .tool_runtime import ToolRuntimeRouter
    from .vector_io import VectorIORouter

    api_to_routers = {
        "vector_io": VectorIORouter,
        "inference": InferenceRouter,
        "safety": SafetyRouter,
        "datasetio": DatasetIORouter,
        "scoring": ScoringRouter,
        "eval": EvalRouter,
        "tool_runtime": ToolRuntimeRouter,
    }
    if api.value not in api_to_routers:
        raise ValueError(f"API {api.value} not found in router map")

    api_to_dep_impl = {}
    if run_config.telemetry.enabled:
        api_to_deps = {
            "inference": {"telemetry": Api.telemetry},
        }
        for dep_name, dep_api in api_to_deps.get(api.value, {}).items():
            if dep_api in deps:
                api_to_dep_impl[dep_name] = deps[dep_api]

    # TODO: move pass configs to routers instead
    if api == Api.inference and run_config.inference_store:
        inference_store = InferenceStore(
            config=run_config.inference_store,
            policy=policy,
        )
        await inference_store.initialize()
        api_to_dep_impl["store"] = inference_store

    impl = api_to_routers[api.value](routing_table, **api_to_dep_impl)
    await impl.initialize()
    return impl