model

package
v0.0.0-...-0e94699 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultPageSize = 10
View Source
const MaxPageSize = 999
View Source
const ModelStatusActive int8 = 1
View Source
const ModelStatusCanceled int8 = 2
View Source
const ModelStatusDraft int8 = 0
View Source
const ModelStatusInactive int8 = 4
View Source
const ModelStatusPending int8 = 3
View Source
const PageDefaultSize = 20
View Source
const UniqueId = "id"
View Source
const UniqueUuid = "uuid"

Variables

View Source
var ArrayModelFields *object.HashMap = &object.HashMap{}
View Source
var TablePrefix string

Functions

func FormatJsonBArrayToWhereInSQL

func FormatJsonBArrayToWhereInSQL(fields string, arrayValues []string) (sqlWhere string)

---------------------------------------------------------------------------------------------------------------------

func GenerateId

func GenerateId() string

func GetAllList

func GetAllList(db *gorm.DB, conditions *map[string]interface{},
	items interface{}, preloads []string) (err error)

func GetFirst

func GetFirst(db *gorm.DB, conditions *map[string]interface{}, model interface{}, preloads []string) (err error)

func GetModelFieldValues

func GetModelFieldValues(model interface{}) (mapFields *object.HashMap, err error)

func GetModelFields

func GetModelFields(model interface{}) (fields []string)

func GetTableFullName

func GetTableFullName(schema string, prefix string, tableName string) (fullName string)

func InsertModelsOnUniqueID

func InsertModelsOnUniqueID(db *gorm.DB, mdl interface{}, uniqueName string, models interface{}) error

func IsPowerPivotLoaded

func IsPowerPivotLoaded(mdl ModelInterface) bool

func IsRobotModelLoaded

func IsRobotModelLoaded(mdl ModelInterface) bool

func Paginate

func Paginate(page int, pageSize int) func(db *gorm.DB) *gorm.DB

*

  • Pagination

func UpsertModelsOnUniqueID

func UpsertModelsOnUniqueID(db *gorm.DB, mdl interface{}, uniqueName string,
	models interface{}, fieldsToUpdate []string, withAssociations bool) error

func WhereAccountUuid

func WhereAccountUuid(uuid string) func(db *gorm.DB) *gorm.DB

func WhereUuid

func WhereUuid(uuid string) func(db *gorm.DB) *gorm.DB

*

  • Scope Where Conditions

Types

type Author

type Author struct {
	Role Role
}

type Content

type Content struct {
	ContentType string
	Parts       []string
}

type Conversation

type Conversation struct {
	ID              string
	UserID          string
	Action          string
	Sessions        []*Session
	ParentMessageID string
	Model           string
	StartTime       time.Time
	EndTime         time.Time
	Status          ConversationStatus
}

func NewConversation

func NewConversation(userId string) *Conversation

func (*Conversation) AddSession

func (c *Conversation) AddSession(ctx context.Context) (session *Session, index int)

func (*Conversation) IsActive

func (c *Conversation) IsActive() bool

type ConversationStatus

type ConversationStatus string
const (
	ConversationStatusActive   ConversationStatus = "active"
	ConversationStatusInactive ConversationStatus = "inactive"
	ConversationStatusClosed   ConversationStatus = "closed"
)

type ErrReply

type ErrReply struct {
	Ctx context.Context
	Job *Job
	Err error
}

type HandleError

type HandleError func(reply *ErrReply)

type HandlePostReply

type HandlePostReply func(ctx context.Context, job *Job) (*Job, error)

type HandlePreSend

type HandlePreSend func(ctx context.Context, job *Job) (*Job, error)

Middleware 是中间件函数的类型定义

type Job

type Job struct {
	Id      string   `json:"id"`
	Payload *Message `json:"payload"`
	Type    int      `json:"jobType"`
}

type Lora

type Lora struct {
	database.PowerModel

	Preview  string         `gorm:"comment:预览图" json:"preview"`
	Hash     string         `gorm:"comment:Hash" json:"hash"`
	Alias    string         `gorm:"comment:别名" json:"alias"`
	Name     string         `gorm:"comment:名称" json:"name"`
	Path     string         `gorm:"comment:路径" json:"path"`
	MetaData datatypes.JSON `gorm:"comment:元数据" json:"metadata"`
}

type Message

type Message struct {
	RobotModel

	ModelType   string         `gorm:"comment:模型类型" json:"modelType"`
	MessageType MessageType    `gorm:"comment:消息类型" json:"messageType"`
	Author      string         `gorm:"comment:作者" json:"author"`
	Content     datatypes.JSON `gorm:"comment:内容" json:"content"`
	Metadata    MetaData       `gorm:"comment:meta" json:"metadata"`
}

Message 是消息的结构定义

func CopyMessage

func CopyMessage(source *Message) *Message

func NewMessage

func NewMessage(msgType MessageType) *Message

type MessageType

type MessageType int

MessageType 是消息类型的枚举定义

const (
	TextMessage MessageType = iota
	ImageMessage
	AudioMessage
)

type MetaData

