Documentation ¶
Index ¶
Constants ¶
View Source
const ( DefaultMessageUserRole = "Human" DefaultMessageBotRole = "Assistant" DefaultBotContentType = "text" // DefaultHistoryDepth is a complete user-bot log DefaultHistoryDepth = 2 )
View Source
const ( AdminRoleSort = 0 DefaultRoleSort = 20 DefaultRoleId = 2 )
View Source
const ( UserStatusNormal uint = 1 UserStatusDisabled uint = 0 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Conversation ¶
type Conversation struct { UUIDModel Username string `gorm:"comment:'user name'" json:"username"` Title string `gorm:"comment:'conversation title'" json:"title"` State bool `gorm:"comment:'state'" json:"state"` Messages []*Message `gorm:"foreignkey:ConversationId" json:"messages"` }
Conversation saves user conversations
type DomainObject ¶
type DomainObject interface { User | Role | Conversation | LLM }
type Message ¶
type Message struct { UUIDModel Role string `gorm:"comment:'informative role'" json:"role"` Content string `gorm:"type:text;" json:"content"` ContentType string `gorm:"comment:'content type'" json:"contentType"` Model string `gorm:"comment:'ai models name'" json:"models"` Feedback uint `gorm:"type:tinyint(1)" json:"feedback"` ParentMsgId string `gorm:"type:varchar(36)" json:"parentMsgId"` ConversationId string `gorm:"type:varchar(36)" json:"conversationId"` Conversation Conversation `gorm:"foreignkey:ConversationId" json:"conversation"` }
Message Store conversation logs, Including user questions and chat bot responses
func (*Message) FindPreMessages ¶
func (m *Message) FindPreMessages(rep repository.Repository, depth uint) ([]*History, error)
FindPreMessages Find previous message records by depth. The depth is an even number, which means a completed user-bot log
type PageInfo ¶
type PageInfo struct { PageNum uint `json:"pageNum" form:"pageNum"` PageSize uint `json:"pageSize" form:"pageSize"` Total int64 `json:"total" form:"total"` NoPagination bool `json:"noPagination" form:"noPagination"` // Do not use pagination }
PageInfo includes the Response result of query by page number
type Role ¶
type Role struct { Model Name string `gorm:"comment:'role name'" json:"name"` Keyword string `gorm:"comment:'role keyword';unique" json:"keyword"` Desc string `gorm:"comment:'role description'" json:"desc"` Sort *uint `gorm:"default:1;comment:'Role sorting (the larger the value, the smaller the authority)'" json:"sort"` Status *uint `gorm:"comment:'role status(enable/disable)';default:1;type:tinyint(1)" json:"status"` Creator string `gorm:"comment:'creator'" json:"creator"` Users []*User `gorm:"foreignkey:RoleId" json:"users"` }
func (*Role) FindIdsBySort ¶
func (r *Role) FindIdsBySort(rep repository.Repository, sort uint) ([]uint, error)
type UUIDModel ¶
type Url ¶
type Url struct { Model Method string `gorm:"comment:'request method'" json:"method"` Path string `gorm:"comment:'url path'" json:"path"` Category string `gorm:"comment:'category'" json:"category"` Desc string `gorm:"comment:'description'" json:"desc"` Creator string `gorm:"comment:'creator'" json:"creator"` }
Url stores all api paths of the current application
type User ¶
type User struct { Model Username string `gorm:"comment:'user name';unique" json:"username"` ZhName string `gorm:"comment:'user zh name'" json:"zhName"` Email string `gorm:"comment:'user email'" json:"email"` Status *uint `gorm:"comment:'user status';default:1;type:tinyint(1)" json:"status"` Creator string `gorm:"comment:'creator'" json:"creator"` RoleId uint `gorm:"comment:'role id'" json:"roleId"` Role Role `gorm:"foreignkey:RoleId" json:"role"` }
func (*User) FindByName ¶
func (u *User) FindByName(rep repository.Repository, name string) (*User, error)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.