[extensions/openai] clip extra leading space (#2042)

This commit is contained in:
matatonic 2023-05-14 11:57:52 -04:00 committed by GitHub
parent 3b886f9c9f
commit ab08cf6465
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: 4AEE18F83AFDEB23

View file

@ -520,6 +520,10 @@ class Handler(BaseHTTPRequestHandler):
for a in generator: for a in generator:
answer = a 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]) completion_token_count = len(encode(answer)[0])
resp = { resp = {