vanceai

package module
v0.0.0-...-f3d4dbb Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2023 License: MIT Imports: 9 Imported by: 0

README

vanceai-go

Vanceai Golang SDK

sketch image

integration test

go test ./... --tags=integration

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorIllegalParameter = errors.New("illegal parameter")
	VanceAIInternalError  = errors.New("vanceai internal error")
	FileNotFound          = errors.New("file not found")
	SizeExceedsLimit      = errors.New("size exceeds limit")
	JParamParseError      = errors.New("jparam parse error")
	JobFailed             = errors.New("job failed")
	InvalidAPIKey         = errors.New("invalid api key")
	InsufficientBalance   = errors.New("insufficient balance")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	APIKey string

	BaseURL        *url.URL
	ProcessWebhook string
	// contains filtered or unexported fields
}

func NewClient

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

func (*Client) Download

func (cli *Client) Download(ctx context.Context, transID string) (io.ReadCloser, error)

func (*Client) GetPoint

func (cli *Client) GetPoint(ctx context.Context) (Response, error)

func (*Client) GetProgress

func (cli *Client) GetProgress(
	ctx context.Context,
	transID string,
) (Response, error)

func (*Client) ProcessImage

func (cli *Client) ProcessImage(
	ctx context.Context,
	uid string,
	jobConfig job,
) (Response, error)

func (*Client) UploadImage

func (cli *Client) UploadImage(
	ctx context.Context,
	reader io.Reader,
	name string,
) (Response, error)

type Compress

type Compress struct {
	Quality int64 `json:"quality"`
}

type Config

type Config struct {
	Module       string       `json:"module"`
	ModuleParams ModuleParams `json:"module_params"`
	OutParams    OutParams    `json:"out_params"`
}

type Data

type Data struct {
	UID       string `json:"uid"`
	Name      string `json:"name"`
	Thumbnail string `json:"thumbnail"`
	W         int64  `json:"w"`
	H         int64  `json:"h"`
	FileSize  int64  `json:"filesize"`
	TransID   string `json:"trans_id"`
	Status    Status `json:"status"`
	MaxNum    string `json:"max_num"`
	UsedNum   string `json:"used_num"`
}

type JobConfig

type JobConfig struct {
	// https://docs.vanceai.com/?shell#description-of-config-file
	Job    string `json:"job"`
	Config Config `json:"config"`
}

type ModuleParams

type ModuleParams struct {
	ModelName     string `json:"model_name"`
	SuppressNoise int64  `json:"suppress_noise"`
	RemoveBlur    int64  `json:"remove_blur"`
	Scale         string `json:"scale"`
	Rescale       int64  `json:"rescale"`
	SingleFace    bool   `json:"single_face"`
	Composite     bool   `json:"composite"`
	Sigma         int64  `json:"sigma"`
	Alpha         int64  `json:"alpha"`
	AutoMode      bool   `json:"auto_mode"`
	WebAutoMode   bool   `json:"web_auto_mode"`
}

type MultipleJob

type MultipleJob struct {
	Job    string         `json:"job"`
	Config []SingleConfig `json:"config"`
}

type OutParams

type OutParams struct {
	Compress Compress `json:"compress"`
}

type ProcessRequest

type ProcessRequest struct {
	APIToken  string `json:"api_token"`
	UID       string `json:"uid"`
	Webhook   string `json:"webhook"`
	JobConfig string `json:"jconfig"`
}

type ProgressRequest

type ProgressRequest struct {
	APIToken string `json:"api_token"`
	TransID  string `json:"trans_id"`
}

type Response

type Response struct {
	Code   int64       `json:"code"`
	CSCode int64       `json:"cscode"`
	IP     string      `json:"ip"`
	Data   Data        `json:"data"`
	Msg    interface{} `json:"msg"`
}

func (*Response) Error

func (r *Response) Error() error

func (*Response) MsgString

func (resp *Response) MsgString() string

type SingleConfig

type SingleConfig struct {
	Name   string `json:"name"`
	Config Config `json:"config"`
}

type Status

type Status string
const (
	// https://docs.vanceai.com/?shell#status-of-job-processing
	Finish  Status = "finish"
	Wait    Status = "wait"
	Fatal   Status = "fatal"
	Process Status = "process"
	Webhook Status = "webhook"
	Busy    Status = "busy"
)

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

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