feat(sources): primary-source discovery via searxng and local llm

This commit is contained in:
kpa39l
2026-11-01 18:03:20 +00:00
parent fba0e395b6
commit 13a6d0647e
25 changed files with 1339 additions and 4 deletions
+4
View File
@@ -49,6 +49,10 @@
{% endif %}
</div>
{% with post = selected, candidates = src_candidates, did = '', error = '', enabled = find_enabled %}
{% include "_post_sources.html" %}
{% endwith %}
<hr class="border-neutral-200 my-1 shrink-0">
<div x-data="{ tab: '{{ 'tr' if selected.translated_text else 'orig' }}' }" class="flex flex-col grow" style="min-height:0;">
<div class="flex items-center justify-between shrink-0 mb-2 gap-2">
+50
View File
@@ -0,0 +1,50 @@
{# Блок «🔎 Источники» в карточке поста (кандидат и отобранный).
Рендерится и как часть страницы, и как htmx-фрагмент (hx-target="#sources-panel", outerHTML). #}
<div id="sources-panel" class="border-t border-neutral-200 pt-2 mt-2 shrink-0">
<div class="flex items-center justify-between gap-2 mb-1">
<span class="text-sm font-medium">🔎 Источники</span>
{% if enabled %}
<form hx-post="/posts/{{ post.id }}/find-sources" hx-target="#sources-panel" hx-swap="outerHTML"
hx-indicator="#src-spin" hx-disabled-elt="find button" method="post"
action="/posts/{{ post.id }}/find-sources">
<button class="btn btn-xs btn-outline" type="submit"
title="Найти первоисточник: ссылки из текста, затем поиск и оценка локальной моделью">Найти источники</button>
<span id="src-spin" class="htmx-indicator text-xs text-neutral-500">⏳ ищу…</span>
</form>
{% endif %}
</div>
{% if did %}<div class="text-xs text-green-700 mb-1">✅ {{ did }}</div>{% endif %}
{% if error %}<div class="text-xs text-red-600 mb-1">⚠ {{ error }}</div>{% endif %}
{% if candidates %}
<div class="flex flex-col gap-1 overflow-y-auto" style="max-height: 12rem;">
{% for c in candidates %}
<div class="flex items-start gap-2 text-xs border border-neutral-200 rounded-md px-2 py-1">
<div class="grow min-w-0">
<div class="flex items-center gap-1 flex-wrap">
<span class="badge badge-{{ 'info' if c.kind == 'telegram' else 'neutral' }}">{{ c.kind }}</span>
{% if c.score is not none %}<span class="badge badge-{{ 'success' if c.score >= 0.7 else 'warning' }}">{{ '%.1f'|format(c.score) }}</span>{% endif %}
<a href="{{ c.url }}" target="_blank" class="no-underline font-medium truncate">{{ c.domain or c.url }}</a>
</div>
<div class="text-neutral-600 truncate">{{ c.title or '' }}</div>
{% if c.reason %}<div class="text-neutral-500">{{ c.reason }}</div>{% endif %}
{% if c.snippet %}<details class="text-neutral-500"><summary class="cursor-pointer">сниппет</summary>{{ c.snippet }}</details>{% endif %}
</div>
<div class="flex flex-col gap-1 shrink-0">
<form hx-post="/posts/{{ post.id }}/sources/{{ c.id }}/accept" hx-target="#sources-panel" hx-swap="outerHTML"
method="post" action="/posts/{{ post.id }}/sources/{{ c.id }}/accept">
<button class="btn btn-xs btn-success" type="submit" title="Добавить в реестр источников (Telegram-канал или RSS-лента)">➕</button>
</form>
<form hx-post="/posts/{{ post.id }}/sources/{{ c.id }}/reject" hx-target="#sources-panel" hx-swap="outerHTML"
method="post" action="/posts/{{ post.id }}/sources/{{ c.id }}/reject">
<button class="btn btn-xs btn-outline text-red-600" type="submit" title="Не источник — больше не предлагать">❌</button>
</form>
</div>
</div>
{% endfor %}
</div>
{% else %}
<div class="text-xs text-neutral-500">Источники не искали. «Найти источники» — ссылки из текста, затем поиск.</div>
{% endif %}
</div>
+1
View File
@@ -67,6 +67,7 @@
<div class="join w-full flex-wrap">
<button class="join-item flex-1 btn btn-sm btn-info" name="action" value="process">🤖 Обработать моделью</button>
<button class="join-item flex-1 btn btn-sm" name="action" value="enqueue">🗓 В очередь</button>
<button class="join-item flex-1 btn btn-sm" name="action" value="find-sources">🔎 Источники</button>
<button class="join-item flex-1 btn btn-sm" name="action" value="rewrite">✍️ Переписать</button>
<button class="join-item flex-1 btn btn-sm btn-success" name="action" value="approve">✅ Опубликовать</button>
<button class="join-item flex-1 btn btn-sm btn-outline text-red-600" name="action" value="reject">🚫 Отклонить</button>
+3
View File
@@ -94,6 +94,9 @@
</form>
{% endif %}
</div>
{% with post = selected, candidates = src_candidates, did = '', error = '', enabled = find_enabled %}
{% include "_post_sources.html" %}
{% endwith %}
<!-- Резюме — сразу под кнопками -->
{% if selected.summary %}
<div class="shrink-0 mb-2">
+3
View File
@@ -3,6 +3,9 @@
{% block content %}
<h4 class="text-xl font-semibold mb-4 flex items-center gap-2 flex-wrap">📡 Источники
<a href="/crawlers" class="btn btn-sm btn-outline">Статус краулеров →</a>
{% if find_enabled %}
<span class="text-sm text-neutral-500 font-normal">поисковых запросов за сутки: <b>{{ search_stats }}</b></span>
{% endif %}
</h4>
{% if did %}