worker

package
v0.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2024 License: MIT Imports: 35 Imported by: 4

Documentation

Overview

Package worker's module provides multipart form data utilities.

This module extends oapi-codegen Go bindings with multipart writers, enabling request parameter encoding for inter-node communication (gateway, orchestrator, runner).

Package worker provides primitives to interact with the openapi HTTP API.

Code generated by github.com/deepmap/oapi-codegen/v2 version v2.2.0 DO NOT EDIT.

Index

Constants

View Source
const (
	HTTPBearerScopes = "HTTPBearer.Scopes"
)

Variables

This section is empty.

Functions

func GetSwagger

func GetSwagger() (swagger *openapi3.T, err error)

GetSwagger returns the Swagger specification corresponding to the generated code in this file. The external references of Swagger specification are resolved. The logic of resolving external references is tightly connected to "import-mapping" feature. Externally referenced files must be embedded in the corresponding golang packages. Urls can be supported but this task was out of the scope.

func Handler

func Handler(si ServerInterface) http.Handler

Handler creates http.Handler with routing matching OpenAPI spec.

func HandlerFromMux

func HandlerFromMux(si ServerInterface, r chi.Router) http.Handler

HandlerFromMux creates http.Handler with routing matching OpenAPI spec based on the provided mux.

func HandlerFromMuxWithBaseURL

func HandlerFromMuxWithBaseURL(si ServerInterface, r chi.Router, baseURL string) http.Handler

func HandlerWithOptions

func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handler

HandlerWithOptions creates http.Handler with additional options

func NewAudioToTextMultipartWriter

func NewAudioToTextMultipartWriter(w io.Writer, req AudioToTextMultipartRequestBody) (*multipart.Writer, error)

func NewAudioToTextRequestWithBody

func NewAudioToTextRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error)

NewAudioToTextRequestWithBody generates requests for AudioToText with any type of body

func NewHealthRequest

func NewHealthRequest(server string) (*http.Request, error)

NewHealthRequest generates requests for Health

func NewImageToImageMultipartWriter

func NewImageToImageMultipartWriter(w io.Writer, req ImageToImageMultipartRequestBody) (*multipart.Writer, error)

func NewImageToImageRequestWithBody

func NewImageToImageRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error)

NewImageToImageRequestWithBody generates requests for ImageToImage with any type of body

func NewImageToVideoMultipartWriter

func NewImageToVideoMultipartWriter(w io.Writer, req ImageToVideoMultipartRequestBody) (*multipart.Writer, error)

func NewImageToVideoRequestWithBody

func NewImageToVideoRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error)

NewImageToVideoRequestWithBody generates requests for ImageToVideo with any type of body

func NewTextToImageRequest

func NewTextToImageRequest(server string, body TextToImageJSONRequestBody) (*http.Request, error)

NewTextToImageRequest calls the generic TextToImage builder with application/json body

func NewTextToImageRequestWithBody

func NewTextToImageRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error)

NewTextToImageRequestWithBody generates requests for TextToImage with any type of body

func NewUpscaleMultipartWriter

func NewUpscaleMultipartWriter(w io.Writer, req UpscaleMultipartRequestBody) (*multipart.Writer, error)

func NewUpscaleRequestWithBody

func NewUpscaleRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error)

NewUpscaleRequestWithBody generates requests for Upscale with any type of body

func PathToRawSpec

func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error)

Constructs a synthetic filesystem for resolving external references when loading openapi specifications.

func ReadImageB64DataUrl

func ReadImageB64DataUrl(url string, w io.Writer) error

func SaveImageB64DataUrl

func SaveImageB64DataUrl(url, outputPath string) error

Types

type APIError

type APIError struct {
	Msg string `json:"msg"`
}

APIError defines model for APIError.

type AudioToTextMultipartRequestBody

type AudioToTextMultipartRequestBody = BodyAudioToTextAudioToTextPost

AudioToTextMultipartRequestBody defines body for AudioToText for multipart/form-data ContentType.

type AudioToTextResponse

type AudioToTextResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *TextResponse
	JSON400      *HTTPError
	JSON401      *HTTPError
	JSON413      *HTTPError
	JSON422      *HTTPValidationError
	JSON500      *HTTPError
}

