File size: 3,641 Bytes
2e787a2
eb3e391
2e787a2
eb3e391
 
 
2e787a2
eca7f7a
a61ba58
 
2e787a2
a61ba58
 
 
2f568d8
 
a61ba58
eca7f7a
 
2e787a2
 
 
 
 
eca7f7a
 
a61ba58
eca7f7a
33d38e5
a61ba58
 
eb3e391
2e787a2
a61ba58
 
 
2e787a2
eb3e391
2e787a2
eb3e391
 
 
 
 
 
 
 
 
 
 
83003f5
 
 
 
 
 
 
 
 
a61ba58
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from pydantic import BaseModel, Field, validator
from typing import List, Optional
from core.constants import GameConfig

class Choice(BaseModel):
    id: int
    text: str = Field(description="The text of the choice.")

class StorySegmentResponse(BaseModel):
    story_text: str = Field(description="The story text. No more than 30 words.")

    @validator('story_text')
    def validate_story_text_length(cls, v):
        words = v.split()
        if len(words) > 50:
            raise ValueError('Story text must not exceed 50 words')
        return v

class StoryPromptsResponse(BaseModel):
    image_prompts: List[str] = Field(
        description="List of comic panel descriptions that illustrate the key moments of the scene. Use the word 'Sarah' only when referring to her.",
        min_items=GameConfig.MIN_PANELS,
        max_items=GameConfig.MAX_PANELS
    )

class StoryMetadataResponse(BaseModel):
    choices: List[str] = Field(description="List of choices for story progression")
    time: str = Field(description="Current in-game time in 24h format (HH:MM). Time passes realistically based on actions.")
    location: str = Field(description="Current location.")
    is_death: bool = Field(description="Whether this segment ends in Sarah's death", default=False)
    is_victory: bool = Field(description="Whether this segment ends in Sarah's victory", default=False)

    @validator('choices')
    def validate_choices(cls, v):
        if len(v) != 2:
            raise ValueError('Must have exactly 2 choices for story progression')
        return v

# Keep existing models unchanged for compatibility
class ChatMessage(BaseModel):
    message: str
    choice_id: Optional[int] = None

class ImageGenerationRequest(BaseModel):
    prompt: str
    width: int = Field(description="Width of the image to generate")
    height: int = Field(description="Height of the image to generate")

class TextToSpeechRequest(BaseModel):
    text: str
    voice_id: str = "nPczCjzI2devNBz1zQrb"  # Default voice ID (Rachel)

class UniverseResponse(BaseModel):
    status: str
    session_id: str
    style: str
    genre: str
    epoch: str
    base_story: str = Field(description="The generated story for this universe")
    macguffin: str = Field(description="The macguffin for this universe")


# Complete story response combining all parts - preserved for API compatibility
class StoryResponse(BaseModel):
    story_text: str = Field(description="The story text. No more than 15 words THIS IS MANDATORY.  Never mention story beat directly. ")
    choices: List[Choice]
    raw_choices: List[str] = Field(description="Raw choice texts from LLM before conversion to Choice objects")
    time: str = Field(description="Current in-game time in 24h format (HH:MM). Time passes realistically based on actions.")
    location: str = Field(description="Current location.")
    is_first_step: bool = Field(description="Whether this is the first step of the story", default=False)
    is_victory: bool = Field(description="Whether this segment ends in Sarah's victory", default=False)
    is_death: bool = Field(description="Whether this segment ends in Sarah's death", default=False)
    image_prompts: List[str] = Field(
        description="List of comic panel descriptions that illustrate the key moments of the scene. Use the word 'Sarah' only when referring to her.",
        min_items=GameConfig.MIN_PANELS,
        max_items=GameConfig.MAX_PANELS
    )

    @validator('choices')
    def validate_choices(cls, v):
        if len(v) != 2:
            raise ValueError('Must have exactly 2 choices for story progression')
        return v