How can I remove the "\\n\\n" from OpenAI API answer?

I’m making a call to OpenAI API but the answer comes with this format: “\n\n”.
How can I make it plain-text?

You shouldn’t have to ?

You can watch this video : https://youtu.be/a4pwESPhQbQ
he solved this problem.

What do you mean?

I tried what he did <split by ()> but it didn’t work.

Something wrong with your JSON. Basically, it shouldn’t come like that.

Interesting. Do you see something wrong in the API call?

Seem like it’s not Open AI. URL is totally different.
Use REGEX to remove
regex code: /\r?\n|\r/g

That’s a normal response from openai. The browser should automatically handle \n

Yes but not sure why it looks like this in the browser:

My mistake, it’s openai through flowise. I tried the regex code but didn’t work. Thanks anyway!

can you paste here your text? I’ll run over in regex validator

Of course, so an example of the text-response I’m getting is:

":point_right:t3: Copies para Facebook Ads:\n\n

:white_check_mark: Ad numero 1:\n\n→ Texto principal: ¡Prueba nuestras deliciosas barras de cereal veganas! :seedling:\n\n→ Titular: Energía saludable en cada bocado :star2:\n\n​:white_check_mark: Ad numero 2:\n\n→ Texto principal: ¿Buscas un snack saludable y delicioso? Prueba nuestras barras de cereal veganas :herb:\n\n→ Titular: Sabor natural y nutritivo en cada mordisco :seedling:\n\n​:white_check_mark: Ad numero 3:\n\n→ Texto principal: Descubre el sabor y la energía de nuestras barras de cereal veganas :star2:\n\n→ Titular: Alimenta tu cuerpo de forma saludable con nuestras barras de cereal veganas :herb:"

I’ll ask what I’m guessing is a stupid question because I’m sure I am missing something… can’t you use the :find & replace operator to find \n\n and replace it with nothing?

2 Likes

Check:

1 Like

Thanks, it worked to replace the “/n” but the problem is still there cause “/n” means “new paragraph”. I have all in the same line and the UI is not nice. I’ll keep researching and see if I can solve it.

Instead of replacing by nothing, replace it by newline (click enter in replace by)

6 Likes

Thanks, this fixed the issue