func ParseAudioToTextResponse

func ParseAudioToTextResponse(rsp *http.Response) (*AudioToTextResponse, error)

ParseAudioToTextResponse parses an HTTP response from a AudioToTextWithResponse call

func (AudioToTextResponse) Status

func (r AudioToTextResponse) Status() string

Status returns HTTPResponse.Status

func (AudioToTextResponse) StatusCode

func (r AudioToTextResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type BodyAudioToTextAudioToTextPost

type BodyAudioToTextAudioToTextPost struct {
	Audio   openapi_types.File `json:"audio"`
	ModelId *string            `json:"model_id,omitempty"`
}

BodyAudioToTextAudioToTextPost defines model for Body_audio_to_text_audio_to_text_post.

type BodyImageToImageImageToImagePost

type BodyImageToImageImageToImagePost struct {
	GuidanceScale      *float32           `json:"guidance_scale,omitempty"`
	Image              openapi_types.File `json:"image"`
	ImageGuidanceScale *float32           `json:"image_guidance_scale,omitempty"`
	ModelId            *string            `json:"model_id,omitempty"`
	NegativePrompt     *string            `json:"negative_prompt,omitempty"`
	NumImagesPerPrompt *int               `json:"num_images_per_prompt,omitempty"`
	NumInferenceSteps  *int               `json:"num_inference_steps,omitempty"`
	Prompt             string             `json:"prompt"`
	SafetyCheck        *bool              `json:"safety_check,omitempty"`
	Seed               *int               `json:"seed,omitempty"`
	Strength           *float32           `json:"strength,omitempty"`
}

BodyImageToImageImageToImagePost defines model for Body_image_to_image_image_to_image_post.

type BodyImageToVideoImageToVideoPost

type BodyImageToVideoImageToVideoPost struct {
	Fps               *int               `json:"fps,omitempty"`
	Height            *int               `json:"height,omitempty"`
	Image             openapi_types.File `json:"image"`
	ModelId           *string            `json:"model_id,omitempty"`
	MotionBucketId    *int               `json:"motion_bucket_id,omitempty"`
	NoiseAugStrength  *float32           `json:"noise_aug_strength,omitempty"`
	NumInferenceSteps *int               `json:"num_inference_steps,omitempty"`
	SafetyCheck       *bool              `json:"safety_check,omitempty"`
	Seed              *int               `json:"seed,omitempty"`
	Width             *int               `json:"width,omitempty"`
}

BodyImageToVideoImageToVideoPost defines model for Body_image_to_video_image_to_video_post.

type BodyUpscaleUpscalePost

type BodyUpscaleUpscalePost struct {
	Image             openapi_types.File `json:"image"`
	ModelId           *string            `json:"model_id,omitempty"`
	NumInferenceSteps *int               `json:"num_inference_steps,omitempty"`
	Prompt            string             `json:"prompt"`
	SafetyCheck       *bool              `json:"safety_check,omitempty"`
	Seed              *int               `json:"seed,omitempty"`
}

BodyUpscaleUpscalePost defines model for Body_upscale_upscale_post.

type ChiServerOptions

type ChiServerOptions struct {
	BaseURL          string
	BaseRouter       chi.Router
	Middlewares      []MiddlewareFunc
	ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
}

type Chunk

type Chunk struct {
	Text      string        `json:"text"`
	Timestamp []interface{} `json:"timestamp"`
}

Chunk defines model for chunk.

type Client

type Client struct {
	// The endpoint of the server conforming to this interface, with scheme,
	// https://api.deepmap.com for example. This can contain a path relative
	// to the server, such as https://api.deepmap.com/dev-test, and all the
	// paths in the swagger spec will be appended to the server.
	Server string

	// Doer for performing requests, typically a *http.Client with any
	// customized settings, such as certificate chains.
	Client HttpRequestDoer

	// A list of callbacks for modifying requests which are generated before sending over
	// the network.
	RequestEditors []RequestEditorFn
}

Client which conforms to the OpenAPI3 specification for this service.

func NewClient

func NewClient(server string, opts ...ClientOption) (*Client, error)

Creates a new Client, with reasonable defaults

func (*Client) AudioToTextWithBody

func (c *Client) AudioToTextWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) Health

