Spaces:
Running
Running
Commit
·
c346d0a
1
Parent(s):
b13f641
Refactor GenerateRequest model; remove field aliases for emotional_tone, creative_style, language_variety, and word_repetition, and update validation error messages to match new field names
Browse files
main.py
CHANGED
|
@@ -110,30 +110,31 @@ class StyleMapper:
|
|
| 110 |
class GenerateRequest(BaseModel):
|
| 111 |
prompt: str
|
| 112 |
style: PoemStyle
|
| 113 |
-
emotional_tone: EmotionalTone
|
| 114 |
-
creative_style: float = Field(ge=0, le=100
|
| 115 |
-
language_variety: float = Field(ge=0, le=1
|
| 116 |
length: Length
|
| 117 |
-
word_repetition: float = Field(ge=1, le=2
|
| 118 |
|
| 119 |
@validator('creative_style')
|
| 120 |
def validate_creative_style(cls, v):
|
| 121 |
if not 0 <= v <= 100:
|
| 122 |
-
raise ValueError('
|
| 123 |
return v
|
| 124 |
|
| 125 |
@validator('language_variety')
|
| 126 |
def validate_language_variety(cls, v):
|
| 127 |
if not 0 <= v <= 1:
|
| 128 |
-
raise ValueError('
|
| 129 |
return v
|
| 130 |
|
| 131 |
@validator('word_repetition')
|
| 132 |
def validate_word_repetition(cls, v):
|
| 133 |
if not 1 <= v <= 2:
|
| 134 |
-
raise ValueError('
|
| 135 |
return v
|
| 136 |
|
|
|
|
| 137 |
class Config:
|
| 138 |
allow_population_by_field_name = True
|
| 139 |
|
|
@@ -276,11 +277,11 @@ class ModelManager:
|
|
| 276 |
# Get style configuration
|
| 277 |
style_config = StyleMapper.get_style_config(
|
| 278 |
request.style,
|
| 279 |
-
request.
|
| 280 |
-
request.
|
| 281 |
-
request.
|
| 282 |
request.length,
|
| 283 |
-
request.
|
| 284 |
)
|
| 285 |
|
| 286 |
try:
|
|
|
|
| 110 |
class GenerateRequest(BaseModel):
|
| 111 |
prompt: str
|
| 112 |
style: PoemStyle
|
| 113 |
+
emotional_tone: EmotionalTone # Use 'emotional_tone' directly
|
| 114 |
+
creative_style: float = Field(ge=0, le=100) # 0-100 slider
|
| 115 |
+
language_variety: float = Field(ge=0, le=1) # 0-1 slider
|
| 116 |
length: Length
|
| 117 |
+
word_repetition: float = Field(ge=1, le=2) # 1-2 slider
|
| 118 |
|
| 119 |
@validator('creative_style')
|
| 120 |
def validate_creative_style(cls, v):
|
| 121 |
if not 0 <= v <= 100:
|
| 122 |
+
raise ValueError('creative_style must be between 0 and 100')
|
| 123 |
return v
|
| 124 |
|
| 125 |
@validator('language_variety')
|
| 126 |
def validate_language_variety(cls, v):
|
| 127 |
if not 0 <= v <= 1:
|
| 128 |
+
raise ValueError('language_variety must be between 0 and 1')
|
| 129 |
return v
|
| 130 |
|
| 131 |
@validator('word_repetition')
|
| 132 |
def validate_word_repetition(cls, v):
|
| 133 |
if not 1 <= v <= 2:
|
| 134 |
+
raise ValueError('word_repetition must be between 1 and 2')
|
| 135 |
return v
|
| 136 |
|
| 137 |
+
|
| 138 |
class Config:
|
| 139 |
allow_population_by_field_name = True
|
| 140 |
|
|
|
|
| 277 |
# Get style configuration
|
| 278 |
style_config = StyleMapper.get_style_config(
|
| 279 |
request.style,
|
| 280 |
+
request.emotional_tone,
|
| 281 |
+
request.creative_style,
|
| 282 |
+
request.language_variety,
|
| 283 |
request.length,
|
| 284 |
+
request.word_repetition
|
| 285 |
)
|
| 286 |
|
| 287 |
try:
|