passionweb-manuel-schnabel / ai-seo-helper

Generates SEO metadata based on content using AI. Currently several metadata for pages and articles of EXT:news can be generated using an additional button next to the corresponding input fields.
10 stars 5 forks source link

ai_seo_helper strips all hyphens from the generated suggestions #16

Open tehplague opened 1 week ago

tehplague commented 1 week ago

The extension tries to strip hyphens and bullet dots from the LLM responses because the LLMs are asked to provide their answers as such lists. However, instead of only removing those characters from line beginnings, every occurrence of - and is removed.

The culprit is in Passionweb\AiSeoHelper\Service\ContentService::buildBulletPointList(). A simple str_replace is not enough to properly sanitize the LLM response in this regard.

Additionally, while looking at this function, I am also unsure whether explode()ing the response by PHP_EOL is suitable to get individual lines in the first place. I suppose OpenAI's API constantly uses plain LF characters as line endings but on non-Unix systems we may have PHP_EOL != LF.

Why don't we try to let the LLM provide its answers e.g. directly as a JSON array by modifying the prompt accordingly? This would ease decoding a lot.

passionweb-manuel-schnabel commented 1 week ago

Hey @tehplague ,

thanks for opening this issue and sorry for the late replay (TYPO3 camp Vienna was calling ;-)).

Your approach sounds good and I think this could really simplify the process.

I will refactor the generation of the suggestions the next time.

Greetings Manu