feat: strip --- delimiters from eBay text output, commercial listing prompt

Agent now extracts content between --- markers so LLM preamble/postamble
is discarded. ebay_description prompt updated for commercial listings:
no private-sale language, condition explicitly "gebraucht", 1 year
gesetzliche Gewährleistung. Device label now includes modelName.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Simon Kuehn 2026-05-18 11:18:40 +00:00
parent 1df6b7f0c6
commit a381ee6531
2 changed files with 78 additions and 3 deletions

View file

@ -0,0 +1,65 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20260520070000 extends AbstractMigration
{
public function getDescription(): string
{
return 'Update eBay prompts: --- delimiters, commercial language, 1-year warranty';
}
public function up(Schema $schema): void
{
$title = <<<'PROMPT'
Create a concise eBay listing title (max 80 characters) for this {{typeName}}.
Device: {{deviceLabel}}
Condition: {{condition}} (used/gebraucht)
{{specsSection}}
Rules: no quotes, no explanation, no private-sale language.
Wrap your answer between --- delimiters like this:
---
your title here
---
PROMPT;
$description = <<<'PROMPT'
Erstelle eine professionelle eBay-Artikelbeschreibung auf Deutsch für diesen {{typeName}}.
Gerät: {{deviceLabel}}
Zustand: gebraucht {{condition}}
{{conditionNotes}}
{{specsSection}}
Wichtige Vorgaben:
- Gewerbliches Angebot (kein Privatverkauf, keine Privatverkauf-Ausschlussklauseln)
- 1 Jahr gesetzliche Gewährleistung
- Zustand "gebraucht" klar erwähnen
- Alle verfügbaren technischen Daten strukturiert auflisten
- HTML-Formatierung verwenden (ul, li, strong-Tags)
- Maximal 2000 Zeichen
Gib NUR den HTML-Beschreibungstext aus, eingefasst zwischen --- Trennzeichen:
---
HTML hier
---
PROMPT;
$this->addSql('UPDATE app.prompt_templates SET body = :body, updated_at = NOW() WHERE key = :key', [
'body' => $title, 'key' => 'ebay_title',
]);
$this->addSql('UPDATE app.prompt_templates SET body = :body, updated_at = NOW() WHERE key = :key', [
'body' => $description, 'key' => 'ebay_description',
]);
}
public function down(Schema $schema): void
{
$this->addSql("UPDATE app.prompt_templates SET body = 'Create a concise eBay listing title (max 80 characters) for this {{typeName}}.\nDevice: {{deviceLabel}}\nUse the most important specifications. Include condition if not \"new\".\nCondition: {{condition}}\n{{specsSection}}\nReturn ONLY the title text, no quotes, no explanation.', updated_at = NOW() WHERE key = 'ebay_title'");
$this->addSql("UPDATE app.prompt_templates SET body = 'Create a professional eBay listing description in German for this {{typeName}}.\nDevice: {{deviceLabel}}\nInclude all available specifications in a clear, structured format.\nMention the condition: {{condition}}.\n{{conditionNotes}}\n{{specsSection}}\nUse HTML formatting (ul, li, strong tags). Max 2000 characters.', updated_at = NOW() WHERE key = 'ebay_description'");
}
}

View file

@ -17,6 +17,15 @@ final class EbayTextAgent
) {
}
private function extractBetweenDelimiters(string $raw): string
{
if (preg_match('/---\s*\n(.*?)\n\s*---/s', $raw, $matches)) {
return trim($matches[1]);
}
return trim($raw);
}
/** @return array{title: string, description: string} */
public function generate(Article $article, string $specsText = ''): array
{
@ -32,8 +41,9 @@ final class EbayTextAgent
$condition = $article->getCondition()->value;
$conditionNotes = $article->getConditionNotes() ?? '';
$manufacturer = $article->getManufacturer() ?? '';
$modelName = $article->getModelName() ?? '';
$modelNumber = $article->getModelNumber() ?? '';
$deviceLabel = trim("{$manufacturer} {$modelNumber}") ?: $typeName;
$deviceLabel = trim("{$manufacturer} {$modelName} {$modelNumber}") ?: $typeName;
$specsSection = $attributeText !== ''
? "Known attributes:\n{$attributeText}"
@ -54,8 +64,8 @@ final class EbayTextAgent
'specsSection' => $specsSection,
]);
$title = trim($this->ollama->generate($this->model, $titlePrompt));
$description = trim($this->ollama->generate($this->model, $descriptionPrompt));
$title = $this->extractBetweenDelimiters($this->ollama->generate($this->model, $titlePrompt));
$description = $this->extractBetweenDelimiters($this->ollama->generate($this->model, $descriptionPrompt));
if (mb_strlen($title) > 80) {
$title = mb_substr($title, 0, 77).'...';