func (c *Client) Health(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) ImageToImageWithBody

func (c *Client) ImageToImageWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) ImageToVideoWithBody

func (c *Client) ImageToVideoWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) TextToImage

func (c *Client) TextToImage(ctx context.Context, body TextToImageJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) TextToImageWithBody

func (c *Client) TextToImageWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

func (*Client) UpscaleWithBody

func (c *Client) UpscaleWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

type ClientInterface

type ClientInterface interface {
	// AudioToTextWithBody request with any body
	AudioToTextWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

	// Health request
	Health(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)

	// ImageToImageWithBody request with any body
	ImageToImageWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

	// ImageToVideoWithBody request with any body
	ImageToVideoWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

	// TextToImageWithBody request with any body
	TextToImageWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)

	TextToImage(ctx context.Context, body TextToImageJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)

	// UpscaleWithBody request with any body
	UpscaleWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
}

The interface specification for the client above.

type ClientOption

type ClientOption func(*Client) error

ClientOption allows setting custom parameters during construction

func WithBaseURL

func WithBaseURL(baseURL string) ClientOption

WithBaseURL overrides the baseURL.

func WithHTTPClient

func WithHTTPClient(doer HttpRequestDoer) ClientOption

WithHTTPClient allows overriding the default Doer, which is automatically created using http.Client. This is useful for tests.

func WithRequestEditorFn

func WithRequestEditorFn(fn RequestEditorFn) ClientOption

WithRequestEditorFn allows setting up a callback function, which will be called right before sending the request. This can be used to mutate the request.

type ClientWithResponses

type ClientWithResponses struct {
	ClientInterface
}

ClientWithResponses builds on ClientInterface to offer response payloads

func NewClientWithResponses

func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error)

NewClientWithResponses creates a new ClientWithResponses, which wraps Client with return type handling

func (*ClientWithResponses) AudioToTextWithBodyWithResponse

func (c *ClientWithResponses) AudioToTextWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AudioToTextResponse, error)

AudioToTextWithBodyWithResponse request with arbitrary body returning *AudioToTextResponse

func (*ClientWithResponses) HealthWithResponse

func (c *ClientWithResponses) HealthWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*HealthResponse, error)

HealthWithResponse request returning *HealthResponse

func (*ClientWithResponses) ImageToImageWithBodyWithResponse

func (c *ClientWithResponses) ImageToImageWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ImageToImageResponse, error)

ImageToImageWithBodyWithResponse request with arbitrary body returning *ImageToImageResponse

func (*ClientWithResponses) ImageToVideoWithBodyWithResponse

func (c *ClientWithResponses) ImageToVideoWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ImageToVideoResponse, error)

ImageToVideoWithBodyWithResponse request with arbitrary body returning *ImageToVideoResponse

func (*ClientWithResponses) TextToImageWithBodyWithResponse

func (c *ClientWithResponses) TextToImageWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*TextToImageResponse, error)

TextToImageWithBodyWithResponse request with arbitrary body returning *TextToImageResponse

func (*ClientWithResponses) TextToImageWithResponse

func (c *ClientWithResponses) TextToImageWithResponse(ctx context.Context, body TextToImageJSONRequestBody, reqEditors ...RequestEditorFn) (*TextToImageResponse, error)

func (*ClientWithResponses) UpscaleWithBodyWithResponse

func (c *ClientWithResponses) UpscaleWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpscaleResponse, error)

UpscaleWithBodyWithResponse request with arbitrary body returning *UpscaleResponse

type ClientWithResponsesInterface

type ClientWithResponsesInterface interface {
	// AudioToTextWithBodyWithResponse request with any body
	AudioToTextWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AudioToTextResponse, error)

	// HealthWithResponse request
	HealthWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*HealthResponse, error)

	// ImageToImageWithBodyWithResponse request with any body
	ImageToImageWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ImageToImageResponse, error)

	// ImageToVideoWithBodyWithResponse request with any body
	ImageToVideoWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ImageToVideoResponse, error)

	// TextToImageWithBodyWithResponse request with any body
	TextToImageWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*TextToImageResponse, error)

	TextToImageWithResponse(ctx context.Context, body TextToImageJSONRequestBody, reqEditors ...RequestEditorFn) (*TextToImageResponse, error)

	// UpscaleWithBodyWithResponse request with any body
	UpscaleWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpscaleResponse, error)
}

