Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[model] add model validation #32

Closed
signebedi opened this issue Mar 28, 2023 · 0 comments
Closed

[model] add model validation #32

signebedi opened this issue Mar 28, 2023 · 0 comments

Comments

@signebedi
Copy link
Owner

We should validate that the model passed is an actual model.

def get_available_models():
    response = openai.Model.list()
    return [model.id for model in response['data']]

def is_valid_model(model_name):
    available_models = get_available_models()
    return model_name in available_models

def validate_model_type(model_name):
    if ('davinci' in model_name or 'curie' in model_name) and is_valid_model(model_name):
        return 'completion'
    elif 'gpt' in model_name and is_valid_model(model_name):
        return 'chat completion'
    else:
        raise Exception()

....


    # Set the parameters for the OpenAI completion API
    model_engine = configs['model'].rstrip('\n')

    try:
        model_type = validate_model_type(model_engine)
    except:
        click.echo(f"{RED}FAILED to validate the model name '{model_engine}'. Are you sure this is a valid OpenAI model? Check the available models at <https://platform.openai.com/docs/models/overview> and try again.{RESET}")
        return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant