dal

package
v0.0.0-...-b37c17f Latest Latest
Warning

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

Go to latest
Published: May 12, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModelIdOpenAiGpt4  = 1
	ModelIdOpenAiGpt35 = 2
)
View Source
const (
	BalanceMultipleFactor = 1000000
)
View Source
const (
	ProviderOpenAi = "openai"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database struct {
	History *History
	Message *Message
	Model   *Model
	User    *User
}

func New

func New(conf *util.Configuration, logger util.ILogger) (*Database, error)

type History

type History struct {
	SessionId     string
	Timestamp     int64
	UserId        string
	ModelId       int
	InTokenCount  int
	OutTokenCount int
	// contains filtered or unexported fields
}

func (*History) Insert

func (h *History) Insert(history *History) error

func (*History) SelectBySessionId

func (h *History) SelectBySessionId(sessionId string) ([]*History, error)

func (*History) SelectByUserIdAfter

func (h *History) SelectByUserIdAfter(userId string, timestamp int64) ([]*History, error)

type IUser

type IUser interface {
	SelectByIdInsertIfNotExists(id string) (*User, error)
	ReduceBalance(id string, amount int64) error
}

type Message

type Message struct {
	Deleted   bool
	SessionId string
	UserId    string // uuid
	Timestamp int64
	Messages  string // json string of messages, might include persona (role: system)
	ModelId   int
	Shared    bool
	Saved     bool // if false, it means the message is automatically saved (last)
	// contains filtered or unexported fields
}

func (*Message) Insert

func (m *Message) Insert(message *Message) error

func (*Message) ReplaceBySessionId

func (m *Message) ReplaceBySessionId(message *Message) error

func (*Message) SelectBySessionId

func (m *Message) SelectBySessionId(id string) (*Message, error)

func (*Message) SelectByUserId

func (m *Message) SelectByUserId(userId string) ([]*Message, error)

func (*Message) SelectLastByUserId

func (m *Message) SelectLastByUserId(userId string) (*Message, error)

type Model

type Model struct {
	Id           int     `json:"id"`
	Name         string  `json:"name"`
	Encoding     string  `json:"encoding"`
	Provider     string  `json:"provider"`
	InRate       float64 `json:"inRate"`
	OutRate      float64 `json:"outRate"`
	SupportImage bool    `json:"supportImage"`
	// contains filtered or unexported fields
}

func (*Model) SelectAll

func (m *Model) SelectAll() ([]*Model, error)

func (*Model) SelectById

func (m *Model) SelectById(id int) (*Model, error)

type User

type User struct {
	Id        string // uuid
	Balance   int64  // dollar * multiple factor (1000000)
	Clipboard string
	// contains filtered or unexported fields
}

func (*User) ReduceBalance

func (u *User) ReduceBalance(id string, amount int64) (*User, error)

func (*User) SelectAll

func (u *User) SelectAll() ([]*User, error)

func (*User) SelectByIdInsertIfNotExists

func (u *User) SelectByIdInsertIfNotExists(uuid string) (*User, error)

func (*User) UpdateClipboard

func (u *User) UpdateClipboard(id, clipboard string) error

Jump to

Keyboard shortcuts

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