fusionbrain

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package fusionbrain - The Fusion Brain API. Documentation: https://fusionbrain.ai/docs/en/doc/api-dokumentaciya/

Index

Constants

View Source
const (
	// StatusInitial - the request has been received, is in the queue for processing
	StatusInitial = "INITIAL"
	// StatusProcessing - the request is being processed
	StatusProcessing = "PROCESSING"
	// StatusDone - task completed
	StatusDone = "DONE"
	// StatusFail - the task could not be completed
	StatusFail = "FAIL"
	// StatusDisabledByQueue - service internal error
	StatusDisabledByQueue = "DISABLED_BY_QUEUE"
)

The Fusion Brain statuses

Variables

This section is empty.

Functions

This section is empty.

Types

type FusionBrain

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

func NewFusionBrain

func NewFusionBrain(client *fasthttp.Client, key, secretKey string) *FusionBrain

NewFusionBrain - the Fusion Brain API is a new section of the platform that allows platform users to access artificial intelligence models via the API. One of the first models that is available via the API is the Kandinsky model.

func (*FusionBrain) CheckAvailable

func (f *FusionBrain) CheckAvailable(ctx context.Context) error

CheckAvailable - if there is a heavy load or technical work, the service may be temporarily unavailable to accept new tasks. You can check the current status in advance by using a GET request to URL /key/api/v1/text2image/availability. During unavailability, tasks will not be accepted and in response to a request to the model, instead of the uuid of your task, the current status of the service will be returned.

func (*FusionBrain) CheckStatus

func (f *FusionBrain) CheckStatus(ctx context.Context, uuid string) (GenerationStatus, error)

CheckStatus - The check_status request allows you to check the status of image generation. To call this method, you need to send a GET request to the URL запрос на URL /key/api/v1/text2image/status/{uuid}, where uid is the task ID received when calling the request to the model.

func (*FusionBrain) GetModels

func (f *FusionBrain) GetModels(ctx context.Context) ([]Model, error)

GetModels - list of available models. The appeal takes place at the URL: https://api-key.fusionbrain.ai/key/api/v1/models.

func (*FusionBrain) GetStyles

func (f *FusionBrain) GetStyles(ctx context.Context) ([]Style, error)

GetStyles - getting the current list of styles.

func (*FusionBrain) TextToImage

func (f *FusionBrain) TextToImage(ctx context.Context, reqBody RequestBody, modelID int) (string, error)

TextToImage - the generate mode takes a text description of an image as input and generates an image corresponding to it. To call this method, you need to send a POST request to the URL /key/api/v1/text2image/run.

type GenerationStatus

type GenerationStatus struct {
	UUID             string   `json:"uuid"`
	Status           string   `json:"status"`
	Images           []string `json:"images"`
	ErrorDescription string   `json:"errorDescription"`
	Censored         string   `json:"censored"`
}

type Model

type Model struct {
	ID      int    `json:"id"`
	Name    string `json:"name"`
	Version string `json:"version"`
	Type    string `json:"type"`
}

type RequestBody

type RequestBody struct {
	Prompt, NegativePrompt, Style string
	Width, Height                 int
}

type Style

type Style struct {
	Name    string `json:"name"`
	Title   string `json:"title"`
	TitleEn string `json:"titleEn"`
	Image   string `json:"image"`
}

Jump to

Keyboard shortcuts

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