Problem/Motivation

When using a custom prompt, it seems I get reports back in markdown and not HTML like the default prompt.

Steps to reproduce

Proposed resolution

Maybe hard code the desired report format?

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork openai_seo-3406001

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

NicholasS created an issue. See original summary.

nicholass’s picture

Status: Active » Needs review
j-vee’s picture

Thanks @NicholasS, good idea that appending the request for HTML to the prompt. I patched in the code from your MR and changed the place where that request is appended to analyzeUrl-function instead, that way it'll always be appended no matter how the service is used.

j-vee’s picture

Status: Needs review » Fixed
j-vee’s picture

nicholass’s picture

StatusFileSize
new97.3 KB

@j-vee So I was occasionally getting some varying HTML formats returned to me even with this request for HTML added on to the end of custom prompts. Most common was ```html I assume a markdown wrapper indicating html.

I wonder if a better approach is to not fight the default markdown format, and just use an existing module or something to render the markdown for the reports? https://www.drupal.org/project/markdown

j-vee’s picture

Title: Custom Prompts Return report in markdown and not HTML » Prompts can return report in markdown and not HTML
Status: Fixed » Needs work

I faced that issue previously but hadn't had it happen for a long time so I thought the prompt updates had fixed it.

Might be better that we do change the module to do just that. Ask for markdown and then convert it to HTML in the back end using a composer plugin like the one drupal/markdown is using: https://github.com/thephpleague/commonmark

It might save a few tokens as well I imagine.

So let's re-open this one for now, thanks!

j-vee’s picture

Status: Needs work » Fixed

I've pushed out a new release to dev that should fix this. So now we specify in the prompt that we want the results in markdown (which the API would provide anyway) and we then use thephpleague/commonmark library to convert that markdown into HTML.

And it works pretty darn well! This way also does save on some tokens so it's a win win solution. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.