lhenault/simpleAI

Raise error rather than default fallback for model selection

Nintorac opened this issue · 1 comments

In the following code a ValueError or something should be raised if no value have been matched rather than silent fallback to completion model.

As well, since select_model_type is only ever called by get_model it is impossible for the default kwarg to ever be used, perhaps worth removing

def select_model_type(model_interface: str='gRPC', task: str='complete'):
    if model_interface == 'gRPC':
        if task == 'embed':
            return RpcEmbeddingLanguageModel
        return RpcCompletionLanguageModel
    return RpcCompletionLanguageModel

    
def get_model(model_id: str, metadata: dict=MODELS_ZOO, task: str='complete'):
    if model_id in metadata.keys():
        model_interface = metadata.get(model_id).get('network', dict())
        model_url = model_interface.get('url', None)
        model_interface = model_interface.get('type', None)
        return select_model_type(model_interface, task)(name=model_id, url=model_url)
    else:
        return None

refer #3 for further discussion around this. that fix is no longer included in any branch

Forgot to close it but been addressed in #32