Skip to content

Commit

Permalink
Improve an important error message
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashwin Bharambe committed Oct 20, 2024
1 parent 2089427 commit 8cfbb9d
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion llama_stack/distribution/routers/routing_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,21 @@ async def shutdown(self) -> None:
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:
Expand Down

0 comments on commit 8cfbb9d

Please sign in to comment.