chat

package
v0.0.0-...-b336c4c Latest Latest
Warning

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

Go to latest
Published: May 5, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

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

func NewApp

func NewApp(cfg *configs.Config, dao *dao.Dao) *App

func (*App) AddHandler

func (a *App) AddHandler(handler Handler)

func (*App) Run

func (a *App) Run()

type Command

type Command interface {
	Info() (name string, description string, scope []string, hidden bool)
	Handle(update *bot.Update, dependency *HandleContext) error
}

type CommandHandler

type CommandHandler struct {
	Command map[string]Handler
}

func NewCommandHandler

func NewCommandHandler(api *bot.BotAPI) *CommandHandler

func (*CommandHandler) AddCommand

func (h *CommandHandler) AddCommand(command Command)

func (*CommandHandler) Bind

func (h *CommandHandler) Bind(api *bot.BotAPI) error

func (*CommandHandler) Handle

func (h *CommandHandler) Handle(update *bot.Update, ctx *HandleContext) error

type GPTHandler

type GPTHandler struct {
}

func NewChatHandler

func NewChatHandler() *GPTHandler

func (*GPTHandler) Handle

func (h *GPTHandler) Handle(update *bot.Update, ctx *HandleContext) error

type HandleContext

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

type Handler

type Handler interface {
	Handle(update *bot.Update, ctx *HandleContext) error
}

type OpenAI

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

func NewOpenAI

func NewOpenAI(cfg *configs.OpenAI, db *dao.Dao) *OpenAI

func (*OpenAI) AddClient

func (o *OpenAI) AddClient(key string) error

func (*OpenAI) AllClient

func (o *OpenAI) AllClient() []string

func (*OpenAI) CreateChatCompletionStream

func (o *OpenAI) CreateChatCompletionStream(history []*openai.ChatCompletionMessage) (*openai.ChatCompletionStream, error)

func (*OpenAI) GetRandClient

func (o *OpenAI) GetRandClient() *openai.Client

func (*OpenAI) RemoveClient

func (o *OpenAI) RemoveClient(key string) error

func (*OpenAI) RestoreClients

func (o *OpenAI) RestoreClients() error

type Session

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

func NewSession

func NewSession(id int64, cfg *configs.ChatConfig, dao *dao.Dao) *Session

func (*Session) Chat

func (s *Session) Chat(question *openai.ChatCompletionMessage, with func([]*openai.ChatCompletionMessage) (*openai.ChatCompletionMessage, error)) error

func (*Session) ClearHistory

func (s *Session) ClearHistory()

func (*Session) RestoreHistory

func (s *Session) RestoreHistory() error

func (*Session) SaveHistory

func (s *Session) SaveHistory() error

type StartCommand

type StartCommand struct {
}

func NewStartCommand

func NewStartCommand() *StartCommand

func (*StartCommand) Handle

func (s *StartCommand) Handle(update *bot.Update, ctx *HandleContext) error

func (*StartCommand) Info

func (s *StartCommand) Info() (name string, description string, scope []string, hidden bool)

type TokenCommand

type TokenCommand struct {
}

func NewTokenCommand

func NewTokenCommand() *TokenCommand

func (*TokenCommand) Handle

func (s *TokenCommand) Handle(update *bot.Update, ctx *HandleContext) error

func (*TokenCommand) Info

func (s *TokenCommand) Info() (name string, description string, scope []string, hidden bool)

Jump to

Keyboard shortcuts

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