ClientWithResponsesInterface is the interface specification for the client with responses above.

type DockerManager

type DockerManager struct {
	// contains filtered or unexported fields
}

func NewDockerManager

func NewDockerManager(containerImageID string, gpus []string, modelDir string) (*DockerManager, error)

func (*DockerManager) Borrow

func (m *DockerManager) Borrow(ctx context.Context, pipeline, modelID string) (*RunnerContainer, error)

func (*DockerManager) HasCapacity

func (m *DockerManager) HasCapacity(ctx context.Context, pipeline, modelID string) bool

HasCapacity checks if an unused managed container exists or if a GPU is available for a new container.

func (*DockerManager) Return

func (m *DockerManager) Return(rc *RunnerContainer)

func (*DockerManager) Stop

func (m *DockerManager) Stop(ctx context.Context) error

func (*DockerManager) Warm

func (m *DockerManager) Warm(ctx context.Context, pipeline string, modelID string, optimizationFlags OptimizationFlags) error

type EnvValue

type EnvValue string

EnvValue unmarshals JSON booleans as strings for compatibility with env variables.

func (EnvValue) String

func (sb EnvValue) String() string

String returns the string representation of the EnvValue.

func (*EnvValue) UnmarshalJSON

func (sb *EnvValue) UnmarshalJSON(b []byte) error

UnmarshalJSON converts JSON booleans to strings for EnvValue.

type HTTPError

type HTTPError struct {
	Detail APIError `json:"detail"`
}

HTTPError defines model for HTTPError.

type HTTPValidationError

type HTTPValidationError struct {
	Detail *[]ValidationError `json:"detail,omitempty"`
}

HTTPValidationError defines model for HTTPValidationError.

type HealthCheck

type HealthCheck struct {
	Status *string `json:"status,omitempty"`
}

HealthCheck defines model for HealthCheck.

type HealthResponse

type HealthResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *HealthCheck
}

func ParseHealthResponse

func ParseHealthResponse(rsp *http.Response) (*HealthResponse, error)

ParseHealthResponse parses an HTTP response from a HealthWithResponse call

func (HealthResponse) Status

func (r HealthResponse) Status() string

Status returns HTTPResponse.Status

func (HealthResponse) StatusCode

func (r HealthResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type HttpRequestDoer

type HttpRequestDoer interface {
	Do(req *http.Request) (*http.Response, error)
}

Doer performs HTTP requests.

The standard http.Client implements this interface.

type ImageResponse

type ImageResponse struct {
	Images []Media `json:"images"`
}

ImageResponse defines model for ImageResponse.

type ImageToImageMultipartRequestBody

type ImageToImageMultipartRequestBody = BodyImageToImageImageToImagePost

ImageToImageMultipartRequestBody defines body for ImageToImage for multipart/form-data ContentType.

type ImageToImageResponse

type ImageToImageResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *ImageResponse
	JSON400      *HTTPError
	JSON401      *HTTPError
	JSON422      *HTTPValidationError
	JSON500      *HTTPError
}

func ParseImageToImageResponse

func ParseImageToImageResponse(rsp *http.Response) (*ImageToImageResponse, error)

ParseImageToImageResponse parses an HTTP response from a ImageToImageWithResponse call

func (ImageToImageResponse) Status

func (r ImageToImageResponse) Status() string

Status returns HTTPResponse.Status

func (ImageToImageResponse) StatusCode

func (r ImageToImageResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type ImageToVideoMultipartRequestBody

type ImageToVideoMultipartRequestBody = BodyImageToVideoImageToVideoPost

ImageToVideoMultipartRequestBody defines body for ImageToVideo for multipart/form-data ContentType.

type ImageToVideoResponse

type ImageToVideoResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *VideoResponse
	JSON400      *HTTPError
	JSON401      *HTTPError
	JSON422      *HTTPValidationError
	JSON500      *HTTPError
}

func ParseImageToVideoResponse

func ParseImageToVideoResponse(rsp *http.Response) (*ImageToVideoResponse, error)

ParseImageToVideoResponse parses an HTTP response from a ImageToVideoWithResponse call

