tbotopenai

package
v1.0.1 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: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorChatGPTJobIsAlreadyUsed

func ErrorChatGPTJobIsAlreadyUsed(id int) error

func ErrorChatGPTJobIsNotExist

func ErrorChatGPTJobIsNotExist(id int) error

func ErrorDreamBoothJobIsAlreadyUsed

func ErrorDreamBoothJobIsAlreadyUsed(id int) error

func ErrorDreamBoothJobIsNotExist

func ErrorDreamBoothJobIsNotExist(id int) error

func ErrorOpenAIJobIsAlreadyUsed

func ErrorOpenAIJobIsAlreadyUsed(id int) error

func ErrorOpenAIJobIsNotExist

func ErrorOpenAIJobIsNotExist(id int) error

func NewSerializedDBBodyRequest

func NewSerializedDBBodyRequest(key, body string) []byte

func NewTClient

func NewTClient(username string) *clientState

Types

type AI

type AI interface {
	GenerateText(ctx context.Context, prompt string) ([]byte, error)
	GenerateImage(ctx context.Context, prompt string) ([]byte, string, error)
}

type ChatGPTBot

type ChatGPTBot struct{}

func NewChatGPTBot

func NewChatGPTBot() *ChatGPTBot

func (*ChatGPTBot) GenerateImage

func (c *ChatGPTBot) GenerateImage(_ context.Context, _ string) ([]byte, string, error)

func (*ChatGPTBot) GenerateText

func (c *ChatGPTBot) GenerateText(ctx context.Context, prompt string) ([]byte, error)

type ChatGPTSettings

type ChatGPTSettings struct {
	Timeout time.Duration `yaml:"timeout"`
}

type Config

type Config struct {
	Telegram                TelegramSettings   `yaml:"telegram"`
	ChatGPT                 ChatGPTSettings    `yaml:"chatgpt"`
	OpenAI                  OpenAISettings     `yaml:"openai"`
	DreamBooth              DreamBoothSettings `yaml:"dreambooth"`
	Roles                   RolesSettings      `yaml:"roles"`
	Permissions             PermissionSettings `yaml:"permissions"`
	Stats                   StatsSettings      `yaml:"stats"`
	Logger                  zap.Config         `yaml:"log"`
	LenMessageChan          int                `yaml:"len_message_chan"`
	LenQueueTaskChan        int                `yaml:"len_queue_task_chan"`
	QueueMessageWorkers     int                `yaml:"queue_message_workers"`
	MaxClientOpenAIJobs     int                `yaml:"max_client_openai_jobs"`
	MaxClientChatGPTJobs    int                `yaml:"max_client_chatgpt_jobs"`
	MaxClientDreamBoothJobs int                `yaml:"max_client_dreambooth_jobs"`
	MaxLogRows              int                `yaml:"max_log_rows"`
	PathBlackList           string             `yaml:"path_blacklist"`
}

func NewConfig

func NewConfig(filename string) (*Config, error)

type DBBodyRequest

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

DBBodyRequest - DreamBooth Text to Image API: https://stablediffusionapi.com/docs/community-models-api-v4/dreamboothtext2img/

type DreamBooth

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

func NewDreamBoothAPI

func NewDreamBoothAPI(log *zap.Logger, cfg *DreamBoothSettings) *DreamBooth

func (*DreamBooth) FetchQueuedImages

func (d *DreamBooth) FetchQueuedImages(requestID, key string) ([]byte, error)

FetchQueuedImages - https://stablediffusionapi.com/docs/community-models-api-v4/dreamboothfetchqueimg

func (*DreamBooth) GenerateImage

func (d *DreamBooth) GenerateImage(ctx context.Context, prompt string) (body []byte, fileName string, err error)

func (*DreamBooth) GenerateText

func (d *DreamBooth) GenerateText(_ context.Context, _ string) (body []byte, err error)

type DreamBoothSettings

type DreamBoothSettings struct {
	Tokens        []string      `yaml:"tokens"`
	RetryInterval time.Duration `yaml:"retry_interval"`
	Timeout       time.Duration `yaml:"timeout"`
}

type Messenger

type Messenger interface {
	Run()
	Stop()
	ReplyText(int, int64, string) error
	ReplyFile(int, int64, []byte, string) error
}

type OpenAI

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

func NewOpenAI

func NewOpenAI(cfg *OpenAISettings) *OpenAI

func (*OpenAI) GenerateImage

func (o *OpenAI) GenerateImage(ctx context.Context, prompt string) ([]byte, string, error)

func (*OpenAI) GenerateText

func (o *OpenAI) GenerateText(ctx context.Context, prompt string) ([]byte, error)

type OpenAISettings

type OpenAISettings struct {
	Token         string        `yaml:"token"`
	RetryCount    int           `yaml:"retry_count"`
	RetryInterval time.Duration `yaml:"retry_interval"`
	Timeout       time.Duration `yaml:"timeout"`
}

type PermissionSettings

type PermissionSettings struct {
	AdminCommands []string `yaml:"admin"`
	UserCommands  []string `yaml:"user"`
}

type RolesSettings

type RolesSettings struct {
	Admins []string `yaml:"admin"`
	Users  []string `yaml:"user"`
}

type Stats

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

func NewStats

func NewStats(log *zap.Logger, interval time.Duration, filepath string) *Stats

func (*Stats) Bytes

func (s *Stats) Bytes() []byte

func (*Stats) Run

func (s *Stats) Run(wg *sync.WaitGroup) error

func (*Stats) Stop

func (s *Stats) Stop()

func (*Stats) Write

func (s *Stats) Write(row statRow)

type StatsSettings

type StatsSettings struct {
	Interval time.Duration `yaml:"interval"`
	Filepath string        `yaml:"filepath"`
}

type TBotOpenAI

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

func NewTBotOpenAI

func NewTBotOpenAI(cfg *Config, log *zap.Logger) (*TBotOpenAI, error)

func (*TBotOpenAI) Run

func (t *TBotOpenAI) Run()

func (*TBotOpenAI) Stop

func (t *TBotOpenAI) Stop()

type Telegram

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

func NewTelegram

func NewTelegram(cfg *TelegramSettings, log *zap.Logger, msgChan chan<- *message) (*Telegram, error)

func (*Telegram) ReplyFile

func (t *Telegram) ReplyFile(messageID int, chatID int64, body []byte, fileName string) (err error)

func (*Telegram) ReplyText

func (t *Telegram) ReplyText(messageID int, chatID int64, body string) (err error)

func (*Telegram) Run

func (t *Telegram) Run()

func (*Telegram) Stop

func (t *Telegram) Stop()

type TelegramSettings

type TelegramSettings struct {
	Token   string `yaml:"token"`
	Debug   bool   `yaml:"debug"`
	Timeout int    `yaml:"timeout"`
}

Jump to

Keyboard shortcuts

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