import datetime
import decimal
from marshmallow.fields import *
from servicestack import *
from typing import *
from dataclasses import dataclass, field
from dataclasses_json import dataclass_json, LetterCase, Undefined, config
from enum import Enum, IntEnum
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class QueryBase:
skip: Optional[int] = None
take: Optional[int] = None
order_by: Optional[str] = None
order_by_desc: Optional[str] = None
include: Optional[str] = None
fields: Optional[str] = None
meta: Optional[Dict[str, str]] = None
T = TypeVar('T')
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class QueryDb(Generic[T], QueryBase, IReturn[QueryResponse[T]]):
@staticmethod
def response_type(): return QueryResponse[T]
class ComfySampler(str, Enum):
EULER = 'euler'
EULER_CFG_PP = 'euler_cfg_pp'
EULER_ANCESTRAL = 'euler_ancestral'
EULER_ANCESTRAL_CFG_PP = 'euler_ancestral_cfg_pp'
HUEN = 'huen'
HUENPP2 = 'huenpp2'
DPM_2 = 'dpm_2'
DPM_2_ANCESTRAL = 'dpm_2_ancestral'
LMS = 'lms'
DPM_FAST = 'dpm_fast'
DPM_ADAPTIVE = 'dpm_adaptive'
DPMPP_2S_ANCESTRAL = 'dpmpp_2s_ancestral'
DPMPP_SDE = 'dpmpp_sde'
DPMPP_SDE_GPU = 'dpmpp_sde_gpu'
DPMPP_2M = 'dpmpp_2m'
DPMPP_2M_SDE = 'dpmpp_2m_sde'
DPMPP_2M_SDE_GPU = 'dpmpp_2m_sde_gpu'
DPMPP_3M_SDE = 'dpmpp_3m_sde'
DPMPP_3M_SDE_GPU = 'dpmpp_3m_sde_gpu'
DDPM = 'ddpm'
LCM = 'lcm'
DDIM = 'ddim'
UNI_PC = 'uni_pc'
UNI_PC_BH2 = 'uni_pc_bh2'
class ModelType(str, Enum):
TEXT_TO_IMAGE = 'TextToImage'
TEXT_ENCODER = 'TextEncoder'
IMAGE_UPSCALE = 'ImageUpscale'
TEXT_TO_SPEECH = 'TextToSpeech'
TEXT_TO_AUDIO = 'TextToAudio'
SPEECH_TO_TEXT = 'SpeechToText'
IMAGE_TO_TEXT = 'ImageToText'
IMAGE_TO_IMAGE = 'ImageToImage'
IMAGE_WITH_MASK = 'ImageWithMask'
VAE = 'VAE'
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ProviderModelDefaults:
id: Optional[str] = None
api_models: Dict[str, str] = field(default_factory=dict)
url: Optional[str] = None
quality: Optional[float] = None
aspect_ratio: Optional[str] = None
cfg_scale: Optional[float] = None
scheduler: Optional[str] = None
sampler: Optional[ComfySampler] = None
width: Optional[int] = None
height: Optional[int] = None
steps: Optional[int] = None
negative_prompt: Optional[str] = None
model_type: Optional[ModelType] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class QueryGenerationModelSettings(QueryDb[ProviderModelDefaults]):
id: Optional[str] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class AuditBase:
created_date: datetime.datetime = datetime.datetime(1, 1, 1)
# @Required()
created_by: Optional[str] = None
modified_date: datetime.datetime = datetime.datetime(1, 1, 1)
# @Required()
modified_by: Optional[str] = None
deleted_date: Optional[datetime.datetime] = None
deleted_by: Optional[str] = None
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Artifact(AuditBase):
id: int = 0
# @References(typeof(Creative))
creative_id: int = 0
file_name: Optional[str] = None
file_path: Optional[str] = None
content_type: Optional[str] = None
content_length: int = 0
width: int = 0
height: int = 0
seed: int = 0
prompt: Optional[str] = None
nsfw: Optional[bool] = None
average_hash: Optional[int] = None
perceptual_hash: Optional[int] = None
difference_hash: Optional[int] = None
background: Optional[str] = None
lqip: Optional[str] = None
quality: int = 0
likes_count: int = 0
albums_count: int = 0
downloads_count: int = 0
search_count: int = 0
temporal_score: int = 0
score: int = 0
rank: int = 0
ref_id: Optional[str] = None
versions: Dict[str, str] = field(default_factory=dict)
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class ArtifactResult(Artifact):
user_prompt: Optional[str] = None
artist_names: List[str] = field(default_factory=list)
modifier_names: List[str] = field(default_factory=list)
primary_artifact_id: Optional[int] = None
owner_ref: Optional[str] = None
similarity: Optional[float] = None
T = TypeVar('T')
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class QueryResponse(Generic[T]):
offset: int = 0
total: int = 0
results: Optional[List[ArtifactResult]] = None
meta: Optional[Dict[str, str]] = None
response_status: Optional[ResponseStatus] = None
Python QueryGenerationModelSettings DTOs
To override the Content-type in your clients, use the HTTP Accept Header, append the .csv suffix or ?format=csv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /csv/reply/QueryGenerationModelSettings HTTP/1.1
Host: blazordiffusion.com
Accept: text/csv
Content-Type: text/csv
Content-Length: length
{"id":"String","skip":0,"take":0,"orderBy":"String","orderByDesc":"String","include":"String","fields":"String","meta":{"String":"String"}}
HTTP/1.1 200 OK Content-Type: text/csv Content-Length: length {"offset":0,"total":0,"results":[{"id":"String","apiModels":{"String":"String"},"url":"String","quality":0,"aspectRatio":"String","cfgScale":0,"scheduler":"String","sampler":"euler","width":0,"height":0,"steps":0,"negativePrompt":"String","modelType":"TextToImage"}],"meta":{"String":"String"},"responseStatus":{"errorCode":"String","message":"String","stackTrace":"String","errors":[{"errorCode":"String","fieldName":"String","message":"String","meta":{"String":"String"}}],"meta":{"String":"String"}}}