From ab08cf646543c72e35096094390a4a676fd5af72 Mon Sep 17 00:00:00 2001 From: matatonic <73265741+matatonic@users.noreply.github.com> Date: Sun, 14 May 2023 11:57:52 -0400 Subject: [PATCH] [extensions/openai] clip extra leading space (#2042) --- extensions/openai/script.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/extensions/openai/script.py b/extensions/openai/script.py index 95fe181c..712cfe38 100644 --- a/extensions/openai/script.py +++ b/extensions/openai/script.py @@ -520,6 +520,10 @@ class Handler(BaseHTTPRequestHandler): for a in generator: answer = a + # some reply's have an extra leading space to fit the instruction template, just clip it off from the reply. + if edit_task[-1] != '\n' and answer and answer[0] == ' ': + answer = answer[1:] + completion_token_count = len(encode(answer)[0]) resp = {