optimize flow retrieval

This commit is contained in:
team 1
2026-04-17 07:45:30 +02:00
parent eeebdfa21a
commit 84ba528036
3 changed files with 21 additions and 20 deletions

View File

@@ -93,7 +93,7 @@ final readonly class AgentRunner
yield $this->systemMsg("Ich optimere die Recherche...", "think");
//Call ai for optimized swag query
//Call AI for optimized swag query
foreach ($this->ollamaClient->stream($promptSwagSearch) as $swagToken) {
if (!is_string($swagToken)) {
@@ -111,7 +111,7 @@ final readonly class AgentRunner
yield $this->systemMsg("Ich rufe Recherchedaten ab (type: " . $commerceIntent . ")", "think");
//Search in swag by ai optimized query
//Search in swag by AI optimized query
try {
$shopResults = $swagFullOutPut !== ''
? $this->shopSearchService->search($swagFullOutPut, $commerceIntent)
@@ -122,7 +122,6 @@ final readonly class AgentRunner
'exception' => $e,
]);
$shopResults = [];
yield $this->systemMsg('Shopdaten konnten nicht geladen werden, ich antworte mit Wissensbasis weiter...', 'think');
}
}

View File

@@ -129,7 +129,7 @@ final readonly class PromptBuilder
}
if ($product->customFields) {
$parts[] = "Meta-Informationen: " . $product->customFields;
$parts[] = "Meta-Information: " . $product->customFields;
}
$lines[] = implode("\n", $parts);

View File

@@ -21,7 +21,8 @@ final readonly class ShopSearchService
private bool $enabled = true,
private int $maxResults = 25,
private string $baseUrl
) {
)
{
}
/**
@@ -98,11 +99,12 @@ final readonly class ShopSearchService
{
if (isset($description['translated']['description'])) {
$newDesc = strip_tags((string)$description['translated']['description']);
$newDesc = html_entity_decode($newDesc);
$newDesc = preg_replace('/^[ \t]*\R/m', '', $newDesc);
$newDesc = preg_replace('/[ \t]{2,}/', ' ', $newDesc);
$result = trim((string)$newDesc);
return mb_substr($result, 0, 500);
return mb_substr($result, 0, 1500);
}
return '';