optimize intention
This commit is contained in:
@@ -128,7 +128,19 @@ final readonly class AgentRunner
|
|||||||
yield $this->systemMsg("Ich rufe Shopdaten ab (type: " . $commerceIntent . ")", "think");
|
yield $this->systemMsg("Ich rufe Shopdaten ab (type: " . $commerceIntent . ")", "think");
|
||||||
|
|
||||||
//Search in swag by ai optimized query
|
//Search in swag by ai optimized query
|
||||||
$shopResults = $swagFullOutPut ? $this->shopSearchService->search($swagFullOutPut, $commerceIntent) : '';
|
try {
|
||||||
|
$shopResults = $swagFullOutPut !== ''
|
||||||
|
? $this->shopSearchService->search($swagFullOutPut, $commerceIntent)
|
||||||
|
: [];
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
$this->agentLogger->warning('Shop search failed, continuing without shop results', [
|
||||||
|
'userId' => $userId,
|
||||||
|
'exception' => $e,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$shopResults = [];
|
||||||
|
yield $this->systemMsg('Shopdaten konnten nicht geladen werden, ich antworte mit Wissensbasis weiter...', 'think');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($commerceIntent === CommerceIntentLite::PRODUCT_SEARCH) {
|
if ($commerceIntent === CommerceIntentLite::PRODUCT_SEARCH) {
|
||||||
@@ -203,8 +215,8 @@ final readonly class AgentRunner
|
|||||||
$finalChunk = $chunker->flush();
|
$finalChunk = $chunker->flush();
|
||||||
if ($finalChunk !== null) {
|
if ($finalChunk !== null) {
|
||||||
yield $this->systemMsg($finalChunk, 'answer');
|
yield $this->systemMsg($finalChunk, 'answer');
|
||||||
} else {
|
} elseif ($fullOutput === '') {
|
||||||
yield $this->systemMsg('... no more data received from llm', 'err');
|
yield $this->systemMsg('❌ Es wurden keine Daten vom LLM empfangen.', 'err');
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
@@ -229,7 +241,7 @@ final readonly class AgentRunner
|
|||||||
'exception' => $e,
|
'exception' => $e,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->systemMsg("\n❌ An internal error occurred while processing the request. \nError: " . $e->getMessage(), 'err');
|
yield $this->systemMsg("\n❌ An internal error occurred while processing the request. \nError: " . $e->getMessage(), 'err');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ final class CommerceQueryParser
|
|||||||
*/
|
*/
|
||||||
private function extractPriceRange(string $prompt): array
|
private function extractPriceRange(string $prompt): array
|
||||||
{
|
{
|
||||||
$priceMin = 10;
|
$priceMin = 0;
|
||||||
$priceMax = null;
|
$priceMax = null;
|
||||||
|
|
||||||
if (preg_match('/\bzwischen\s+(\d+(?:[.,]\d+)?)\s+und\s+(\d+(?:[.,]\d+)?)\s+euro\b/u', $prompt, $m) === 1) {
|
if (preg_match('/\bzwischen\s+(\d+(?:[.,]\d+)?)\s+und\s+(\d+(?:[.,]\d+)?)\s+euro\b/u', $prompt, $m) === 1) {
|
||||||
|
|||||||
@@ -58,14 +58,18 @@ final readonly class AskSseController
|
|||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
// 🔥 FIXED: Sende Chunks direkt (behält \n!)
|
// 🔥 FIXED: Sende Chunks direkt (behält \n!)
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
|
try {
|
||||||
foreach ($this->agentRunner->run($prompt, $clientId, true) as $chunk) {
|
foreach ($this->agentRunner->run($prompt, $clientId, true) as $chunk) {
|
||||||
// Normalize line endings
|
|
||||||
$chunk = str_replace(["\r\n", "\r"], "\n", $chunk);
|
$chunk = str_replace(["\r\n", "\r"], "\n", $chunk);
|
||||||
|
|
||||||
// Sende Chunk direkt mit \n
|
|
||||||
$this->sendData($chunk);
|
$this->sendData($chunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->sendEvent('done', '[DONE]');
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
$this->sendData('<span class="text-danger">❌ Stream abgebrochen: ' . $e->getMessage() . '</span>');
|
||||||
|
$this->sendEvent('done', '[DONE]');
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
// Signal completion
|
// Signal completion
|
||||||
// ---------------------------------------------------------
|
// ---------------------------------------------------------
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ final class CommerceIntentLite
|
|||||||
'alternativ',
|
'alternativ',
|
||||||
'find',
|
'find',
|
||||||
'shop',
|
'shop',
|
||||||
|
'store',
|
||||||
'sku',
|
'sku',
|
||||||
'Artikel',
|
'Artikel',
|
||||||
'Gerät',
|
'Gerät',
|
||||||
@@ -46,7 +47,8 @@ final class CommerceIntentLite
|
|||||||
'Titromat',
|
'Titromat',
|
||||||
'Seminar',
|
'Seminar',
|
||||||
'Schulung',
|
'Schulung',
|
||||||
'Sensor'
|
'Sensor',
|
||||||
|
'liste'
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($strongSignals as $signal) {
|
foreach ($strongSignals as $signal) {
|
||||||
|
|||||||
Reference in New Issue
Block a user