Fix for versioned OpenAI instruct models (#10788)

Versioned OpenAI instruct models may end with numbers, e.g.
`gpt-3.5-turbo-instruct-0914`.

Fixes https://github.com/langchain-ai/langchainjs/issues/2669 in Python
This commit is contained in:
Jacob Lee 2023-09-19 15:50:06 -07:00 committed by GitHub
parent 73afd72e1d
commit 61cecf8b1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -198,7 +198,7 @@ class BaseOpenAI(BaseLLM):
model_name = data.get("model_name", "") model_name = data.get("model_name", "")
if ( if (
model_name.startswith("gpt-3.5-turbo") or model_name.startswith("gpt-4") model_name.startswith("gpt-3.5-turbo") or model_name.startswith("gpt-4")
) and not model_name.endswith("-instruct"): ) and "-instruct" not in model_name:
warnings.warn( warnings.warn(
"You are trying to use a chat model. This way of initializing it is " "You are trying to use a chat model. This way of initializing it is "
"no longer supported. Instead, please use: " "no longer supported. Instead, please use: "