返回 Pixelle-Video
content.py
根目录 / api / schemas / content.py
1 # Copyright (C) 2025 AIDC-AI
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 # http://www.apache.org/licenses/LICENSE-2.0
7 # Unless required by applicable law or agreed to in writing, software
8 # distributed under the License is distributed on an "AS IS" BASIS,
9 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 # See the License for the specific language governing permissions and
11 # limitations under the License.
12
13 """
14 Content generation API schemas
15 """
16
17 from typing import List, Optional
18 from pydantic import BaseModel, Field
19
20
21 # ============================================================================
22 # Narration Generation
23 # ============================================================================
24
25 class NarrationGenerateRequest(BaseModel):
26 """Narration generation request"""
27 text: str = Field(..., description="Source text to generate narrations from")
28 n_scenes: int = Field(5, ge=1, le=20, description="Number of scenes")
29 min_words: int = Field(5, ge=1, le=100, description="Minimum words per narration")
30 max_words: int = Field(20, ge=1, le=200, description="Maximum words per narration")
31
32 class Config:
33 json_schema_extra = {
34 "example": {
35 "text": "Atomic Habits is about making small changes that lead to remarkable results.",
36 "n_scenes": 5,
37 "min_words": 5,
38 "max_words": 20
39 }
40 }
41
42
43 class NarrationGenerateResponse(BaseModel):
44 """Narration generation response"""
45 success: bool = True
46 message: str = "Success"
47 narrations: List[str] = Field(..., description="Generated narrations")
48
49
50 # ============================================================================
51 # Image Prompt Generation
52 # ============================================================================
53
54 class ImagePromptGenerateRequest(BaseModel):
55 """Image prompt generation request"""
56 narrations: List[str] = Field(..., description="List of narrations")
57 min_words: int = Field(30, ge=10, le=100, description="Minimum words per prompt")
58 max_words: int = Field(60, ge=10, le=200, description="Maximum words per prompt")
59
60 class Config:
61 json_schema_extra = {
62 "example": {
63 "narrations": [
64 "Small habits compound over time",
65 "Focus on systems, not goals"
66 ],
67 "min_words": 30,
68 "max_words": 60
69 }
70 }
71
72
73 class ImagePromptGenerateResponse(BaseModel):
74 """Image prompt generation response"""
75 success: bool = True
76 message: str = "Success"
77 image_prompts: List[str] = Field(..., description="Generated image prompts")
78
79
80 # ============================================================================
81 # Title Generation
82 # ============================================================================
83
84 class TitleGenerateRequest(BaseModel):
85 """Title generation request"""
86 text: str = Field(..., description="Source text")
87 style: Optional[str] = Field(None, description="Title style (e.g., 'engaging', 'formal')")
88
89 class Config:
90 json_schema_extra = {
91 "example": {
92 "text": "Atomic Habits is about making small changes that lead to remarkable results.",
93 "style": "engaging"
94 }
95 }
96
97
98 class TitleGenerateResponse(BaseModel):
99 """Title generation response"""
100 success: bool = True
101 message: str = "Success"
102 title: str = Field(..., description="Generated title")
103
104
104 lines PYTHON