AIStoryWriter icon indicating copy to clipboard operation
AIStoryWriter copied to clipboard

[BUG] Incorrect detection of generation failure leads to infinite loop

Open timmaclean opened this issue 1 year ago • 1 comments

I was encountering an infinite loop of empty AI responses halfway through the generation process, seemingly at random.

While debugging, I identified that the code to handle a generation failure ( Writer/Interface/Wrapper.py:388 ) does not correctly handle a message with no content, resulting in an infinite loop of empty response generation. Using a breakpoint to add spaces before the test, the infinite loop was broken.

(I assume my specific configuration resulted in generation failures with no white-space, while this was tested with a configuration that did generate white-space even when it failed)

if _Messages[-1]["content"].isspace():

I recommend the line be changed to the following:

if _Messages[-1]["content"].trim() == "":

timmaclean avatar Oct 27 '24 01:10 timmaclean

Thank you! Would you mind making that into a PR? I'd be happy to merge it!

datacrystals avatar Oct 29 '24 05:10 datacrystals