safe-content-ai/models.py
Amir Boroumand 4ce040a5b2
Image url support (#3)
* Update main.py

* Update ci.yml

* Update README.md

* Update requirements.txt

* Create models.py

* Update main.py

* Update test_main.py

* Update README.md

* Update models.py

* Update test_main.py

* Update main.py

* Update main.py

* Update models.py

* Update main.py
2024-05-31 17:12:37 -04:00

50 lines
1.1 KiB
Python

"""Module providing base models."""
from pydantic import BaseModel
class ImageUrlsRequest(BaseModel):
"""
Model representing the request body for the /v1/detect/urls endpoint.
Attributes:
urls (list[str]): List of image URLs to be processed.
"""
urls: list[str]
class ImageDetectionResponse(BaseModel):
"""
Base model representing the response body for image detection.
Attributes:
is_nsfw (bool): Whether the image is classified as NSFW.
confidence_percentage (float): Confidence level of the NSFW classification.
"""
is_nsfw: bool
confidence_percentage: float
class FileImageDetectionResponse(ImageDetectionResponse):
"""
Model extending ImageDetectionResponse with a file attribute.
Attributes:
file (str): The name of the file that was processed.
"""
file_name: str
class UrlImageDetectionResponse(ImageDetectionResponse):
"""
Model extending ImageDetectionResponse with a URL attribute.
Attributes:
url (str): The URL of the image that was processed.
"""
url: str