Files
vesti/openspec/changes/manual-direction/design.md
T

56 lines
1.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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.