Removing '\n\n' from generated OpenAI text before added

Hello,

Everything is working smoothly, but I can’t stop my generated text from being added to my multiline with two returns (\n\n) above it.

Example returned:

“text”: “n\n\novel is no easy feat. It takes dedication, hard work, and a lot of creative energy. But with the right approach,”

How it appears in multiline:

Writing a best-selling

novel is no easy feat. It takes dedication, hard work, and a lot of creative energy. But with the right approach,

Can anyone offer any advice?

Stuart

Just put \n\n after the prompt and it goes away.

1 Like

You can also add a find&replace function - find (press enter twice in the first box) and replace (enter nothing in the second box),

Of course this will delete all instances of 2 empty lines, so if you WANT 2 empty lines elsewhere, probably not the best solution. @NigelG’s is probably a smarter way to go.

2 Likes

You could use a Regex to remove the first \n\n of you needed to.

It does try very hard to format things nicely for you but I do wonder if mentioning you don’t want it all formatted might do the trick.

I have been playing with asking it to format lists of things with various things, and it is happy to do so.

Perfect! Thank you @heythere.

I tried your advice too, @NigelG. The regex was a great idea but it only works for lists apparently. The \n\n at the end of a prompt only seemed to remove one return.

Thanks again!

Yes, that removes the double space at the start of the response.

You can remove the \n s with a find and replace

Note there will also be ’ and " in there too.

I’m new to Bubble (I usually work in Python) and as much as I love it I stumble a lot.

For example, thanks to you both (@NigelG @heythere ) I learned something new and I removed the spaces/returns AND it worked as I had hoped.

I close my laptop, put the kids to bed, and reopen everything… now the generated text is doing something odd.

Example:

Input A: The sun rose

Click button to generate text which is saved and appended with Input A.

Generated text: above the clouds. The sun rose above the clouds.

I honestly don’t know why. I haven’t made any changes.

I think something weird may be happening with OpenAI. My app was generating beautiful chunks of language based on long reference passages a few days ago (basically summarizing the ref. language), and all the sudden started having problems and would only work with short reference passages. I haven’t experienced your specific issue, but my suspicion is it’s not a Bubble issue…

Might see if other ppl are seeing the same issue in their forums: https://community.openai.com/

Hi @NigelG e @heythere . Thanks for the tips.

I’m trying to use regex to remove the two empty lines of open AI with the expression: /^\s*[\r\n]/gm.

I was able to remove the empty lines and the n/n in the text element with find and replace. But when I send this result for a multiline input to keep editing, the regex expression /^\s*[\r\n]/gm isn’t work. Am I doing something wrong?

Thanks!

I always use :trimmed

Never not worked for me. Don’t see why it would throw any errors in the example you provided

my understanding is that the regex is executed only with the global flag, not the multiline. Try to create your regex with that in mind.
Also, if your regex is /asdf/ in the editor you need to input asdf.