api

package
v0.0.0-...-036bb43 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrImageNotFound = errors.New("image not found")
	ErrImageExpired  = errors.New("image expired")
)

Functions

This section is empty.

Types

type HyperbolicImage

type HyperbolicImage struct {
	Index      int    `json:"index"`
	Image      string `json:"image"`
	RandomSeed string `json:"random_seed"`
}

HyperbolicImage represents a generated image in the Hyperbolic API response

type HyperbolicRequest

type HyperbolicRequest struct {
	ModelName string `json:"model_name"`
	Prompt    string `json:"prompt"`
	Height    int    `json:"height"`
	Width     int    `json:"width"`
	Backend   string `json:"backend"`
}

HyperbolicRequest represents a Hyperbolic image generation request

type HyperbolicResponse

type HyperbolicResponse struct {
	Images        []HyperbolicImage `json:"images"`
	InferenceTime float64           `json:"inference_time"`
}

HyperbolicResponse represents a Hyperbolic API response

type ImageManager

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

func NewImageManager

func NewImageManager(basePath string, expiryDuration time.Duration, maxStoreSizeMB int, cleanupInterval time.Duration) (*ImageManager, error)

func (*ImageManager) GetImage

func (manager *ImageManager) GetImage(id string) ([]byte, error)

func (*ImageManager) StoreImageWithPrompt

func (manager *ImageManager) StoreImageWithPrompt(prompt string, imageData []byte) (string, error)

type OpenAIImage

type OpenAIImage struct {
	URL     string `json:"url,omitempty"`
	B64JSON string `json:"b64_json,omitempty"`
}

type OpenAIRequest

type OpenAIRequest struct {
	Model          string  `json:"model"`
	Prompt         string  `json:"prompt"`
	N              *int    `json:"n,omitempty"`
	Size           *string `json:"size,omitempty"`
	ResponseFormat *string `json:"response_format,omitempty"`
}

OpenAIRequest represents an OpenAI image generation request

type OpenAIResponse

type OpenAIResponse struct {
	Created int64         `json:"created"`
	Data    []OpenAIImage `json:"data"`
}

type Router

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

func NewRouter

func NewRouter(imageManager *ImageManager, baseURL string) *Router

func (*Router) ServeHTTP

func (router *Router) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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