func (ImageToVideoResponse) Status

func (r ImageToVideoResponse) Status() string

Status returns HTTPResponse.Status

func (ImageToVideoResponse) StatusCode

func (r ImageToVideoResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type InvalidParamFormatError

type InvalidParamFormatError struct {
	ParamName string
	Err       error
}

func (*InvalidParamFormatError) Error

func (e *InvalidParamFormatError) Error() string

func (*InvalidParamFormatError) Unwrap

func (e *InvalidParamFormatError) Unwrap() error

type Media

type Media struct {
	Nsfw bool   `json:"nsfw"`
	Seed int    `json:"seed"`
	Url  string `json:"url"`
}

Media defines model for Media.

type MiddlewareFunc

type MiddlewareFunc func(http.Handler) http.Handler

type OptimizationFlags

type OptimizationFlags map[string]EnvValue

OptimizationFlags is a map of optimization flags to be passed to the pipeline.

type RequestEditorFn

type RequestEditorFn func(ctx context.Context, req *http.Request) error

RequestEditorFn is the function signature for the RequestEditor callback function

type RequiredHeaderError

type RequiredHeaderError struct {
	ParamName string
	Err       error
}

func (*RequiredHeaderError) Error

func (e *RequiredHeaderError) Error() string

func (*RequiredHeaderError) Unwrap

func (e *RequiredHeaderError) Unwrap() error

type RequiredParamError

type RequiredParamError struct {
	ParamName string
}

func (*RequiredParamError) Error

func (e *RequiredParamError) Error() string

type RunnerContainer

type RunnerContainer struct {
	RunnerContainerConfig

	Client *ClientWithResponses
}

func NewRunnerContainer

func NewRunnerContainer(ctx context.Context, cfg RunnerContainerConfig) (*RunnerContainer, error)

type RunnerContainerConfig

type RunnerContainerConfig struct {
	Type     RunnerContainerType
	Pipeline string
	ModelID  string
	Endpoint RunnerEndpoint

	// For managed containers only
	ID       string
	GPU      string
	KeepWarm bool
	// contains filtered or unexported fields
}

type RunnerContainerType

type RunnerContainerType int
const (
	Managed RunnerContainerType = iota
	External
)

type RunnerEndpoint

type RunnerEndpoint struct {
	URL   string
	Token string
}

type ServerInterface

type ServerInterface interface {
	// Audio To Text
	// (POST /audio-to-text)
	AudioToText(w http.ResponseWriter, r *http.Request)
	// Health
	// (GET /health)
	Health(w http.ResponseWriter, r *http.Request)
	// Image To Image
	// (POST /image-to-image)
	ImageToImage(w http.ResponseWriter, r *http.Request)
	// Image To Video
	// (POST /image-to-video)
	ImageToVideo(w http.ResponseWriter, r *http.Request)
	// Text To Image
	// (POST /text-to-image)
	TextToImage(w http.ResponseWriter, r *http.Request)
	// Upscale
	// (POST /upscale)
	Upscale(w http.ResponseWriter, r *http.Request)
}

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler            ServerInterface
	HandlerMiddlewares []MiddlewareFunc
	ErrorHandlerFunc   func(w http.ResponseWriter, r *http.Request, err error)
}

ServerInterfaceWrapper converts contexts to parameters.

func (*ServerInterfaceWrapper) AudioToText

func (siw *ServerInterfaceWrapper) AudioToText(w http.ResponseWriter, r *http.Request)

AudioToText operation middleware

func (*ServerInterfaceWrapper) Health

Health operation middleware

func (*ServerInterfaceWrapper) ImageToImage

func (siw *ServerInterfaceWrapper) ImageToImage(w http.ResponseWriter, r *http.Request)

ImageToImage operation middleware

func (*ServerInterfaceWrapper) ImageToVideo

func (siw *ServerInterfaceWrapper) ImageToVideo(w http.ResponseWriter, r *http.Request)

ImageToVideo operation middleware

func (*ServerInterfaceWrapper) TextToImage

func (siw *ServerInterfaceWrapper) TextToImage(w http.ResponseWriter, r *http.Request)

TextToImage operation middleware

func (*ServerInterfaceWrapper) Upscale

