dalle

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusPending   = "pending"
	StatusRejected  = "rejected"
	StatusSucceeded = "succeeded"

	TaskTypeText2Im = "text2im"
)

Variables

View Source
var Enabled bool

Functions

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) option

func WithUserAgent

func WithUserAgent(userAgent string) option

Types

type Client

type Client interface {
	Generate(ctx context.Context, prompt string) (*Task, error)
	ListTasks(ctx context.Context, req *ListTasksRequest) (*ListTasksResponse, error)
	GetTask(ctx context.Context, taskID string) (*Task, error)
	Download(ctx context.Context, generationID string) (io.ReadCloser, error)
	Share(ctx context.Context, generationID string) (string, error)
}

type Error

type Error struct {
	Message    string
	StatusCode int
	Details    string
}

func (Error) Error

func (e Error) Error() string

type GenerateRequest

type GenerateRequest struct {
	Prompt   GenerateRequestPrompt `json:"prompt"`
	TaskType string                `json:"task_type"`
}

type GenerateRequestPrompt

type GenerateRequestPrompt struct {
	BatchSize int32  `json:"batch_size"`
	Caption   string `json:"caption"`
}

type Generation

type Generation struct {
	ImagePath string `json:"image_path"`
}

type GenerationData

type GenerationData struct {
	Created        int64      `json:"created"`
	Generation     Generation `json:"generation"`
	GenerationType string     `json:"generation_type"`
	ID             string     `json:"id"`
}

type Generations

type Generations struct {
	Data   []GenerationData `json:"data"`
	Object string           `json:"object"`
}

type HTTPClient

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

func NewHTTPClient

func NewHTTPClient(apiKey string, opts ...option) (*HTTPClient, error)

func (*HTTPClient) Download

func (c *HTTPClient) Download(ctx context.Context, generationID string) (io.ReadCloser, error)

func (*HTTPClient) Generate

func (c *HTTPClient) Generate(ctx context.Context, caption string) (*Task, error)

func (*HTTPClient) GetTask

func (c *HTTPClient) GetTask(ctx context.Context, taskID string) (*Task, error)

func (*HTTPClient) ListTasks

func (c *HTTPClient) ListTasks(ctx context.Context, req *ListTasksRequest) (*ListTasksResponse, error)

func (*HTTPClient) Share

func (c *HTTPClient) Share(ctx context.Context, generationID string) (string, error)

Share makes the generation public and returns the public url

type ListTasksRequest

type ListTasksRequest struct {
	Limit int32 `json:"limit"`
}

type ListTasksResponse

type ListTasksResponse struct {
	Object string `json:"object"`
	Data   []Task `json:"data"`
}

type Prompt

type Prompt struct {
	ID         string `json:"id"`
	Object     string `json:"object"`
	Created    int64  `json:"created"`
	PromptType string `json:"prompt_type"`
	Prompt     struct {
		Caption string `json:"caption"`
	} `json:"prompt"`
	ParentGenerationID string `json:"parent_generation_id"`
}

type Task

type Task struct {
	Object      string      `json:"object"`
	ID          string      `json:"id"`
	Created     int64       `json:"created"`
	TaskType    string      `json:"task_type"`
	Status      string      `json:"status"`
	PromptID    string      `json:"prompt_id"`
	Prompt      Prompt      `json:"prompt"`
	Generations Generations `json:"generations"`
}

Jump to

Keyboard shortcuts

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