Spaces:
Sleeping
Sleeping
File size: 4,543 Bytes
dc41b87 7d52223 dc41b87 7d52223 dc41b87 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | """
راوي (Rawi) - Arabic AI Storytelling Platform
Data models for API requests and responses
"""
from enum import Enum
from typing import List, Optional
from pydantic import BaseModel, Field
# ======== Enum Types ========
class StoryLength(str, Enum):
"""Story length options"""
SHORT = "short"
MEDIUM = "medium"
LONG = "long"
class StoryType(str, Enum):
"""Story genre options in Arabic"""
ROMANCE = "رومانسي"
HORROR = "رعب"
COMEDY = "كوميدي"
ACTION = "أكشن"
ADVENTURE = "مغامرة"
DRAMA = "دراما"
FANTASY = "خيال"
HISTORICAL = "تاريخي"
MYSTERY = "غموض"
NONE = "لا"
class CharacterGender(str, Enum):
"""Character gender options in Arabic"""
MALE = "ذكر"
FEMALE = "أنثى"
# ======== Request Models ========
class Character(BaseModel):
"""Character information for story generation"""
name: str = Field(..., description="اسم الشخصية")
gender: CharacterGender = Field(..., description="جنس الشخصية")
description: str = Field(..., description="وصف الشخصية")
class StoryConfig(BaseModel):
"""Configuration for initial story generation"""
length: StoryLength = Field(..., description="طول القصة")
primary_type: StoryType = Field(..., description="النوع الأساسي للقصة")
secondary_type: StoryType = Field(default=StoryType.NONE, description="النوع الثانوي للقصة")
characters: List[Character] = Field(default=[], description="الشخصيات في القصة")
interactive: bool = Field(default=True, description="هل القصة تفاعلية أم كاملة؟")
class ChoiceRequest(BaseModel):
"""Request to continue a story with a choice or custom text"""
story_id: str = Field(..., description="معرف القصة")
choice_id: Optional[int] = Field(None, description="معرف الاختيار الذي تم اختياره")
custom_text: Optional[str] = Field(None, description="النص المخصص الذي أدخله المستخدم")
class TTSRequest(BaseModel):
"""Request to generate text-to-speech for a story"""
story_id: str = Field(..., description="معرف القصة")
speed: float = Field(1.0, description="سرعة الصوت (0.5 للبطيء، 1.0 للعادي، 2.0 للسريع)", ge=0.5, le=2.0)
class EditRequest(BaseModel):
"""Request to edit a story based on user instructions"""
story_id: str = Field(..., description="معرف القصة")
edit_instructions: str = Field(..., description="تعليمات لتعديل القصة")
# ======== Response Models ========
class StoryChoice(BaseModel):
"""A choice option presented to the user"""
id: int = Field(..., description="معرف الاختيار")
text: str = Field(..., description="نص الاختيار")
class StoryParagraph(BaseModel):
"""A paragraph of story content with optional choices"""
content: str = Field(..., description="محتوى الفقرة")
choices: Optional[List[StoryChoice]] = Field(default=None, description="الاختيارات المتاحة بعد هذه الفقرة")
class StoryResponse(BaseModel):
"""Response containing story content and metadata"""
story_id: str = Field(..., description="معرف القصة")
paragraph: StoryParagraph = Field(..., description="فقرة من القصة")
is_complete: bool = Field(default=False, description="هل القصة اكتملت؟")
title: Optional[str] = Field(default=None, description="عنوان القصة (يتم إضافته عند اكتمال القصة)")
class CompleteStoryResponse(BaseModel):
"""Response containing a complete story generated without interaction"""
story_id: str = Field(..., description="معرف القصة")
paragraphs: List[str] = Field(..., description="فقرات القصة كاملة")
title: str = Field(..., description="عنوان القصة")
class TTSResponse(BaseModel):
"""Response containing URL to audio file"""
audio_url: str = Field(..., description="رابط ملف الصوت")
class EditResponse(BaseModel):
"""Response containing edited story content"""
success: bool = Field(default=True, description="نجاح عملية التعديل")
paragraphs: List[str] = Field(..., description="فقرات القصة المعدلة")
title: Optional[str] = Field(default=None, description="عنوان القصة المعدل (اختياري)") |