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

Add validation for model_name parameter #476

Merged

Conversation

smwitkowski
Copy link
Contributor

This PR introduces a validation check for the model_name parameter within the openai method of the outlines.models module. The aim is to ensure that only valid model names are used when calling this function. As per the current implementation, any string passed as the model_name would be accepted.

The change enforces the function to only accept gpt-4 or gpt-3.5-turbo as valid model names. If any other model name is passed, a ValueError is raised, informing the user about the invalid input and suggesting the correct model names.

This change also adds tests to tests/models/test_openai.py. To ensure an invalid model raises a value error.

Note: I added gpt-4-1106-preview in the tests, so when or if it's added to the suite of models supported by outlines, that will need to be updated, along with the mode in openai.py

@rlouf
Copy link
Member

rlouf commented Dec 22, 2023

Thank you for the contribution! Could you run pre-commit and then squash your commits? Looks good to me otherwise!

@rlouf rlouf force-pushed the 475-validate-openai-model-names branch from 5a4f911 to 5d64c5f Compare December 23, 2023 13:06
@rlouf rlouf force-pushed the 475-validate-openai-model-names branch from 5d64c5f to c0fd9d5 Compare December 23, 2023 13:07
@rlouf
Copy link
Member

rlouf commented Dec 23, 2023

I fixed the code formatting and squashed the commit. Thank you for contirbuting!

@rlouf rlouf merged commit 7355c4b into outlines-dev:main Dec 23, 2023
5 checks passed
benlipkin pushed a commit to benlipkin/outlines that referenced this pull request Jan 5, 2024
This PR introduces a validation check for the `model_name` parameter
within the `openai` method of the `outlines.models` module. The aim is
to ensure that only valid model names are used when calling this
function. As per the current implementation, any string passed as the
`model_name` would be accepted.

The change enforces the function to only accept `gpt-4` or
`gpt-3.5-turbo` as valid model names. If any other model name is passed,
a ValueError is raised, informing the user about the invalid input and
suggesting the correct model names.

This change also adds tests to `tests/models/test_openai.py`. To ensure
an invalid model raises a value error.

Note: I added `gpt-4-1106-preview` in the tests, so when or if it's
added to the suite of models supported by outlines, that will need to be
updated, along with the mode in `openai.py`

Co-authored-by: Stephen Witkowski <stephen.witkowski@proton.me>
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

Successfully merging this pull request may close these issues.

None yet

2 participants