-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix single newlines #6599
Fix single newlines #6599
Conversation
Merge dev branch
Merge dev branch
Merge dev branch
Merge dev branch
…newline for normal text
I tried this fix. It works on the user's replies but still exhibits the same issue in the assistant replies. Edit: Hmm... Sometimes the user's replies do not work either. I can't find definitive pattern for this behavior yet. |
The commit that introduced problems was 3d19746, so I have reverted things (in this PR) to be as close as possible to before that commit. The idea of this But the lists behavior was and still is wrong. Examples of lists that cause issues:
Here is another one:
|
Now the lists above work, but
doesn't, unless I add back |
This may be unfixable without a dirty hack to enforce 4 spaces indentation for every nested list generated by an LLM. See: Python-Markdown/markdown#3 (comment) I'll merge this PR because it fixes the issues above. If someone can see a better solution, please send a new PR! |
Thanks for the example, that makes sense. So after this PR, the change would be this one? # Don't add an extra \n for code, LaTeX, or tables
if is_code or is_latex or line.startswith('|'):
result += '\n'
# Also don't add an extra \n for lists
elif stripped_line.startswith('-') or stripped_line.startswith('*') or stripped_line.startswith('+') or stripped_line.startswith('>') or re.match(r'\d+\.', stripped_line):
result += '\n'
else:
- result += '\n\n'
+ result += ' \n' It seems like that would break this case (2 long paragraphs separated by a
|
That's fair, I wrote that |
The aim of this PR is to allow single newlines to be used both by the LLM and the user and thus fix issue #6597.
The following is an example showing the effect of the change made:
Before:
After:
@oobabooga I had a difficult time figuring out the purpose of
previous_line_empty
. Is there any particular kind of output that relies on it?