When using the o3-mini model via the OpenAI API in PHP, we encountered an issue with Markdown formatting. The model sometimes returns <?php instead of ```php, preventing ParsedownExtra from rendering the code correctly. This problem is specific to o3-mini and does not occur in gpt-4o or o1.
We are using ParsedownExtra in a Laravel project GitHub /erusev/parsedown.
Has anyone else encountered this issue? Are there any suggested fixes, workarounds, or alternative PHP Markdown parsers we can test ?
Markdown formatting: Starting with o1-2024-12-17, reasoning models in the API will avoid generating responses with markdown formatting. To signal to the model when you do want markdown formatting in the response, include the string Formatting re-enabled on the first line of your developer message.
You can enhance that with “the PHP code will be output in a markdown code fence block, with no additional chat.”
Thank you! The solution is to add the phrase “Formatting re-enabled” before the query :
$history[] = [
'role' => 'user',
// 'content' => $prompt_query, // Do not use this
'content' => "Formatting re-enabled " . $prompt_query,
];
The problem is related to the OpenAI API:
Markdown formatting: Starting with o1-2024-12-17, reasoning models in the API avoid generating responses with markdown formatting. To signal to the model that you want markdown formatting in the response, include the string “Formatting re-enabled” on the first line of your developer message.