From 07f679b2e728322990ccf10e8a51c2eb91a9aa2e Mon Sep 17 00:00:00 2001 From: Gmer4Lfe Date: Sun, 9 Aug 2026 22:54:42 -0400 Subject: [PATCH] Drop subreddit front pages from degoog results MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Its Reddit engine returns a community's landing page for any query at all — a question about ZFS scrubs came back with Rocket League Esports and Dividend Investing, interleaved one in two, so half of what reached the model was noise. Threads from that same engine are frequently the best result there is, so the engine stays and only the URL shape goes: /r/ with nothing after it is a front page by definition. That is a fact about the URL, not an opinion about how well it matches, and this file does no similarity scoring of its own. --- Plugin/unraid/include/ai_web.php | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/Plugin/unraid/include/ai_web.php b/Plugin/unraid/include/ai_web.php index 6200be0..52b357c 100644 --- a/Plugin/unraid/include/ai_web.php +++ b/Plugin/unraid/include/ai_web.php @@ -175,11 +175,26 @@ function vv_ai_web_degoog(string $q): ?array { if ($base === '') return null; $d = vv_ai_web_http($base . '/api/search?q=' . rawurlencode($q)); if ($d === null) return null; - return array_map(fn($r) => ['title' => $r['title'] ?? '', - 'url' => $r['url'] ?? '', - 'snippet' => ($r['snippet'] ?? '') !== '' ? $r['snippet'] - : ($r['content'] ?? '')], - array_slice($d['results'] ?? [], 0, vv_ai_web_results_max())); + + // Its Reddit engine returns subreddit front pages for any query at all — "Rocket League + // Esports" and "Dividend Investing" came back for a question about ZFS scrubs, interleaved + // one in two, so half of what reached the model was noise. Reddit *threads* from the same + // engine are often the best result there is, so the engine is not excluded; the shape of URL + // that cannot contain an answer is. + // + // Structural, not a relevance judgement. /r/ with nothing after it is a community's + // front page by definition, which is a fact about the URL rather than an opinion about how + // well it matches — this file does no similarity scoring of its own and should not start. + $rows = []; + foreach ($d['results'] ?? [] as $r) { + $url = (string)($r['url'] ?? ''); + if (preg_match('#^https?://(?:[a-z0-9-]+\.)*reddit\.com/r/[^/?#]+/?$#i', $url)) continue; + $rows[] = ['title' => $r['title'] ?? '', + 'url' => $url, + 'snippet' => ($r['snippet'] ?? '') !== '' ? $r['snippet'] : ($r['content'] ?? '')]; + if (count($rows) >= vv_ai_web_results_max()) break; + } + return $rows; } function vv_ai_web_searxng(string $q): ?array {