chore(pydantic): migrate to v2 compatibility
Browse files- app/core/config.py +6 -2
- app/models/inference.py +3 -2
app/core/config.py
CHANGED
|
@@ -4,7 +4,7 @@ Configuration management for the FastAPI application.
|
|
| 4 |
|
| 5 |
import os
|
| 6 |
from typing import Optional
|
| 7 |
-
from
|
| 8 |
|
| 9 |
|
| 10 |
class Settings(BaseSettings):
|
|
@@ -44,10 +44,14 @@ class Settings(BaseSettings):
|
|
| 44 |
# Server Configuration
|
| 45 |
HOST: str = "0.0.0.0"
|
| 46 |
PORT: int = 7860 # HuggingFace Spaces standard
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
| 48 |
class Config:
|
| 49 |
env_file = ".env"
|
| 50 |
case_sensitive = True
|
|
|
|
| 51 |
|
| 52 |
|
| 53 |
# Global settings instance
|
|
|
|
| 4 |
|
| 5 |
import os
|
| 6 |
from typing import Optional
|
| 7 |
+
from pydantic_settings import BaseSettings
|
| 8 |
|
| 9 |
|
| 10 |
class Settings(BaseSettings):
|
|
|
|
| 44 |
# Server Configuration
|
| 45 |
HOST: str = "0.0.0.0"
|
| 46 |
PORT: int = 7860 # HuggingFace Spaces standard
|
| 47 |
+
|
| 48 |
+
# Development Configuration
|
| 49 |
+
DEBUG: bool = False
|
| 50 |
+
|
| 51 |
class Config:
|
| 52 |
env_file = ".env"
|
| 53 |
case_sensitive = True
|
| 54 |
+
extra = "ignore"
|
| 55 |
|
| 56 |
|
| 57 |
# Global settings instance
|
app/models/inference.py
CHANGED
|
@@ -3,7 +3,7 @@ Pydantic models for API requests and responses.
|
|
| 3 |
"""
|
| 4 |
|
| 5 |
from typing import List, Optional, Dict, Any
|
| 6 |
-
from pydantic import BaseModel, Field,
|
| 7 |
import base64
|
| 8 |
|
| 9 |
|
|
@@ -61,7 +61,8 @@ class InferenceRequest(BaseModel):
|
|
| 61 |
description="List of class IDs to filter (None for all classes)"
|
| 62 |
)
|
| 63 |
|
| 64 |
-
@
|
|
|
|
| 65 |
def validate_image(cls, v):
|
| 66 |
"""Validate base64 image data."""
|
| 67 |
try:
|
|
|
|
| 3 |
"""
|
| 4 |
|
| 5 |
from typing import List, Optional, Dict, Any
|
| 6 |
+
from pydantic import BaseModel, Field, field_validator
|
| 7 |
import base64
|
| 8 |
|
| 9 |
|
|
|
|
| 61 |
description="List of class IDs to filter (None for all classes)"
|
| 62 |
)
|
| 63 |
|
| 64 |
+
@field_validator('image')
|
| 65 |
+
@classmethod
|
| 66 |
def validate_image(cls, v):
|
| 67 |
"""Validate base64 image data."""
|
| 68 |
try:
|