Blazor Diffusion

<back to all web services

QueryGenerationModelSettings

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 .xml suffix or ?format=xml

HTTP + XML

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /xml/reply/QueryGenerationModelSettings HTTP/1.1 
Host: blazordiffusion.com 
Accept: application/xml
Content-Type: application/xml
Content-Length: length

<QueryGenerationModelSettings xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/AiServer.ServiceModel">
  <Skip xmlns="http://schemas.servicestack.net/types">0</Skip>
  <Take xmlns="http://schemas.servicestack.net/types">0</Take>
  <OrderBy xmlns="http://schemas.servicestack.net/types">String</OrderBy>
  <OrderByDesc xmlns="http://schemas.servicestack.net/types">String</OrderByDesc>
  <Include xmlns="http://schemas.servicestack.net/types">String</Include>
  <Fields xmlns="http://schemas.servicestack.net/types">String</Fields>
  <Meta xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns="http://schemas.servicestack.net/types">
    <d2p1:KeyValueOfstringstring>
      <d2p1:Key>String</d2p1:Key>
      <d2p1:Value>String</d2p1:Value>
    </d2p1:KeyValueOfstringstring>
  </Meta>
  <Id>String</Id>
</QueryGenerationModelSettings>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<QueryResponseOfProviderModelDefaultsHzAs4VeO xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.servicestack.net/types">
  <Offset>0</Offset>
  <Total>0</Total>
  <Results xmlns:d2p1="http://schemas.datacontract.org/2004/07/AiServer.ServiceModel.Types">
    <d2p1:ProviderModelDefaults>
      <d2p1:ApiModels xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
        <d4p1:KeyValueOfstringstring>
          <d4p1:Key>String</d4p1:Key>
          <d4p1:Value>String</d4p1:Value>
        </d4p1:KeyValueOfstringstring>
      </d2p1:ApiModels>
      <d2p1:AspectRatio>String</d2p1:AspectRatio>
      <d2p1:CfgScale>0</d2p1:CfgScale>
      <d2p1:Height>0</d2p1:Height>
      <d2p1:Id>String</d2p1:Id>
      <d2p1:ModelType>TextToImage</d2p1:ModelType>
      <d2p1:NegativePrompt>String</d2p1:NegativePrompt>
      <d2p1:Quality>0</d2p1:Quality>
      <d2p1:Sampler>euler</d2p1:Sampler>
      <d2p1:Scheduler>String</d2p1:Scheduler>
      <d2p1:Steps>0</d2p1:Steps>
      <d2p1:Url>String</d2p1:Url>
      <d2p1:Width>0</d2p1:Width>
    </d2p1:ProviderModelDefaults>
  </Results>
  <Meta xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
    <d2p1:KeyValueOfstringstring>
      <d2p1:Key>String</d2p1:Key>
      <d2p1:Value>String</d2p1:Value>
    </d2p1:KeyValueOfstringstring>
  </Meta>
  <ResponseStatus>
    <ErrorCode>String</ErrorCode>
    <Message>String</Message>
    <StackTrace>String</StackTrace>
    <Errors>
      <ResponseError>
        <ErrorCode>String</ErrorCode>
        <FieldName>String</FieldName>
        <Message>String</Message>
        <Meta xmlns:d5p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
          <d5p1:KeyValueOfstringstring>
            <d5p1:Key>String</d5p1:Key>
            <d5p1:Value>String</d5p1:Value>
          </d5p1:KeyValueOfstringstring>
        </Meta>
      </ResponseError>
    </Errors>
    <Meta xmlns:d3p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
      <d3p1:KeyValueOfstringstring>
        <d3p1:Key>String</d3p1:Key>
        <d3p1:Value>String</d3p1:Value>
      </d3p1:KeyValueOfstringstring>
    </Meta>
  </ResponseStatus>
</QueryResponseOfProviderModelDefaultsHzAs4VeO>