Fix missing end of answer for quotes processor

This commit is contained in:
Weves 2024-06-03 16:31:11 -07:00 committed by Chris Weaver
parent 5a75470d23
commit 3788041115

View File

@ -247,6 +247,17 @@ def process_model_tokens(
if found_answer_start and not found_answer_end:
if is_json_prompt and _stream_json_answer_end(model_previous, token):
found_answer_end = True
# return the remaining part of the answer e.g. token might be 'd.", ' and we should yield 'd.'
if token:
try:
answer_token_section = token.index('"')
yield DanswerAnswerPiece(
answer_piece=hold_quote + token[:answer_token_section]
)
except ValueError:
logger.error("Quotation mark not found in token")
yield DanswerAnswerPiece(answer_piece=hold_quote + token)
yield DanswerAnswerPiece(answer_piece=None)
continue
elif not is_json_prompt: