mirror of
https://gitverse.ru/kpa39l/vesti.git
synced 2026-09-29 09:55:03 +00:00
openspec: change-ы manual-direction (ручное направление без LLM) и extract-post-sources (извлечение источников из постов) + sources/extract.py
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
# manual-direction
|
||||
|
||||
## Design
|
||||
|
||||
### web/app.py
|
||||
|
||||
`post_reclassify(post_id, request, group_by, direction, own, q, src, manual_direction: str = Form(""))`:
|
||||
|
||||
- передать `manual_direction` в `impl_reclassify`.
|
||||
|
||||
`impl_reclassify(post_id, manual_direction: str = "")`:
|
||||
|
||||
```python
|
||||
def impl_reclassify(post_id: int, manual_direction: str = ""):
|
||||
from classifier.classify import classify_text
|
||||
from classifier.keywords import DIRECTIONS_CANON
|
||||
conn = _db()
|
||||
p = conn.execute("SELECT * FROM posts WHERE id=?", (post_id,)).fetchone()
|
||||
if not p:
|
||||
conn.close()
|
||||
raise ValueError("notfound")
|
||||
md = (manual_direction or "").strip()
|
||||
if md in DIRECTIONS_CANON:
|
||||
# ручное направление: без LLM, classified=1, как словарное попадание
|
||||
conn.execute(
|
||||
"UPDATE posts SET direction=?, relevance=?, interest=?, summary=?, classified=1 WHERE id=?",
|
||||
(md, "low", 1, "", post_id),
|
||||
)
|
||||
conn.commit()
|
||||
conn.close()
|
||||
return
|
||||
res = classify_text(dict(p))
|
||||
... # как раньше
|
||||
```
|
||||
|
||||
### web/templates/selected.html
|
||||
|
||||
В форме reclassify (кнопка «🤖 Обработать моделью») добавить select:
|
||||
|
||||
```html
|
||||
<form method="post" action="/posts/{{ selected.id }}/reclassify" class="d-inline-flex align-items-center gap-1">
|
||||
{{ hid }}
|
||||
<select name="manual_direction" class="form-select form-select-sm w-auto">
|
||||
<option value="">— модель —</option>
|
||||
{% for d in directions %}
|
||||
<option value="{{ d }}">{{ d }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<button class="btn btn-info" type="submit">🤖 Обработать моделью</button>
|
||||
</form>
|
||||
```
|
||||
|
||||
Поведение:
|
||||
- «— модель —»: прежнее поведение (LLM).
|
||||
- выбор направления: установится принудительно, без LLM.
|
||||
Reference in New Issue
Block a user