feat(ai-services): add Python FastAPI AI/ML services container
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>
This commit is contained in:
20
libs/ai-services/app/models/moderation.py
Normal file
20
libs/ai-services/app/models/moderation.py
Normal file
@@ -0,0 +1,20 @@
|
||||
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")
|
||||
Reference in New Issue
Block a user