webui

package
v0.0.0-...-30b734a Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2025 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MockApiServer

func MockApiServer(t *testing.T, model string) *httptest.Server

Mock api server, model is the model to return for the requested model

func MockGenServer

func MockGenServer(t *testing.T, model string) *httptest.Server

Mock generation server, model is the currently loaded model

func StartGen

func StartGen(ctx context.Context, gen *generator.ApiRequest, url string) error

Sends the request to the generator and sends results to the api if it succeeds

Types

type AcceptedResponse

type AcceptedResponse struct {
	Body AcceptedResponseBody
}

func PostGenerate

func PostGenerate(ctx context.Context, input *GenerateRequest) (*AcceptedResponse, error)

type AcceptedResponseBody

type AcceptedResponseBody struct {
	BatchId string `json:"batchId"`
	GenId   string `json:"genId"`
}

func BatchAndQueue

func BatchAndQueue(ctx context.Context, g *generator.ApiRequest) (*AcceptedResponseBody, error)

batchAndQueue creates a batch of generations based off the request and adds them to the queue

type AlwaysonScripts

type AlwaysonScripts struct {
	//add controlnet later
	GrpcClient GrpcArgs `json:"grpc_client" validate:"required"`
}

type DownloadInfo

type DownloadInfo struct {
	Name        string `json:"name" validate:"required"`            // The name of the file without the extension
	Filename    string `json:"filename" validate:"required"`        // The name of the file with the extension
	Extension   string `json:"ext" validate:"required"`             // The extension type of the file
	DownloadUrl string `json:"downloadUrl" validate:"required,url"` // The url to download the file
	Type        string `json:"type" validate:"oneof=ckpt lora vae"` // The type of the file, should be one of the following: ckpt, lora, lyco
}

func (*DownloadInfo) GetLogTags

func (ref *DownloadInfo) GetLogTags() string

func (*DownloadInfo) LogWithTags

func (ref *DownloadInfo) LogWithTags(ctx context.Context, msg ...string)

type GenerateRequest

type GenerateRequest struct {
	Body struct {
		generator.ApiRequest
	}
}

type GenerationModel

type GenerationModel struct {
	generator.SharedArgs
	generator.IngestArgs
	Info         *generator.WebuiResponse `json:"info,omitempty" validate:"omitempty"`
	GroupId      string                   `json:"group_id" validate:"omitempty"`
	Checkpoint   *ModelVersionDetails     `json:"checkpoint" validate:"required"`
	HrCheckpoint *ModelVersionDetails     `json:"hr_checkpoint" validate:"omitempty"`
	Loras        []ModelVersionDetails    `json:"lora_models" validate:"omitempty"`
	HrLoras      []ModelVersionDetails    `json:"hr_models" validate:"omitempty"`
}

func ApiRequestToGenerationModel

func ApiRequestToGenerationModel(ctx context.Context, req *generator.ApiRequest) (*GenerationModel, error)

func (*GenerationModel) DownloadAndUpdatePrompts

func (gen *GenerationModel) DownloadAndUpdatePrompts(ctx context.Context, url string) error

func (*GenerationModel) GetLogTags

func (req *GenerationModel) GetLogTags() string

func (*GenerationModel) LogWithTags

func (req *GenerationModel) LogWithTags(ctx context.Context, msg ...string)

type GrpcArgs

type GrpcArgs struct {
	Args []generator.IngestArgs `json:"args" validate:"required"`
}

type ModelDownloadInfo

type ModelDownloadInfo struct {
	DownloadUrl string `json:"download_url" validate:"required,url"`
	Id          string `json:"id" validate:"required,uuid"`
	// The name of the file without the extension
	Name      string `json:"name" validate:"required"`
	VersionId string `json:"version_id" validate:"required,uuid"`
	FileType  string `json:"file_type" validate:"oneof=Model PrunedModel Negative VAE TrainingData"`
}

type ModelDownloadRequest

type ModelDownloadRequest struct {
	DownloadUrl string `json:"downloadUrl" validate:"required,url"`
	Filename    string `json:"filename" validate:"required"`
	Type        string `json:"type" validate:"oneof=ckpt lora lyco"`
}

Wrapper class to send to extras/model/download

func (*ModelDownloadRequest) Validate

func (req *ModelDownloadRequest) Validate() error

type ModelOptions

type ModelOptions struct {
	SdModelCheckpoint string `json:"sd_model_checkpoint"`
}

for setting the model

type ModelVersionDetails

type ModelVersionDetails struct {
	ModelVersionResponse
	Multiplier float32       `json:"multiplier" validate:"omitempty"` // Only used for Lora models
	Vae        *DownloadInfo `json:"vae" validate:"omitempty"`        // VAE file reference
	Model      *DownloadInfo `json:"model" validate:"required"`       // Model file reference
}

func LoraToModelDetails

func LoraToModelDetails(ctx context.Context, lora generator.LoraVersionReference, modelType string) (*ModelVersionDetails, error)

Overload for loras

func ToModelDetails

func ToModelDetails(ctx context.Context, model *generator.ModelVersionReference, modelType string) (*ModelVersionDetails, error)

Converts a ModelVersionReference to a ModelVersionDetails by fetching the relevant information from the API

func (*ModelVersionDetails) DownloadModels

func (gen *ModelVersionDetails) DownloadModels(ctx context.Context, url, logPrefix string, checkVae bool) error

Download the model and check the related vae

func (*ModelVersionDetails) GetLogTags

func (ref *ModelVersionDetails) GetLogTags() string

func (*ModelVersionDetails) LogWithTags

func (req *ModelVersionDetails) LogWithTags(ctx context.Context, msg ...string)

type ModelVersionFile

type ModelVersionFile struct {
	Name        string `json:"name" validate:"required"`
	FileType    string `json:"type" validate:"required"` // Training Data, Negative, Pruned Model, VAE, Model
	DownloadUrl string `json:"downloadUrl" validate:"required,url"`
}

type ModelVersionInfo

type ModelVersionInfo struct {
	BaseModel    string   `json:"base_model"`
	Description  string   `json:"description"`
	DownloadUrl  string   `json:"download_url" validate:"required,url"`
	Id           string   `json:"id" validate:"required,uuid"`
	ModelId      string   `json:"model_id" validate:"required,uuid"`
	Name         string   `json:"name" validate:"required"`
	TrainedWords []string `json:"trained_words" validate:"omitempty"`
}

func (*ModelVersionInfo) GetLogTags

func (ref *ModelVersionInfo) GetLogTags() string

type ModelVersionResponse

type ModelVersionResponse struct {
	Files []ModelDownloadInfo `json:"files" validate:"required"`
	Info  ModelVersionInfo    `json:"info" validate:"required"`
}

The response from /model/version/details/{uuid}

type WebuiRequest

type WebuiRequest struct {
	generator.SharedArgs
	SdModelCheckpoint string          `json:"sd_model_checkpoint" validate:"required"` // String representation of ModelVersionReference to send to webui
	SendImage         bool            `json:"send_image" validate:"omitempty"`         // should always be false
	AlwaysonScripts   AlwaysonScripts `json:"alwayson_scripts" validate:"omitempty"`   // additonal values, unstructured json, probably need real models for this
}

sent to automatic1111 webui

func (*WebuiRequest) GetLogTags

func (msg *WebuiRequest) GetLogTags() string

TODO: add prompt/negative prompt length

func (*WebuiRequest) LogWithTags

func (req *WebuiRequest) LogWithTags(ctx context.Context, msg ...string)

func (*WebuiRequest) Validate

func (req *WebuiRequest) Validate() error

Jump to

Keyboard shortcuts

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