From 52f7c469228ebf4a0903dcf38143182a5399af88 Mon Sep 17 00:00:00 2001 From: Liren Tu Date: Tue, 18 Apr 2023 23:10:40 -0700 Subject: [PATCH 1/2] Check empty string --- openai/validators.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openai/validators.py b/openai/validators.py index 078179a44b..8237bce731 100644 --- a/openai/validators.py +++ b/openai/validators.py @@ -423,7 +423,7 @@ def completions_space_start_validator(df): def add_space_start(x): x["completion"] = x["completion"].apply( - lambda x: ("" if x[0] == " " else " ") + x + lambda x: ("" if x == "" or x[0] == " " else " ") + x ) return x From 27fc715436ee4cdd52a782408bd7a8d85d0175f6 Mon Sep 17 00:00:00 2001 From: Liren Tu Date: Tue, 11 Jul 2023 20:43:22 -0700 Subject: [PATCH 2/2] Use startswith --- openai/validators.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openai/validators.py b/openai/validators.py index 8237bce731..b7f6364084 100644 --- a/openai/validators.py +++ b/openai/validators.py @@ -423,7 +423,7 @@ def completions_space_start_validator(df): def add_space_start(x): x["completion"] = x["completion"].apply( - lambda x: ("" if x == "" or x[0] == " " else " ") + x + lambda s: ("" if s.startswith(" ") else " ") + s ) return x