I am developing a sort of chatbot using php within the Drupal CMS framework. It is designed to give responses using site documents as context.
I am making my API calls to gpt-4 and gpt3.5-tubo.
I am getting responses fine, but they come back as plain text. This is how they are coming back directly from the server. So, for example, when the LLM responds with a list, it uses linefeed characters \n which of course are ignored in html.
So far, the best I can come up with in code(javascript and php) is:
var output = {{ newOutput|json_encode|raw }};
output = output.replace(/\n/g, '<br>'); // Add this line
output = output.split('<br>');
Any ideas on better solutions for displaying model API responses (chat completions)?