request

package
v0.0.0-...-54d18ba Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const BaseURL = "https://api.novita.ai/v3"

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(apiKey string) (*Client, error)

func (*Client) Img2Img

func (c *Client) Img2Img(ctx context.Context, request *types.Img2ImgRequest) (*types.AsyncResponse, error)

func (*Client) Models

func (c *Client) Models(ctx context.Context, opts ...WithModelOption) (types.ModelList, error)

func (*Client) Progress

func (*Client) SyncImg2img

func (c *Client) SyncImg2img(ctx context.Context, request *types.Img2ImgRequest, opts ...WithGenerateImageOption) (*types.ProgressResponse, error)

func (*Client) SyncTxt2img

func (c *Client) SyncTxt2img(ctx context.Context, request *types.Txt2ImgRequest, opts ...WithGenerateImageOption) (*types.ProgressResponse, error)

func (*Client) SyncUpscale

func (c *Client) SyncUpscale(ctx context.Context, request *types.UpscaleRequest, opts ...WithGenerateImageOption) (*types.ProgressResponse, error)

func (*Client) Txt2Img

func (c *Client) Txt2Img(ctx context.Context, request *types.Txt2ImgRequest) (*types.AsyncResponse, error)

func (*Client) Upscale

func (c *Client) Upscale(ctx context.Context, request *types.UpscaleRequest) (*types.AsyncResponse, error)

type ClientInterface

type ClientInterface interface {
	// Txt2Img Asynchronously generate images from request. Returns AsyncResponse, use `task_id` to get Progress.
	Txt2Img(context.Context, *types.Txt2ImgRequest) (*types.AsyncResponse, error)
	// SyncTxt2img Synchronously generate images from request. You can get image url in `Progress.Data.Imgs`.
	SyncTxt2img(context.Context, *types.Txt2ImgRequest, ...WithGenerateImageOption) (*types.ProgressResponse, error)
	// Img2Img  Asynchronously generate images from request. Returns AsyncResponse, use `task_id` to get Progress.
	Img2Img(context.Context, *types.Img2ImgRequest) (*types.AsyncResponse, error)
	// SyncImg2img Synchronously generate images from request. You can get image url in `Progress.Data.Imgs`.
	SyncImg2img(context.Context, *types.Img2ImgRequest, ...WithGenerateImageOption) (*types.ProgressResponse, error)
	// Progress Task Progress, use `task_id` to get progress.
	Progress(context.Context, *types.ProgressRequest, ...WithGenerateImageOption) (*types.ProgressResponse, error)
	// Upscale Asynchronously upscale images from request. Returns AsyncResponse, use `task_id` to get Progress.
	Upscale(context.Context, *types.Img2ImgRequest) (*types.AsyncResponse, error)
	// SyncUpscale Synchronously upscale images from request. You can get image url in `Progress.Data.Imgs`.
	SyncUpscale(context.Context, *types.Img2ImgRequest, ...WithGenerateImageOption) (*types.ProgressResponse, error)
	// Models List all models, including checkpoint, lora, vae and other models. Return types info by type.
	Models(context.Context, ...WithModelOption) (map[types.ModelType]*types.Model, error)
}

ClientInterface define the behavior of Client

type GenerateImageOption

type GenerateImageOption struct {
	DownloadImage              bool
	SaveImage                  bool
	SaveImageDir               string
	SaveImagePerm              os.FileMode
	SaveImageFileNameConverter func(taskId string, fileIndex int, fileName string) string
}

GenerateImageOption Generation Option

type ModelOption

type ModelOption struct {
	Refresh bool
}

type WithGenerateImageOption

type WithGenerateImageOption func(*GenerateImageOption)

WithGenerateImageOption Option Pattern

func WithDownloadImage

func WithDownloadImage() WithGenerateImageOption

WithDownloadImage if this is set, you can get image raw bytes in `Progress.Data.ImgsBytes`

func WithSaveImage

func WithSaveImage(dir string, perm os.FileMode, filenameConvert func(taskId string, fileIndex int, fileName string) string) WithGenerateImageOption

type WithModelOption

type WithModelOption func(opt *ModelOption)

func WithRefresh

func WithRefresh() WithModelOption

Jump to

Keyboard shortcuts

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