optimize retrieve logic
This commit is contained in:
@@ -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 = [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user