Remove markdown/formatting from chatGPT API

hello folks!

Just trying the newly released chatGPT API. Everything seems alright so far but I am unable to get the desired responses basically:

Model responses are being generated with the markdown/formatting like as shown in the example below:

Sure, here’s a simple recipe to make paratha:\n\nIngredients:\n- 2 cups whole wheat flour\n- Water, as needed\n- Salt, as per taste\n- Oil, as needed\n\nInstructions:\n\n1. In a large mixing bowl, add the whole wheat flour and salt. Mix well.\n2. Add enough water slowly to knead the dough (add water gradually to achieve the right consistency).\n3. Knead the dough for 5-7 minutes until it becomes soft and smooth.\n4. Divide the dough into equal-sized dough balls.\n5. Take a rolling pin and a small bowl-shaped object or a little flour. Dust the rolling pin, and the small bowl-shaped object/flour, and roll the dough ball into a flat disc.\n6. Apply a little oil on top of the flat disc and sprinkle a little wheat flour on it. Fold it into a half-moon shape and apply oil on it again, sprinkle some flour on it and fold into a triangle shape.\n7. Gently roll out the triangle into a flat disc.\n8. Heat a non-stick pan or tawa over medium heat.\n9. Place the rolled-out paratha on the tawa/pan and cook until small bubbles appear on its surface. Flip with a spatula and cook the other side the same way. Press gently on both sides while cooking to ensure even cooking and that the paratha is crispy and fully cooked.

Is there any way to get rid of them? I tried instructing the model to not add them in the system prompt but it still persists.

Any help is appreciated!

When you say markdown formatting, do you mean the “\n”?

Yes. The formatting to be precise. the \n in the text above.

Instructing the model “Respond with no formatting.” Seems to be working now. Thanks for the help anyway! But if you have any suggestion too please do suggest.

I wouldn’t call \n markdown. It just a newline character, that’ll improve readability of your text.

1 Like

Hi, I am having this same error too. Here is a tool that solves this. You can use this tool anytime you write

stripmd.vercel. app/