mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-08-07 02:58:21 +00:00
chore: update return type to Optional[str]
Updated the return type of the methods `get_provider_model_id` and `get_llama_model` in the `ModelRegistryHelper` class to `Optional[str]` to indicate that they may return a string or None when no match is found. This change improves the clarity of the methods' behavior and supports better type safety. Replaced explicit `if-else` checks with `dict.get()` for cleaner code. Signed-off-by: Sébastien Han <seb@redhat.com>
This commit is contained in:
parent
3922999118
commit
787e78d7d4
1 changed files with 4 additions and 10 deletions
|
@ -57,17 +57,11 @@ class ModelRegistryHelper(ModelsProtocolPrivate):
|
||||||
self.alias_to_provider_id_map[alias_obj.llama_model] = alias_obj.provider_model_id
|
self.alias_to_provider_id_map[alias_obj.llama_model] = alias_obj.provider_model_id
|
||||||
self.provider_id_to_llama_model_map[alias_obj.provider_model_id] = alias_obj.llama_model
|
self.provider_id_to_llama_model_map[alias_obj.provider_model_id] = alias_obj.llama_model
|
||||||
|
|
||||||
def get_provider_model_id(self, identifier: str) -> str:
|
def get_provider_model_id(self, identifier: str) -> Optional[str]:
|
||||||
if identifier in self.alias_to_provider_id_map:
|
return self.alias_to_provider_id_map.get(identifier, None)
|
||||||
return self.alias_to_provider_id_map[identifier]
|
|
||||||
else:
|
|
||||||
return None
|
|
||||||
|
|
||||||
def get_llama_model(self, provider_model_id: str) -> str:
|
def get_llama_model(self, provider_model_id: str) -> Optional[str]:
|
||||||
if provider_model_id in self.provider_id_to_llama_model_map:
|
return self.provider_id_to_llama_model_map.get(provider_model_id, None)
|
||||||
return self.provider_id_to_llama_model_map[provider_model_id]
|
|
||||||
else:
|
|
||||||
return None
|
|
||||||
|
|
||||||
async def register_model(self, model: Model) -> Model:
|
async def register_model(self, model: Model) -> Model:
|
||||||
if model.model_type == ModelType.embedding:
|
if model.model_type == ModelType.embedding:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue