Documentation ¶
Index ¶
- Constants
- type InputState
- type Message
- type MessageVersion
- type SqliteStore
- func (s *SqliteStore) ApproveUser(ctx context.Context, chatId int64) error
- func (s *SqliteStore) CheckInviteCode(ctx context.Context, user *User, code string) error
- func (s *SqliteStore) ClearMessages(ctx context.Context, chatId int64) error
- func (s *SqliteStore) Close()
- func (s *SqliteStore) EnsureDiglogID(ctx context.Context, user *User) error
- func (s *SqliteStore) EnsureInviteCode(ctx context.Context, user *User) error
- func (s *SqliteStore) GetDialogMessages(ctx context.Context, chatId int64) ([]*Message, error)
- func (s *SqliteStore) GetUser(ctx context.Context, chatId int64) (*User, error)
- func (s *SqliteStore) PutMessages(ctx context.Context, messages []*Message) error
- func (s *SqliteStore) PutUsage(ctx context.Context, usage *Usage) error
- func (s *SqliteStore) PutUser(ctx context.Context, user *User) (*User, error)
- func (s *SqliteStore) ResetDiglogID(ctx context.Context, user *User) error
- func (s *SqliteStore) SetDefaultInviteCode(code string)
- func (s *SqliteStore) SetInputState(ctx context.Context, chatId int64, state InputState) error
- func (s *SqliteStore) SetSystemPrompt(ctx context.Context, chatId int64, prompt string) error
- type Store
- type Usage
- type User
Constants ¶
View Source
const ( DialogRetention = time.Hour SaltLength = 32 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type InputState ¶
type InputState string
const ( InputStateEmpty InputState = "" InputStateWaitingForSystemPrompt InputState = "waiting_for_system_prompt" )
type MessageVersion ¶
type MessageVersion int
const ( MessageVersionV0 MessageVersion = iota MessageVersionV1 MessageVersionV2 )
type SqliteStore ¶
type SqliteStore struct {
// contains filtered or unexported fields
}
func NewSqlite ¶
func NewSqlite(path string) (*SqliteStore, error)
func (*SqliteStore) ApproveUser ¶
func (s *SqliteStore) ApproveUser(ctx context.Context, chatId int64) error
func (*SqliteStore) CheckInviteCode ¶
func (*SqliteStore) ClearMessages ¶
func (s *SqliteStore) ClearMessages(ctx context.Context, chatId int64) error
func (*SqliteStore) Close ¶
func (s *SqliteStore) Close()
func (*SqliteStore) EnsureDiglogID ¶
func (s *SqliteStore) EnsureDiglogID(ctx context.Context, user *User) error
func (*SqliteStore) EnsureInviteCode ¶
func (s *SqliteStore) EnsureInviteCode(ctx context.Context, user *User) error
EnsureInviteCode checks if the user has an invite code and generates a new one if not.
func (*SqliteStore) GetDialogMessages ¶
func (*SqliteStore) PutMessages ¶
func (s *SqliteStore) PutMessages(ctx context.Context, messages []*Message) error
func (*SqliteStore) PutUsage ¶
func (s *SqliteStore) PutUsage(ctx context.Context, usage *Usage) error
func (*SqliteStore) ResetDiglogID ¶
func (s *SqliteStore) ResetDiglogID(ctx context.Context, user *User) error
func (*SqliteStore) SetDefaultInviteCode ¶
func (s *SqliteStore) SetDefaultInviteCode(code string)
func (*SqliteStore) SetInputState ¶
func (s *SqliteStore) SetInputState(ctx context.Context, chatId int64, state InputState) error
func (*SqliteStore) SetSystemPrompt ¶
SetSystemPrompt sets the system prompt for the user.
type Store ¶
type Store interface { GetUser(ctx context.Context, chatId int64) (*User, error) PutUser(ctx context.Context, user *User) (*User, error) ApproveUser(ctx context.Context, chatId int64) error EnsureInviteCode(ctx context.Context, user *User) error EnsureDiglogID(ctx context.Context, user *User) error ResetDiglogID(ctx context.Context, user *User) error CheckInviteCode(ctx context.Context, user *User, inviteCode string) error SetSystemPrompt(ctx context.Context, chatId int64, prompt string) error SetInputState(ctx context.Context, chatId int64, state InputState) error GetDialogMessages(ctx context.Context, chatId int64) ([]*Message, error) PutMessages(ctx context.Context, message []*Message) error ClearMessages(ctx context.Context, chatId int64) error PutUsage(ctx context.Context, usage *Usage) error }
type User ¶
type User struct { ChatId int64 `db:"chat_id"` Approved bool `db:"approved"` Username string `db:"username"` FullName string `db:"full_name"` Salt string `db:"salt"` Model string `db:"model"` InviteCode string `db:"invite_code"` SystemPrompt string `db:"system_prompt"` InputState InputState `db:"input_state"` DialogID string `db:"dialog_id"` CreatedAt ytime.Time `db:"created_at"` UpdatedAt ytime.Time `db:"updated_at"` }
Click to show internal directories.
Click to hide internal directories.