Building something like gpt but how to format the rich text response

When the LLM sends the markdown how does it gives to rich text response …
Please help me out the frontend is in the next js and backend is in fast api