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

fix: check for latest OpenAI model names #6027

Closed

Conversation

ArzelaAscoIi
Copy link
Member

Related Issues

  • TBD

Proposed Changes:

How did you test it?

  • not tested yet

Checklist

@ArzelaAscoIi ArzelaAscoIi requested a review from a team as a code owner October 11, 2023 12:09
@ArzelaAscoIi ArzelaAscoIi requested review from julian-risch and removed request for a team October 11, 2023 12:09
@ArzelaAscoIi ArzelaAscoIi marked this pull request as draft October 11, 2023 12:09
@@ -270,7 +272,7 @@ def _ensure_token_limit(self, prompt: Union[str, List[Dict[str, str]]]) -> Union

@classmethod
def supports(cls, model_name_or_path: str, **kwargs) -> bool:
valid_model = model_name_or_path in ["ada", "babbage", "davinci", "curie", "gpt-3.5-turbo-instruct"] or any(
valid_model = model_name_or_path in OPEN_AI_MODEL_NAMES or any(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work for the snapshot models (e.g. gpt-3.5-turbo-0613)?

Copy link
Member Author

@ArzelaAscoIi ArzelaAscoIi Oct 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. :/ I just added the one that was missing for us. Basically we need to come up with a rule to match all OpenAI models or somehow with a hard coded rule or implement some kind of dynamic validation by e.g. fetching all available models and check if the chosen one is one of them.

Happy to add extra model names

@anakin87
Copy link
Member

Hello!

A general note.
Currently, in Haystack, OpenAI models are supported using two different invocation layers:

  • OpenAI for old GPT-3 models and gpt-3.5-turbo-instruct
  • ChatGPT for gpt-3.5-turbo and gpt-4 families of models

Check out the two different supports methods:

def supports(cls, model_name_or_path: str, **kwargs) -> bool:
valid_model = model_name_or_path in ["ada", "babbage", "davinci", "curie", "gpt-3.5-turbo-instruct"] or any(
m in model_name_or_path for m in ["-ada-", "-babbage-", "-davinci-", "-curie-"]
)
return valid_model and not has_azure_parameters(**kwargs)

def supports(cls, model_name_or_path: str, **kwargs) -> bool:
valid_model = (
any(m for m in ["gpt-3.5-turbo", "gpt-4"] if m in model_name_or_path)
and not "gpt-3.5-turbo-instruct" in model_name_or_path
)
return valid_model and not has_azure_parameters(**kwargs)

My impression is that these last models are supported by the ChatGPT layer.

@@ -20,6 +20,8 @@

logger = logging.getLogger(__name__)

OPEN_AI_MODEL_NAMES = ["ada", "babbage", "davinci", "curie", "gpt-3.5-turbo-instruct", "gpt-3.5-turbo", "gpt-4"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about making this configurable via env variables?

@masci masci self-assigned this Oct 11, 2023
@ArzelaAscoIi
Copy link
Member Author

Okay! Makes sense. We will add an extra step to validate also the ChatGPT invocation layer. Thanks for you help!

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.

5 participants