Upscale operation middleware

type TextResponse

type TextResponse struct {
	Chunks []Chunk `json:"chunks"`
	Text   string  `json:"text"`
}

TextResponse defines model for TextResponse.

type TextToImageJSONRequestBody

type TextToImageJSONRequestBody = TextToImageParams

TextToImageJSONRequestBody defines body for TextToImage for application/json ContentType.

type TextToImageParams

type TextToImageParams struct {
	GuidanceScale      *float32 `json:"guidance_scale,omitempty"`
	Height             *int     `json:"height,omitempty"`
	ModelId            *string  `json:"model_id,omitempty"`
	NegativePrompt     *string  `json:"negative_prompt,omitempty"`
	NumImagesPerPrompt *int     `json:"num_images_per_prompt,omitempty"`
	NumInferenceSteps  *int     `json:"num_inference_steps,omitempty"`
	Prompt             string   `json:"prompt"`
	SafetyCheck        *bool    `json:"safety_check,omitempty"`
	Seed               *int     `json:"seed,omitempty"`
	Width              *int     `json:"width,omitempty"`
}

TextToImageParams defines model for TextToImageParams.

type TextToImageResponse

type TextToImageResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *ImageResponse
	JSON400      *HTTPError
	JSON401      *HTTPError
	JSON422      *HTTPValidationError
	JSON500      *HTTPError
}

func ParseTextToImageResponse

func ParseTextToImageResponse(rsp *http.Response) (*TextToImageResponse, error)

ParseTextToImageResponse parses an HTTP response from a TextToImageWithResponse call

func (TextToImageResponse) Status

func (r TextToImageResponse) Status() string

Status returns HTTPResponse.Status

func (TextToImageResponse) StatusCode