type MetaData struct {
	ErrMsg       string           `json:"errMsg"`
	ErrCode      int              `json:"errorCode"`
	Robot        *RobotAttributes `json:"robot"`
	Conversation *Conversation    `json:"conversation"`
	CustomerId   int64            `json:"customerId"`
	// 用来保存请问的原始数据,但是不用包含输入的图片
	RequestData datatypes.JSON `json:"requestData"`
}

type ModelInterface

type ModelInterface interface {
	GetTableName(needFull bool) string
	GetRobotModel() ModelInterface
	GetId() int64
	GetUuid() string
	GetPrimaryKey() string
	GetForeignRefer() string
	GetForeignReferValue() int64
}

type Pagination

type Pagination struct {
	Limit      int         `json:"limit"`
	Page       int         `json:"page"`
	Sort       string      `json:"sort"`
	TotalRows  int64       `json:"totalRows"`
	TotalPages int         `json:"totalPages"`
	Data       interface{} `json:"data"`
}

func GetList

func GetList(db *gorm.DB, conditions *map[string]interface{},
	models interface{}, preloads []string,
	page int, pageSize int) (paginator *Pagination, err error)

func NewPagination

func NewPagination(page int, limit int, sort string) *Pagination

func (*Pagination) GetLimit

func (p *Pagination) GetLimit() int

func (*Pagination) GetOffset

func (p *Pagination) GetOffset() int

func (*Pagination) GetPage

func (p *Pagination) GetPage() int

func (*Pagination) GetSort

func (p *Pagination) GetSort() string

func (*Pagination) SetLimit

func (p *Pagination) SetLimit(limit int) *Pagination

func (*Pagination) SetPage

func (p *Pagination) SetPage(page int) *Pagination

func (*Pagination) SetSort

func (p *Pagination) SetSort(sort string) *Pagination

type PowerUuidModel

type PowerUuidModel struct {
	Id        int64          `gorm:"autoIncrement:true;unique; column:id; ->;<-:create" json:"-"`
	Uuid      string         `gorm:"primaryKey;autoIncrement:false;unique; column:uuid; ->;<-:create " json:"uuid" sql:"index"`
	CreatedAt time.Time      `gorm:"column:created_at; ->;<-:create " json:"createdAt"`
	UpdatedAt time.Time      `gorm:"column:updated_at" json:"updatedAt"`
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

func NewPowerUuidModel

func NewPowerUuidModel() *PowerUuidModel

func (*PowerUuidModel) GetForeignRefer

func (mdl *PowerUuidModel) GetForeignRefer() string

func (*PowerUuidModel) GetForeignReferValue

func (mdl *PowerUuidModel) GetForeignReferValue() int64

func (*PowerUuidModel) GetId

func (mdl *PowerUuidModel) GetId() int64

func (*PowerUuidModel) GetPrimaryKey

func (mdl *PowerUuidModel) GetPrimaryKey() string

func (*PowerUuidModel) GetRobotModel

func (mdl *PowerUuidModel) GetRobotModel() ModelInterface

func (*PowerUuidModel) GetTableName

func (mdl *PowerUuidModel) GetTableName(needFull bool) string

func (*PowerUuidModel) GetUuid

func (mdl *PowerUuidModel) GetUuid() string

type RobotAttributes

type RobotAttributes struct {
	// attributes
	Name    string
	Version string
	Gender  RobotGender
	Type    RobotType
}

type RobotGender

type RobotGender int8
const (
	GenderMale RobotGender = iota
	GenderFemale
	GenderNeutral
)

type RobotModel

type RobotModel struct {
	Id int64 `gorm:"autoIncrement:true;unique; column:id; ->;<-:create" json:"id"`

	CreatedAt time.Time      `gorm:"column:created_at; ->;<-:create " json:"createdAt"`
	UpdatedAt time.Time      `gorm:"column:updated_at" json:"updatedAt"`
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

func NewRobotModel

func NewRobotModel() *RobotModel

func (*RobotModel) GetForeignRefer

func (mdl *RobotModel) GetForeignRefer() string

func (*RobotModel) GetForeignReferValue

func (mdl *RobotModel) GetForeignReferValue() int64

func (*RobotModel) GetId

func (mdl *RobotModel) GetId() int64

func (*RobotModel) GetPrimaryKey

func (mdl *RobotModel) GetPrimaryKey() string

func (*RobotModel) GetRobotModel

func (mdl *RobotModel) GetRobotModel() ModelInterface

func (*RobotModel) GetTableName

func (mdl *RobotModel) GetTableName(needFull bool) string

func (*RobotModel) GetUuid

func (mdl *RobotModel) GetUuid() string

type RobotType

type RobotType int8
const (
	TypeChatBot RobotType = iota
	TypeArtBot
)

type Role

type Role string
const (
	SystemRole    Role = "system"
	UserRole      Role = "user"
	AssistantRole Role = "assistant"
)

type Session

type Session struct {
	ID string

	Messages   []*Message
	Metadata   *object.HashMap
	StartTime  time.Time
	EndTime    time.Time
	IsComplete bool
	// contains filtered or unexported fields
}

func (*Session) GetContext

func (mdl *Session) GetContext() context.Context

func (*Session) SetContext

func (mdl *Session) SetContext(ctx context.Context)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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