content.py 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. Content generation API schemas
  14. """
  15. from typing import List, Optional
  16. from pydantic import BaseModel, Field
  17. # ============================================================================
  18. # Narration Generation
  19. # ============================================================================
  20. class NarrationGenerateRequest(BaseModel):
  21. """Narration generation request"""
  22. text: str = Field(..., description="Source text to generate narrations from")
  23. n_scenes: int = Field(5, ge=1, le=20, description="Number of scenes")
  24. min_words: int = Field(5, ge=1, le=100, description="Minimum words per narration")
  25. max_words: int = Field(20, ge=1, le=200, description="Maximum words per narration")
  26. class Config:
  27. json_schema_extra = {
  28. "example": {
  29. "text": "Atomic Habits is about making small changes that lead to remarkable results.",
  30. "n_scenes": 5,
  31. "min_words": 5,
  32. "max_words": 20
  33. }
  34. }
  35. class NarrationGenerateResponse(BaseModel):
  36. """Narration generation response"""
  37. success: bool = True
  38. message: str = "Success"
  39. narrations: List[str] = Field(..., description="Generated narrations")
  40. # ============================================================================
  41. # Image Prompt Generation
  42. # ============================================================================
  43. class ImagePromptGenerateRequest(BaseModel):
  44. """Image prompt generation request"""
  45. narrations: List[str] = Field(..., description="List of narrations")
  46. min_words: int = Field(30, ge=10, le=100, description="Minimum words per prompt")
  47. max_words: int = Field(60, ge=10, le=200, description="Maximum words per prompt")
  48. class Config:
  49. json_schema_extra = {
  50. "example": {
  51. "narrations": [
  52. "Small habits compound over time",
  53. "Focus on systems, not goals"
  54. ],
  55. "min_words": 30,
  56. "max_words": 60
  57. }
  58. }
  59. class ImagePromptGenerateResponse(BaseModel):
  60. """Image prompt generation response"""
  61. success: bool = True
  62. message: str = "Success"
  63. image_prompts: List[str] = Field(..., description="Generated image prompts")
  64. # ============================================================================
  65. # Title Generation
  66. # ============================================================================
  67. class TitleGenerateRequest(BaseModel):
  68. """Title generation request"""
  69. text: str = Field(..., description="Source text")
  70. style: Optional[str] = Field(None, description="Title style (e.g., 'engaging', 'formal')")
  71. class Config:
  72. json_schema_extra = {
  73. "example": {
  74. "text": "Atomic Habits is about making small changes that lead to remarkable results.",
  75. "style": "engaging"
  76. }
  77. }
  78. class TitleGenerateResponse(BaseModel):
  79. """Title generation response"""
  80. success: bool = True
  81. message: str = "Success"
  82. title: str = Field(..., description="Generated title")