From 8cfbb9d38b80ca5930e8ba20756cdaa51af30ca0 Mon Sep 17 00:00:00 2001 From: Ashwin Bharambe Date: Sat, 19 Oct 2024 17:19:54 -0700 Subject: [PATCH] Improve an important error message --- .../distribution/routers/routing_tables.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/llama_stack/distribution/routers/routing_tables.py b/llama_stack/distribution/routers/routing_tables.py index ede30aea1..597dbed07 100644 --- a/llama_stack/distribution/routers/routing_tables.py +++ b/llama_stack/distribution/routers/routing_tables.py @@ -87,8 +87,21 @@ class CommonRoutingTableImpl(RoutingTable): def get_provider_impl( self, routing_key: str, provider_id: Optional[str] = None ) -> Any: + def apiname_object(): + if isinstance(self, ModelsRoutingTable): + return ("Inference", "model") + elif isinstance(self, ShieldsRoutingTable): + return ("Safety", "shield") + elif isinstance(self, MemoryBanksRoutingTable): + return ("Memory", "memory_bank") + else: + raise ValueError("Unknown routing table type") + if routing_key not in self.registry: - raise ValueError(f"`{routing_key}` not registered") + apiname, objname = apiname_object() + raise ValueError( + f"`{routing_key}` not registered. Make sure there is an {apiname} provider serving this {objname}." + ) objs = self.registry[routing_key] for obj in objs: