Spaces:
Running
Running
fahmiaziz98
commited on
Commit
·
31bb4e3
1
Parent(s):
a23b910
[FIX ERROR]: validate model & input
Browse files
src/models/schemas/requests.py
CHANGED
|
@@ -40,12 +40,12 @@ class BaseEmbedRequest(BaseModel):
|
|
| 40 |
None, description="Optional embedding generation parameters"
|
| 41 |
)
|
| 42 |
|
| 43 |
-
@field_validator("
|
| 44 |
@classmethod
|
| 45 |
def validate_model_id(cls, v: str) -> str:
|
| 46 |
-
"""Validate that
|
| 47 |
if not v or not v.strip():
|
| 48 |
-
raise ValueError("
|
| 49 |
return v.strip()
|
| 50 |
|
| 51 |
model_config = ConfigDict(
|
|
@@ -60,9 +60,7 @@ class EmbedRequest(BaseEmbedRequest):
|
|
| 60 |
Used for /embeddings and /embed_sparse endpoint to process multiple texts at once.
|
| 61 |
|
| 62 |
Attributes:
|
| 63 |
-
|
| 64 |
-
model_id: Identifier of the model to use
|
| 65 |
-
prompt: Optional prompt for instruction-based models
|
| 66 |
"""
|
| 67 |
|
| 68 |
input: List[str] = Field(
|
|
@@ -71,7 +69,7 @@ class EmbedRequest(BaseEmbedRequest):
|
|
| 71 |
min_length=1,
|
| 72 |
)
|
| 73 |
|
| 74 |
-
@field_validator("
|
| 75 |
@classmethod
|
| 76 |
def validate_texts(cls, v: List[str]) -> List[str]:
|
| 77 |
"""Validate that all texts are non-empty."""
|
|
|
|
| 40 |
None, description="Optional embedding generation parameters"
|
| 41 |
)
|
| 42 |
|
| 43 |
+
@field_validator("model")
|
| 44 |
@classmethod
|
| 45 |
def validate_model_id(cls, v: str) -> str:
|
| 46 |
+
"""Validate that model is not empty."""
|
| 47 |
if not v or not v.strip():
|
| 48 |
+
raise ValueError("model cannot be empty")
|
| 49 |
return v.strip()
|
| 50 |
|
| 51 |
model_config = ConfigDict(
|
|
|
|
| 60 |
Used for /embeddings and /embed_sparse endpoint to process multiple texts at once.
|
| 61 |
|
| 62 |
Attributes:
|
| 63 |
+
input: List of input texts to embed
|
|
|
|
|
|
|
| 64 |
"""
|
| 65 |
|
| 66 |
input: List[str] = Field(
|
|
|
|
| 69 |
min_length=1,
|
| 70 |
)
|
| 71 |
|
| 72 |
+
@field_validator("input")
|
| 73 |
@classmethod
|
| 74 |
def validate_texts(cls, v: List[str]) -> List[str]:
|
| 75 |
"""Validate that all texts are non-empty."""
|