Formatting response from AI
-
Hello Team,
I am expecting OpenAI to send code in the responses which they will send inside
or
based on the type of code provided.But it doesn’t appear good when those are not handled. is it possible that chatbot processes the response and by default adds <pre> for content inside
and <code> for content inside
Also I see OpenAI adds programming language as an added entry in the code so can we remove that as well?
I wrote some code which does the same in my existing solution but I couldn’t find similar alternative in your plugin so I am not able to use it. Do you already have any such functionality? If No, is it possible to add?
Sample code
function formatResponse(response) {
let cleanResponse = response.replace(/(\w+)\n/g, '
');
cleanResponse = cleanResponse.replace(/(.*?)
/gs, '<pre>$1</pre>');
cleanResponse = cleanResponse.replace(/(.*?)
/g, '<code>$1</code>');
return cleanResponse;
}
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- You must be logged in to reply to this topic.