Skip to content
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

Linebreaks #63

Closed
An0therAnon opened this issue Mar 21, 2023 · 6 comments
Closed

Linebreaks #63

An0therAnon opened this issue Mar 21, 2023 · 6 comments

Comments

@An0therAnon
Copy link

For some reason agnai doesn't receive line breaks, its quite annoying when using a RPG bot with stats which are all clogged in a sole paragraph. Even with other bots, when looking at the original result in scale, it haves line breaks, but in the UI it doesn't.

@sceuick
Copy link
Member

sceuick commented Mar 22, 2023

This might be due to the "end tokens" that Agnai looks for in a response because it expects it to be conversational in nature.
Specifically, Agnai looks for \n\n which might be causing your issue.

I'm intending to support other modes such as adventure, story, and companion modes.
Your use case might fall in to that.

@giubil
Copy link

giubil commented Mar 22, 2023

@sceuick I took a look at the issue of the linebreaks disappearing in a message, and I think I found the the problem.

It's coming from the sanitise() function in srv/api/chat/common.ts :
https://github.com/luminai-companion/agn-ai/blob/760260e990efdd82431dcbdcf45f82ad0cf02587/srv/api/chat/common.ts#L99

In regex, \s+ will match all whitespaces, including line breaks. To exclude linebreaks from the match, you need to use this regex : /[^\S\r\n]/g (which also excludes Windows carriages returns for good measures)

I've tested it locally, and indeed, when replacing the regex with the updated one, we see line breaks in the received message :

CleanShot 2023-03-22 at 20 18 23

I haven't done any more testing than this, so I have no idea if it breaks something somewhere else, but thought I would share anyways.

@sceuick
Copy link
Member

sceuick commented Mar 23, 2023

Thanks for digging into this for me. I'll do some testing with your regex.

@An0therAnon
Copy link
Author

An0therAnon commented Mar 23, 2023

Welp, it there is another issue which wasn't in the site before; ill post it here since its quite similar and maybe it haves a relation: when a message have a double linebreak it will cut the message at that, doesn't receive the full message.

@sceuick
Copy link
Member

sceuick commented Mar 23, 2023

Literally just deployed a change that removed the \n\n end token. 🤞

@An0therAnon
Copy link
Author

Just tested, everything in order. Good shit man, hope you can keep the good work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants