add a retranslate chinese function
This commit is contained in:
@@ -144,6 +144,31 @@ class SubtitleTranslationResponse(BaseModel):
|
||||
error: Optional[str] = None
|
||||
|
||||
|
||||
class TranslationTerm(BaseModel):
|
||||
model_config = ConfigDict(extra="forbid")
|
||||
|
||||
source: str = Field(min_length=1, max_length=120)
|
||||
zh: str = Field(min_length=1, max_length=120)
|
||||
|
||||
@field_validator("source", "zh")
|
||||
@classmethod
|
||||
def strip_term(cls, value: str) -> str:
|
||||
cleaned = value.strip()
|
||||
if not cleaned:
|
||||
raise ValueError("translation term cannot be empty")
|
||||
return cleaned
|
||||
|
||||
|
||||
class SubtitleRetranslateRequest(BaseModel):
|
||||
model_config = ConfigDict(extra="forbid")
|
||||
|
||||
terms: List[TranslationTerm] = Field(default_factory=list, max_length=50)
|
||||
|
||||
|
||||
class AdminSubtitleTranslationResponse(SubtitleTranslationResponse):
|
||||
terms: List[TranslationTerm] = Field(default_factory=list)
|
||||
|
||||
|
||||
class SentenceBoundaryAdjust(BaseModel):
|
||||
model_config = ConfigDict(extra="forbid")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user