Create libs/ai-services/ with FastAPI app providing: - POST /avm/predict — XGBoost-backed property price prediction (heuristic fallback) - POST /avm/extract-features — Vietnamese NLP feature extraction from listing text - POST /moderation/check — content moderation with rule-based flagging - GET /health — health check endpoint Includes Dockerfile (Python 3.12), docker-compose integration, Pydantic models, and 9 passing tests covering all endpoints. Co-Authored-By: Paperclip <noreply@paperclip.ing>
21 lines
689 B
Python
21 lines
689 B
Python
from pydantic import BaseModel, Field
|
|
|
|
|
|
class ModerationRequest(BaseModel):
|
|
text: str = Field(..., min_length=1, description="Text content to moderate")
|
|
context: str = Field("listing", description="Context: listing, comment, profile")
|
|
|
|
|
|
class ModerationFlag(BaseModel):
|
|
category: str
|
|
severity: str = Field(..., description="low, medium, high")
|
|
matched_text: str
|
|
reason: str
|
|
|
|
|
|
class ModerationResponse(BaseModel):
|
|
is_flagged: bool
|
|
score: float = Field(..., ge=0, le=1, description="Overall risk score")
|
|
flags: list[ModerationFlag] = Field(default_factory=list)
|
|
cleaned_text: str | None = Field(None, description="Text with flagged content redacted")
|