From c006dffa656a35cfad98cfbaf89680a53f4f47fc Mon Sep 17 00:00:00 2001 From: Sam Baumann Date: Mon, 13 Apr 2026 22:36:33 -0400 Subject: [PATCH] Fix stop parameter check to allow explicit None value Previously, `not self.generator_kwargs.get("stop")` would overwrite a user-supplied `stop=None` (which disables the stop sequence). Use `"stop" not in` to only set the default when the key is absent. --- bertopic/representation/_openai.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bertopic/representation/_openai.py b/bertopic/representation/_openai.py index 71eb8c9a..ad47c066 100644 --- a/bertopic/representation/_openai.py +++ b/bertopic/representation/_openai.py @@ -176,7 +176,7 @@ def __init__( del self.generator_kwargs["model"] if self.generator_kwargs.get("prompt"): del self.generator_kwargs["prompt"] - if not self.generator_kwargs.get("stop"): + if "stop" not in self.generator_kwargs: self.generator_kwargs["stop"] = "\n" def extract_topics(