Markdown with Open AI API, strange behavior!


I use GitHub - showdownjs/showdown: A bidirectional Markdown to HTML to Markdown converter written in Javascript and i do CURL calls to the API to get responses

I am guessing that since the response is streaming, using showdown or other such libraries is tough as the markdown may not be finished in the streamed text, leaving the markdown to show as is without the “conversion” to HTML

Anyway, has anyone had luck with a good library to use to convert markdown from the API to HTMl please? I am reluctant to reinvent the wheel here

Thanks in advance

1 Like

I am using this:

With CURL, you can confirm that it works by doing:
curl -X POST -H “Content-Type: text/plain” --data-binary -o YourHTMLFileName.html

1 Like

Thank you

I am looking for something in Javascript.

I know it is a parsing thing… but am lazy to reinvent it (look for markup content in streamed chunk, if doesn’t exist then append to text… and store the info in a variable…) and then in next chunk if it exists, then treat it as a closing markdown… yuckkk…i may go round in circles



I found the solution: when OpenAi streams back markdown and/or HTML… you can use something like what is mentioned here

Bloody simple and amazing and useful

Hope this helps someone

1 Like