Skip to content

Commit

Permalink
Fix Invalid Request using AzureOpenAI (langchain-ai#3522)
Browse files Browse the repository at this point in the history
This fixes the error when calling AzureOpenAI of gpt-35-turbo model.

The error is:
InvalidRequestError: logprobs, best_of and echo parameters are not
available on gpt-35-turbo model. Please remove the parameter and try
again. For more details, see
https://go.microsoft.com/fwlink/?linkid=2227346.
  • Loading branch information
howard0su authored Apr 27, 2023
1 parent f5aa767 commit 83e871f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion langchain/llms/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,15 @@ def _default_params(self) -> Dict[str, Any]:
"frequency_penalty": self.frequency_penalty,
"presence_penalty": self.presence_penalty,
"n": self.n,
"best_of": self.best_of,
"request_timeout": self.request_timeout,
"logit_bias": self.logit_bias,
}

# Azure gpt-35-turbo doesn't support best_of
# don't specify best_of if it is 1
if self.best_of > 1:
normal_params["best_of"] = self.best_of

return {**normal_params, **self.model_kwargs}

def _generate(
Expand Down

0 comments on commit 83e871f

Please sign in to comment.