optimize intention

This commit is contained in:
team 1
2026-04-14 19:54:42 +02:00
parent 0fead8983e
commit c8d7ecf1f5
4 changed files with 29 additions and 11 deletions

View File

@@ -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');
}
}