Documentation ¶
Overview ¶
Package gpt contains bot command handler which sends text generated by GPT.
Index ¶
- type ContextPromptData
- type Handler
- func (h *Handler) OnCommand(ctx context.Context, e dispatch.MessageEvent) error
- func (h *Handler) OnInfo(ctx context.Context, e dispatch.MessageEvent) error
- func (h *Handler) OnReply(ctx context.Context, e dispatch.MessageEvent) (rerr error)
- func (h *Handler) WithContextPromptTemplate(t *template.Template) *Handler
- func (h *Handler) WithLimitConfig(cfg LimitConfig) *Handler
- type LimitConfig
- type PromptUser
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContextPromptData ¶
type ContextPromptData struct { Prompter PromptUser // ChatTitle is a chat title where prompt was generated. ChatTitle string }
ContextPromptData is a data structure passed to context prompt template.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler implements GPT request handler.
func New ¶
func New(api *openai.Client, db *ent.Client, tp trace.TracerProvider) *Handler
New creates new Handler.
func (*Handler) WithContextPromptTemplate ¶
WithContextPromptTemplate sets template to setup a context prompt before completion.
func (*Handler) WithLimitConfig ¶
func (h *Handler) WithLimitConfig(cfg LimitConfig) *Handler
WithMessageLimit sets message limit in runes.
type LimitConfig ¶
type LimitConfig struct { // PerUserRate sets cooldown timeout for a one user across chats. // If <=0, limit is disabled. PerUserRate time.Duration // PerPeerRate sets cooldown timeout for a one peer (chat/channel/user). // If <=0, limit is disabled. PerPeerRate time.Duration // MessageSizeLimit sets limit in runes for one message (prompt). // If <=0, limit is disabled. MessageSizeLimit int // DialogDepthLimit sets dialog depth limit. Counts prompt and AI answer as well. // If <=0, limit is disabled. DialogDepthLimit int }
LimitConfig sets limits for GPT.
func (*LimitConfig) ParseEnv ¶
func (cfg *LimitConfig) ParseEnv() error
ParseEnv parses environment.
type PromptUser ¶
PromptUser defines context prompt data of user asking the question.
Click to show internal directories.
Click to hide internal directories.