optimize retrieve logic

This commit is contained in:
team 1
2026-04-14 12:43:43 +02:00
parent 406e59b0fd
commit 7caf6b5354
6 changed files with 51 additions and 41 deletions

View File

@@ -30,12 +30,14 @@ final readonly class PromptBuilder
* @return string
*/
public function build(
string $prompt,
string $userId,
string $urlContent,
array $knowledgeChunks,
array $shopResults = [],
?bool $fullContext = false,
string $prompt,
string $userId,
string $urlContent,
array $knowledgeChunks,
array $shopResults = [],
?bool $fullContext = false,
?string $swagFullOutPut = ''
): string
{
$now = (new DateTimeImmutable())->format('Y-m-d H:i:s');
@@ -77,6 +79,10 @@ final readonly class PromptBuilder
$shopBlock = '';
$isDetailed = !(count($shopResults) > 5);
if($swagFullOutPut){
$shopBlock = "SHOP SEARCH QUERY: " . trim($swagFullOutPut)."\n";
}
if ($shopResults !== []) {
$lines = [];
@@ -130,7 +136,7 @@ final readonly class PromptBuilder
}
if ($lines !== []) {
$shopBlock =
$shopBlock .=
"LIVE SHOP RESULTS (authoritative for products):\n" .
implode("\n\n", $lines);
}
@@ -141,6 +147,7 @@ final readonly class PromptBuilder
// ------------------------------------------------------------
$knowledgeParts = [];
if ($knowledgeChunks !== []) {
$lines = [];