Documentation ¶
Index ¶
Constants ¶
View Source
const ( DashScopeBaseURL = "https://dashscope.aliyuncs.com" ImageSynthesisURI = "/api/v1/services/aigc/text2image/image-synthesis" TaskURI = "/api/v1/tasks/%s" )
Variables ¶
Functions ¶
func ImageSynthesisURL ¶
func ImageSynthesisURL() string
Types ¶
type ImageResponse ¶
type ImageResponse struct { StatusCode int `json:"status_code"` RequestID string `json:"request_id"` Code string `json:"code"` Message string `json:"message"` Output Output `json:"output"` Usage Usage `json:"usage"` }
func AsyncCall ¶
func AsyncCall(ctx context.Context, req *ImageSynthesisRequest, httpcli httpclient.IHttpClient, options ...httpclient.HTTPOption) (*ImageResponse, error)
calling tongyi-wanx-api to get image-generation async task id.
type ImageSynthesisInput ¶
type ImageSynthesisParams ¶
type ImageSynthesisParams struct { /* The style of the output image, currently supports the following style values: "<auto>" default, "<3d cartoon>" 3D cartoon, "<anime>" animation, "<oil painting>" oil painting, "<watercolor>" watercolor, "<sketch>" sketch, "<chinese painting>" Chinese painting, "<flat illustration>" flat illustration, */ Style string `json:"style,omitempty"` /* The resolution of the generated image, currently only supports '1024*1024', '720*1280', '1280*720' three resolutions, default is 1024*1024 pixels. */ Size string `json:"size,omitempty"` // The number of images generated, currently supports 1~4, default is 1. N int `json:"n,omitempty"` // seed. Seed int `json:"seed,omitempty"` }
type ImageSynthesisRequest ¶
type ImageSynthesisRequest struct { Model string `json:"model"` Input ImageSynthesisInput `json:"input"` Params ImageSynthesisParams `json:"parameters"` Download bool `json:"-"` }
type ImgBlob ¶
type ImgBlob struct { // types include: "image/png". ImgType string `json:"img_type"` ImgURL string `json:"img_url"` // Raw bytes for media formats. Data []byte `json:"-"` }
func CreateImageGeneration ¶
func CreateImageGeneration(ctx context.Context, payload *ImageSynthesisRequest, httpcli httpclient.IHttpClient, token string) ([]*ImgBlob, error)
type Output ¶
type Output struct { TaskID string `json:"task_id"` TaskStatus string `json:"task_status"` Results []struct { URL string `json:"url"` } `json:"results"` TaskMetrics struct { Total int `json:"TOTAL"` Succeeded int `json:"SUCCEEDED"` Failed int `json:"FAILED"` } `json:"task_metrics"` }
func SyncCall ¶
func SyncCall(ctx context.Context, req *ImageSynthesisRequest, httpcli httpclient.IHttpClient, options ...httpclient.HTTPOption) (*Output, error)
tongyi-wanx-api only support AsyncCall, so we need to warp it to be Sync.
type TaskRequest ¶
type TaskRequest struct {
TaskID string `json:"task_id"`
}
type TaskResponse ¶
type TaskResponse struct { RequestID string `json:"request_id"` Output Output `json:"output"` Usage Usage `json:"usage"` }
func CheckTaskStatus ¶
func CheckTaskStatus(ctx context.Context, req *TaskRequest, httpcli httpclient.IHttpClient, options ...httpclient.HTTPOption) (*TaskResponse, error)
type TaskStatus ¶
type TaskStatus string
const ( TaskSucceeded TaskStatus = "SUCCEEDED" TaskFailed TaskStatus = "FAILED" TaskCanceled TaskStatus = "CANCELED" TaskPending TaskStatus = "PENDING" TaskSuspended TaskStatus = "SUSPENDED" TaskRunning TaskStatus = "RUNNING" )
Click to show internal directories.
Click to hide internal directories.