add history to shop search

This commit is contained in:
team 1
2026-04-17 12:59:21 +02:00
parent bab3682975
commit ae2b52ad18
8 changed files with 630 additions and 172 deletions

View File

@@ -1,14 +1,30 @@
<?php
declare(strict_types=1);
namespace App\Config;
class AgentRunnerConfig
final class AgentRunnerConfig
{
public function getShopPrompt($prompt): string
public function getShopPrompt(string $prompt, string $commerceHistoryContext = ''): string
{
/**
* Erzeuge aus dem folgenden Nutzereingabetext einen kurzen Suchtext für die Shopware-6-Suche. Regeln: - Gib nur den finalen Suchtext aus. - erstelle immer die singular form von den relevanten Suchbegriffen - Keine Einleitung, keine Erklärung, keine Anführungszeichen. - Verwende nur die shop relevanten Suchbegriffe für eine Shopsuche aus dem Nutzereingabetext. - Maximal 6 Suchbegriffe, besser weniger. - Entferne Füllwörter, Höflichkeitsformen und irrelevante Wörter. - Erhalte Produktnamen, Marken, Modellnummern und zusammengesetzte Begriffe exakt, wenn sie relevant sind. - Zahlen, die zu einem Produktnamen oder Modell gehören (zb Indikator 300 oder Testomat 808 oder Testomat 2000), müssen erhalten bleiben. - Trenne die Begriffe nur durch Leerzeichen. Ausgabeformat: Keyword1 Keyword2 Keyword3
*/
$historyBlock = '';
if (trim($commerceHistoryContext) !== '') {
$historyBlock = '
RECENT CONVERSATION CONTEXT:
' . $commerceHistoryContext . '
Additional rules for conversation context:
- The current user input has highest priority.
- Use the recent conversation context only to resolve omitted references.
- Use it only for product carry-over, brand carry-over, model carry-over, or variant follow-ups.
- Do not revive older products unless the current user input clearly refers to them.
- If the current input starts a new topic, ignore older product context.
- Prefer the most recent product reference over older ones.
';
}
return '
Generate a short search query for Shopware 6 from the following user input text.
@@ -23,11 +39,17 @@ class AgentRunnerConfig
- Numbers that belong to a product name or model must be preserved (e.g. Indikator 300, Testomat 808, Testomat 2000).
- Separate terms using spaces only.
- If a relevant product name is present, it must be placed at the beginning of the final search query.
- Try to always identify all products mentioned in the user input text, even in long prompts.
- Look for terms such as Testomat, Horiba, Tritromat, or words like indicator.
- If the current user input is vague or referential, use the recent conversation context only as support.
- Do not output words that only describe conversation flow, such as "same", "again", "also", or "like above".
Output format:
Keyword1 Keyword2 Keyword3
input text: ' . $prompt . '
' . $historyBlock . '
CURRENT USER INPUT:
' . $prompt . '
';
}
}