I’ve got a chatbot working using Python(Flask), LangChain, ChromaDB and then HTML/CSS/JS front end.
My bot is a retrieval agent with vector embeddings.
My final issue is I cannot figure out how to get the agent’s response to render in a decent formatted manner with bullet points, paragraph spacing, etc.
It’s just a wall of text for the chatbot’s response in my browser, no matter what I seem to do.
I’ve tried converting the output to markdown and then to HTML, but that’s not working either.
I’m either not asking the question right to solve my problem or no one has written much about this because it’s just common knowledge for programmers, I guess, but I’m new and this has been 20 hours now trying to fix this!
Other info. I’m calling the gpt-4-0613 API if that means anything.
Edit: I finally figured out that my problem was I didn’t realize what I needed was a way to convert markdown to HTML.
As a noob I didn’t realize JSON isn’t the “output” format of the chatbot’s response via the API.
JSON is the wrapper that delivers the text and that text can be in markdown if the response calls for numbered lists or bullet points or whatever.
So I needed to convert the markdown to HTML in the browser to get the styling I wanted in terms of formatted blog posts, etc.
At first I created my own function tk try and manually handle the conversions, but that’s a fool’s errand as it’s just too much.
So I ended up using the “showdown” library to handle the conversion and this was all the code I needed:
<script>
// Initialize the Showdown converter
const converter = new showdown.Converter();
function convertMarkdownToHTML(markdown) {
return converter.makeHtml(markdown);
}
So thank you all for the help and encouragement.
I learned a “thousand ways it doesn’t work” by going through the process of trying to figure this out for 3 days though!