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");
|
||||
|
||||
//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) {
|
||||
@@ -203,8 +215,8 @@ final readonly class AgentRunner
|
||||
$finalChunk = $chunker->flush();
|
||||
if ($finalChunk !== null) {
|
||||
yield $this->systemMsg($finalChunk, 'answer');
|
||||
} else {
|
||||
yield $this->systemMsg('... no more data received from llm', 'err');
|
||||
} elseif ($fullOutput === '') {
|
||||
yield $this->systemMsg('❌ Es wurden keine Daten vom LLM empfangen.', 'err');
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------
|
||||
@@ -229,7 +241,7 @@ final readonly class AgentRunner
|
||||
'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
|
||||
{
|
||||
$priceMin = 10;
|
||||
$priceMin = 0;
|
||||
$priceMax = null;
|
||||
|
||||
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!)
|
||||
// ---------------------------------------------------------
|
||||
foreach ($this->agentRunner->run($prompt, $clientId,true) as $chunk) {
|
||||
// Normalize line endings
|
||||
try {
|
||||
foreach ($this->agentRunner->run($prompt, $clientId, true) as $chunk) {
|
||||
$chunk = str_replace(["\r\n", "\r"], "\n", $chunk);
|
||||
|
||||
// Sende Chunk direkt mit \n
|
||||
$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
|
||||
// ---------------------------------------------------------
|
||||
|
||||
@@ -38,6 +38,7 @@ final class CommerceIntentLite
|
||||
'alternativ',
|
||||
'find',
|
||||
'shop',
|
||||
'store',
|
||||
'sku',
|
||||
'Artikel',
|
||||
'Gerät',
|
||||
@@ -46,7 +47,8 @@ final class CommerceIntentLite
|
||||
'Titromat',
|
||||
'Seminar',
|
||||
'Schulung',
|
||||
'Sensor'
|
||||
'Sensor',
|
||||
'liste'
|
||||
];
|
||||
|
||||
foreach ($strongSignals as $signal) {
|
||||
|
||||
Reference in New Issue
Block a user