From 7315360907b7c2fa88d7803b5778599f2e37277d Mon Sep 17 00:00:00 2001 From: Erick Friis Date: Tue, 3 Dec 2024 09:54:53 -0800 Subject: [PATCH] openai: dont populate logit_bias if None (#28482) --- libs/partners/openai/langchain_openai/llms/base.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/partners/openai/langchain_openai/llms/base.py b/libs/partners/openai/langchain_openai/llms/base.py index dc5dd67099b..b910f2e404d 100644 --- a/libs/partners/openai/langchain_openai/llms/base.py +++ b/libs/partners/openai/langchain_openai/llms/base.py @@ -205,11 +205,13 @@ class BaseOpenAI(BaseLLM): "frequency_penalty": self.frequency_penalty, "presence_penalty": self.presence_penalty, "n": self.n, - "logit_bias": self.logit_bias, "seed": self.seed, "logprobs": self.logprobs, } + if self.logit_bias is not None: + normal_params["logit_bias"] = self.logit_bias + if self.max_tokens is not None: normal_params["max_tokens"] = self.max_tokens