feat: multiple translations with context, improved task examples

- Add WordTranslation model for storing multiple translations per word
- AI generates translations with example sentences and their translations
- Show example usage after answering tasks (learning + interface language)
- Save translations to word_translations table when adding words from tasks
- Improve word exclusion in new_words mode (stronger prompt + client filtering)
- Add migration for word_translations table

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-12-06 21:29:41 +03:00
parent 63e2615243
commit d937b37a3b
10 changed files with 543 additions and 30 deletions

View File

@@ -93,6 +93,19 @@ class Vocabulary(Base):
notes: Mapped[Optional[str]] = mapped_column(String(500)) # Заметки пользователя
class WordTranslation(Base):
"""Модель перевода слова с контекстом"""
__tablename__ = "word_translations"
id: Mapped[int] = mapped_column(primary_key=True)
vocabulary_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
translation: Mapped[str] = mapped_column(String(255), nullable=False)
context: Mapped[Optional[str]] = mapped_column(String(500)) # Пример предложения
context_translation: Mapped[Optional[str]] = mapped_column(String(500)) # Перевод примера
is_primary: Mapped[bool] = mapped_column(Boolean, default=False) # Основной перевод
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow)
class Task(Base):
"""Модель задания"""
__tablename__ = "tasks"