Closed carlosapd closed 1 year ago
🤖
Hello,
Thank you for bringing this to our attention. The issue you're experiencing is due to the fact that the OpenAI API does not support a negative value for max_tokens
. In the OpenAIChat class, there is a specific check for max_tokens
being -1
and in that case, it removes the max_tokens
parameter from the request. This is because for the ChatGPT API, omitting max_tokens
is equivalent to having no limit on the number of tokens. However, this check is not present in the OpenAI class, which is used for the gpt-3.5-turbo-instruct
model. Therefore, when -1
is passed as max_tokens
, it is sent directly to the OpenAI API, which does not support negative values for max_tokens
, causing a failure.
In addition, the get_sub_prompts
method in the BaseOpenAI
class also checks if max_tokens
is -1
. If it is, and if there are multiple prompts, it raises a ValueError, as -1
is not supported for multiple inputs. If there is only one prompt, it sets max_tokens
to the maximum tokens for the prompt.
I found a similar issue in the LangChain repository: Error when using gpt-3.5-turbo-instruct: model_token_mapping is missing an entry for gpt-3.5-turbo-instruct. This issue was closed by a pull request: misc: add gpt-3.5-turbo-instruct to model_token_mapping. It seems that the gpt-3.5-turbo-instruct
model was not included in the model_token_mapping
dictionary, which maps model names to their respective maximum context sizes. This could be the reason why you're seeing the ValueError: Unknown model: gpt-3.5-turbo-instruct
.
As a workaround, you could try setting max_tokens
to a positive integer instead of -1
. This should allow you to use the gpt-3.5-turbo-instruct
model without encountering this error. However, please note that this will limit the length of the generated output to the number of tokens specified.
We will look into adding a check for max_tokens
being -1
in the OpenAI class and including gpt-3.5-turbo-instruct
in the model_token_mapping
dictionary in a future update. Thank you for your patience and understanding.
Best, Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
If you want to continue the conversation, start your reply with @dosu-bot.
Duplicate of #10806, closing now.
System Info
LangChain version: tested with both versions 0.0.294 and 0.0.295. Python Version: 3.10.10 running on Linux x86_64 (Ubuntu 22.04). Tested with OpenAI library, both versions 0.27.8 and 0.28.0.
Who can help?
@hwchase17 @agola11
Information
Related Components
Reproduction
Run the following snippet:
The following error is returned (just the relevant stack trace):
Originally got this through a
LLMChain
, but tracked it down to the LLM itself.Expected behavior
Should be processing the input correctly. Can confirm this works with other models like
text-davinci-003
.