message

package
v0.0.0-...-e7f2ee2 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MessageTypes = map[MessageType]string{
	"User":      "user",
	"Assistant": "assistant",
}

Functions

This section is empty.

Types

type IMessageRepo

type IMessageRepo interface {
	FindMessageByParams(conversationSessionID string, modelID int64, messageType MessageType) (*Message, error)
	GetMaxSequenceNumber(conversationSessionID string, messageType MessageType) (int, error)
	CreateMessage(message *Message) error
	FindMessageBySessionID(conversationSessionID string) ([]*Message, error)
}

func ProvideMessageRepo

func ProvideMessageRepo(db *gorm.DB) IMessageRepo

type IMessageService

type IMessageService interface {
	CreateQuestionMessage(newQuestion *Message) (*Message, error)
	GetMaxSequenceNumber(conversationSessionID string, messageType MessageType) (int, error)
}

func ProvideMessageService

func ProvideMessageService(repo IMessageRepo, db *gorm.DB) IMessageService

type Message

type Message struct {
	ID                    int64     `json:"id" gorm:"column:id;primaryKey;autoIncrement"`
	ConversationSessionID string    `json:"conversation_session_id" gorm:"column:conversation_session_id;not null"`
	MessageType           string    `json:"message_type" gorm:"column:message_type;type:ENUM('user', 'assistant');not null"`
	Content               string    `json:"content" gorm:"column:content;not null"`
	Context               string    `json:"context" gorm:"column:context;"`
	Expand                string    `json:"expand" gorm:"column:expand;"`
	MaasID                *int64    `json:"maas_id" gorm:"column:maas_id"`
	SequenceNumber        int       `json:"sequence_number" gorm:"column:sequence_number;not null"`
	CreateTime            time.Time `json:"create_time" gorm:"column:create_time;autoCreateTime;type:datetime(0);"`
	ParentQuestionID      *int64    `json:"parent_question_id" gorm:"column:parent_question_id"`
}

func NewMessage

func NewMessage(attrs ...MessageAttrFunc) *Message

func (*Message) Mutate

func (m *Message) Mutate(attrs ...MessageAttrFunc) *Message

func (*Message) TableName

func (m *Message) TableName() string

type MessageAttrFunc

type MessageAttrFunc func(u *Message)

func WithContent

func WithContent(content string) MessageAttrFunc

func WithContext

func WithContext(context string) MessageAttrFunc

func WithConversationSessionID

func WithConversationSessionID(conversationSessionID string) MessageAttrFunc

func WithExpand

func WithExpand(expand string) MessageAttrFunc

func WithMaasID

func WithMaasID(maasID *int64) MessageAttrFunc

func WithMessageID

func WithMessageID(id int64) MessageAttrFunc

func WithMessageType

func WithMessageType(messageType string) MessageAttrFunc

func WithParentQuestionID

func WithParentQuestionID(parentId *int64) MessageAttrFunc

func WithSequenceNumber

func WithSequenceNumber(sequenceNumber int) MessageAttrFunc

type MessageAttrFuncs

type MessageAttrFuncs []MessageAttrFunc

type MessageRepo

type MessageRepo struct {
	// contains filtered or unexported fields
}

func (*MessageRepo) CreateMessage

func (m *MessageRepo) CreateMessage(message *Message) error

func (*MessageRepo) FindMessageByParams

func (m *MessageRepo) FindMessageByParams(conversationSessionID string, modelID int64, messageType MessageType) (*Message, error)

func (*MessageRepo) FindMessageBySessionID

func (m *MessageRepo) FindMessageBySessionID(conversationSessionID string) ([]*Message, error)

func (*MessageRepo) GetMaxSequenceNumber

func (m *MessageRepo) GetMaxSequenceNumber(conversationSessionID string, messageType MessageType) (int, error)

type MessageService

type MessageService struct {
	// contains filtered or unexported fields
}

func (*MessageService) CreateQuestionMessage

func (m *MessageService) CreateQuestionMessage(newQuestion *Message) (*Message, error)

func (*MessageService) GetMaxSequenceNumber

func (m *MessageService) GetMaxSequenceNumber(conversationSessionID string, messageType MessageType) (int, error)

type MessageType

type MessageType string

Jump to

Keyboard shortcuts

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