func (r TextToImageResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type TooManyValuesForParamError

type TooManyValuesForParamError struct {
	ParamName string
	Count     int
}

func (*TooManyValuesForParamError) Error

type UnescapedCookieParamError

type UnescapedCookieParamError struct {
	ParamName string
	Err       error
}

func (*UnescapedCookieParamError) Error

func (e *UnescapedCookieParamError) Error() string

func (*UnescapedCookieParamError) Unwrap

func (e *UnescapedCookieParamError) Unwrap() error

type Unimplemented

type Unimplemented struct{}

func (Unimplemented) AudioToText

func (_ Unimplemented) AudioToText(w http.ResponseWriter, r *http.Request)

Audio To Text (POST /audio-to-text)

func (Unimplemented) Health

func (_ Unimplemented) Health(w http.ResponseWriter, r *http.Request)

Health (GET /health)

func (Unimplemented) ImageToImage

func (_ Unimplemented) ImageToImage(w http.ResponseWriter, r *http.Request)

Image To Image (POST /image-to-image)

func (Unimplemented) ImageToVideo

func (_ Unimplemented) ImageToVideo(w http.ResponseWriter, r *http.Request)

Image To Video (POST /image-to-video)

func (Unimplemented) TextToImage

func (_ Unimplemented) TextToImage(w http.ResponseWriter, r *http.Request)

Text To Image (POST /text-to-image)

func (Unimplemented) Upscale

func (_ Unimplemented) Upscale(w http.ResponseWriter, r *http.Request)

Upscale (POST /upscale)

type UnmarshalingParamError

type UnmarshalingParamError struct {
	ParamName string
	Err       error
}

func (*UnmarshalingParamError) Error

func (e *UnmarshalingParamError) Error() string

func (*UnmarshalingParamError) Unwrap

func (e *UnmarshalingParamError) Unwrap() error

type UpscaleMultipartRequestBody

type UpscaleMultipartRequestBody = BodyUpscaleUpscalePost

UpscaleMultipartRequestBody defines body for Upscale for multipart/form-data ContentType.

type UpscaleResponse

type UpscaleResponse struct {
	Body         []byte
	HTTPResponse *http.Response
	JSON200      *ImageResponse
	JSON400      *HTTPError
	JSON401      *HTTPError
	JSON422      *HTTPValidationError
	JSON500      *HTTPError
}

func ParseUpscaleResponse

func ParseUpscaleResponse(rsp *http.Response) (*UpscaleResponse, error)

ParseUpscaleResponse parses an HTTP response from a UpscaleWithResponse call

func (UpscaleResponse) Status

func (r UpscaleResponse) Status() string

Status returns HTTPResponse.Status

func (UpscaleResponse) StatusCode

func (r UpscaleResponse) StatusCode() int

StatusCode returns HTTPResponse.StatusCode

type ValidationError

type ValidationError struct {
	Loc  []ValidationError_Loc_Item `json:"loc"`
	Msg  string                     `json:"msg"`
	Type string                     `json:"type"`
}

ValidationError defines model for ValidationError.

type ValidationErrorLoc0

type ValidationErrorLoc0 = string

ValidationErrorLoc0 defines model for .

type ValidationErrorLoc1

type ValidationErrorLoc1 = int

ValidationErrorLoc1 defines model for .

type ValidationError_Loc_Item

type ValidationError_Loc_Item struct {
	// contains filtered or unexported fields
}

ValidationError_Loc_Item defines model for ValidationError.loc.Item.

func (ValidationError_Loc_Item) AsValidationErrorLoc0

func (t ValidationError_Loc_Item) AsValidationErrorLoc0() (ValidationErrorLoc0, error)

AsValidationErrorLoc0 returns the union data inside the ValidationError_Loc_Item as a ValidationErrorLoc0

func (ValidationError_Loc_Item) AsValidationErrorLoc1

func (t ValidationError_Loc_Item) AsValidationErrorLoc1() (ValidationErrorLoc1, error)

AsValidationErrorLoc1 returns the union data inside the ValidationError_Loc_Item as a ValidationErrorLoc1

func (*ValidationError_Loc_Item) FromValidationErrorLoc0

func (t *ValidationError_Loc_Item) FromValidationErrorLoc0(v ValidationErrorLoc0) error

FromValidationErrorLoc0 overwrites any union data inside the ValidationError_Loc_Item as the provided ValidationErrorLoc0

func (*ValidationError_Loc_Item) FromValidationErrorLoc1

func (t *ValidationError_Loc_Item) FromValidationErrorLoc1(v ValidationErrorLoc1) error

FromValidationErrorLoc1 overwrites any union data inside the ValidationError_Loc_Item as the provided ValidationErrorLoc1

func (ValidationError_Loc_Item) MarshalJSON

func (t ValidationError_Loc_Item) MarshalJSON() ([]byte, error)

func (*ValidationError_Loc_Item) MergeValidationErrorLoc0

func (t *ValidationError_Loc_Item) MergeValidationErrorLoc0(v ValidationErrorLoc0) error

MergeValidationErrorLoc0 performs a merge with any union data inside the ValidationError_Loc_Item, using the provided ValidationErrorLoc0

func (*ValidationError_Loc_Item) MergeValidationErrorLoc1

func (t *ValidationError_Loc_Item) MergeValidationErrorLoc1(v ValidationErrorLoc1) error

MergeValidationErrorLoc1 performs a merge with any union data inside the ValidationError_Loc_Item, using the provided ValidationErrorLoc1

func (*ValidationError_Loc_Item) UnmarshalJSON

func (t *ValidationError_Loc_Item) UnmarshalJSON(b []byte) error

type VideoResponse

type VideoResponse struct {
	Frames [][]Media `json:"frames"`
}

VideoResponse defines model for VideoResponse.

type Worker

type Worker struct {
	// contains filtered or unexported fields
}

func NewWorker

func NewWorker(containerImageID string, gpus []string, modelDir string) (*Worker, error)

func (*Worker) AudioToText

func (*Worker) HasCapacity

func (w *Worker) HasCapacity(pipeline, modelID string) bool

HasCapacity returns true if the worker has capacity for the given pipeline and model ID.

func (*Worker) ImageToImage

func (*Worker) ImageToVideo

func (*Worker) Stop

func (w *Worker) Stop(ctx context.Context) error

func (*Worker) TextToImage

func (w *Worker) TextToImage(ctx context.Context, req TextToImageJSONRequestBody) (*ImageResponse, error)

func (*Worker) Upscale

func (*Worker) Warm

func (w *Worker) Warm(ctx context.Context, pipeline string, modelID string, endpoint RunnerEndpoint, optimizationFlags OptimizationFlags) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL