optimize debug retrieval

This commit is contained in:
team2
2026-03-01 20:27:43 +01:00
parent 4a619cd6a8
commit 7b6d8f7269
3 changed files with 18 additions and 14 deletions

View File

@@ -16,7 +16,7 @@ use App\Vector\VectorSearchClient;
final class NdjsonHybridRetriever implements RetrieverInterface
{
private const VECTOR_SCORE_THRESHOLD = 0.72;
private const VECTOR_SCORE_THRESHOLD = 0.82;
// Guardrails
private const HARD_MAX_CHUNKS = 90;
@@ -45,7 +45,8 @@ final class NdjsonHybridRetriever implements RetrieverInterface
private readonly CatalogIntentLite $catalogIntent,
private readonly IntentRouteResolver $routeResolver,
private readonly EntityCatalogService $entityCatalogService
) {
)
{
}
// =========================================================
@@ -123,9 +124,9 @@ final class NdjsonHybridRetriever implements RetrieverInterface
* text:string
* }>
*/
public function retrieveDebug(string $prompt): array
public function retrieveDebug(string $prompt, ?ModelGenerationConfig $config = null): array
{
$config = $this->configRepository->findActiveForModel();
$config = $config ?? $this->configRepository->findActiveForModel();
if ($config === null) {
throw new \RuntimeException('No active ModelGenerationConfig found.');
@@ -193,11 +194,12 @@ final class NdjsonHybridRetriever implements RetrieverInterface
* }
*/
private function runCore(
string $prompt,
string $prompt,
ModelGenerationConfig $config,
bool $withScores,
string $salesIntent
): array {
bool $withScores,
string $salesIntent
): array
{
$limit = max(1, min($config->getRetrievalMaxChunks(), self::HARD_MAX_CHUNKS));
$vectorTopKBase = max(1, min($config->getRetrievalVectorTopK(), self::HARD_MAX_VECTORK));
@@ -338,9 +340,10 @@ final class NdjsonHybridRetriever implements RetrieverInterface
array $globalHits,
array $scopedHits,
float $threshold,
bool $boostScoped,
bool $captureRaw
): array {
bool $boostScoped,
bool $captureRaw
): array
{
$rrfScores = [];
$rawScores = [];

View File

@@ -74,7 +74,7 @@ final class ModelGenerationConfigAdminService
return [];
}
return $this->retriever->retrieveDebug($prompt);
return $this->retriever->retrieveDebug($prompt,$config);
}
private function requireString(mixed $value, string $field): string