Some checks failed
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-school (push) Successful in 42s
CI / test-go-edu-search (push) Successful in 34s
CI / test-python-klausur (push) Failing after 2m51s
CI / test-python-agent-core (push) Successful in 21s
CI / test-nodejs-website (push) Successful in 29s
sed replacement left orphaned hostname references in story page and empty lines in getApiBase functions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
87 lines
2.6 KiB
Python
87 lines
2.6 KiB
Python
"""Pydantic models and enums for the Vocab Worksheet API."""
|
|
|
|
from datetime import datetime
|
|
from enum import Enum
|
|
from typing import List, Optional
|
|
|
|
from pydantic import BaseModel
|
|
|
|
|
|
# =============================================================================
|
|
# Enums
|
|
# =============================================================================
|
|
|
|
class WorksheetType(str, Enum):
|
|
EN_TO_DE = "en_to_de" # English -> German translation
|
|
DE_TO_EN = "de_to_en" # German -> English translation
|
|
COPY_PRACTICE = "copy" # Write word multiple times
|
|
GAP_FILL = "gap_fill" # Fill in the blanks
|
|
COMBINED = "combined" # All types combined
|
|
|
|
|
|
class SessionStatus(str, Enum):
|
|
PENDING = "pending" # Session created, no upload yet
|
|
PROCESSING = "processing" # OCR in progress
|
|
EXTRACTED = "extracted" # Vocabulary extracted, ready to edit
|
|
COMPLETED = "completed" # Worksheet generated
|
|
|
|
|
|
# =============================================================================
|
|
# Pydantic Models
|
|
# =============================================================================
|
|
|
|
class VocabularyEntry(BaseModel):
|
|
id: str
|
|
english: str
|
|
german: str
|
|
example_sentence: Optional[str] = None
|
|
example_sentence_gap: Optional[str] = None # With ___ for gap-fill
|
|
word_type: Optional[str] = None # noun, verb, adjective, etc.
|
|
source_page: Optional[int] = None # Page number where entry was found (1-indexed)
|
|
|
|
|
|
class SessionCreate(BaseModel):
|
|
name: str
|
|
description: Optional[str] = None
|
|
source_language: str = "en" # Source language (default English)
|
|
target_language: str = "de" # Target language (default German)
|
|
|
|
|
|
class SessionResponse(BaseModel):
|
|
id: str
|
|
name: str
|
|
description: Optional[str]
|
|
source_language: str
|
|
target_language: str
|
|
status: str
|
|
vocabulary_count: int
|
|
image_path: Optional[str]
|
|
created_at: datetime
|
|
|
|
|
|
class VocabularyResponse(BaseModel):
|
|
session_id: str
|
|
vocabulary: List[VocabularyEntry]
|
|
extraction_confidence: Optional[float]
|
|
|
|
|
|
class VocabularyUpdate(BaseModel):
|
|
vocabulary: List[VocabularyEntry]
|
|
|
|
|
|
class WorksheetGenerateRequest(BaseModel):
|
|
worksheet_types: List[WorksheetType]
|
|
title: Optional[str] = None
|
|
include_solutions: bool = True
|
|
repetitions: int = 3 # For copy practice
|
|
line_height: str = "normal" # normal, large, extra-large
|
|
|
|
|
|
class WorksheetResponse(BaseModel):
|
|
id: str
|
|
session_id: str
|
|
worksheet_types: List[str]
|
|
pdf_path: str
|
|
solution_path: Optional[str]
|
|
generated_at: datetime
|