Documentation ¶
Index ¶
- Constants
- Variables
- func AskImage(prompt string, size string) ([]byte, error)
- func CountTokens(content string) (int, error)
- func EditImage(filePath, prompt, size string) ([]byte, error)
- type ChatMessage
- type ChatMessages
- func (c *ChatMessages) AddMessage(content string, role ROLES) (*ChatMessage, error)
- func (c *ChatMessages) AddMessageFromFile(filename string) (*ChatMessage, error)
- func (c *ChatMessages) ClearMessages()
- func (c *ChatMessages) DeleteMessage(id int64) error
- func (c *ChatMessages) FilterByOpenAIRoles() []ChatMessage
- func (c *ChatMessages) FilterMessages(role ROLES) (messages []ChatMessage, tokens int)
- func (c *ChatMessages) FindById(id int64) *ChatMessage
- func (c *ChatMessages) FindByOrder(order uint) *ChatMessage
- func (c *ChatMessages) FindMessageByContent(content string) (*ChatMessage, error)
- func (c *ChatMessages) LastMessage(role ROLES) *ChatMessage
- func (c *ChatMessages) LoadFromFile(filename string) (err error)
- func (c *ChatMessages) RecountTokens() *ChatMessages
- func (c *ChatMessages) SaveChatInModelfileFormat(filename string) error
- func (c *ChatMessages) SaveToFile(filename string) error
- func (c *ChatMessages) SetAssociatedId(idUser, idAssistant int64) error
- func (c *ChatMessages) SetDescription(description string) *ChatMessages
- func (c *ChatMessages) SetId(id string) *ChatMessages
- func (c *ChatMessages) SetMessagesOrder() *ChatMessages
- func (c *ChatMessages) ToLangchainMessage() []llms.MessageContent
- func (c *ChatMessages) UpdateMessage(m ChatMessage) error
- type ContextHolder
- type ContextService
- func (cs *ContextService) AddContext(ctx context.Context, cancelFn func())
- func (cs *ContextService) AddContextWithId(ctx context.Context, cancelFn func(), id int64)
- func (cs *ContextService) CloseContext(ctx context.Context) error
- func (cs *ContextService) CloseContextById(id int64) error
- func (cs *ContextService) CloseLastContext() error
- func (cs *ContextService) FindContextWithId(id int64) *ContextHolder
- func (cs *ContextService) Length() int
- type FileMetadata
- type FileService
- func (s *FileService) Append(fileType FileType, msgContent, originalFileName string, msgId int64, ...) (*FileMetadata, error)
- func (s *FileService) Delete(id string) error
- func (s *FileService) Get(id string) (vfs.File, *FileMetadata, error)
- func (s *FileService) GetByMsgId(id int64, fileType FileType) (vfs.File, *FileMetadata, error)
- func (s *FileService) List(fileType FileType) ([]FileMetadata, error)
- func (s *FileService) SaveToOS(id string, destinationPath string) error
- type FileType
- type IContextService
- type IFileService
- type Meta
- type PromptConfig
- type ROLES
- type TYPE
Constants ¶
Variables ¶
View Source
var ErrAlreadyExist = errors.New("already exists")
View Source
var ErrNotFound = errors.New("not found")
Functions ¶
func CountTokens ¶
Types ¶
type ChatMessage ¶
type ChatMessage struct { Id snowflake.ID Role ROLES Content string Tokens int Type TYPE Order uint AssociatedMessageId int64 Date time.Time AudioFileId string `json:"-"` Meta Meta }
func (*ChatMessage) AsTypeFile ¶
func (c *ChatMessage) AsTypeFile() *ChatMessage
func (*ChatMessage) SetAudioFileId ¶
func (c *ChatMessage) SetAudioFileId(id string) *ChatMessage
type ChatMessages ¶
type ChatMessages struct { Id string Description string Messages []ChatMessage TotalTokens int // contains filtered or unexported fields }
func NewChatMessages ¶
func NewChatMessages(id string) *ChatMessages
func (*ChatMessages) AddMessage ¶
func (c *ChatMessages) AddMessage(content string, role ROLES) (*ChatMessage, error)
func (*ChatMessages) AddMessageFromFile ¶
func (c *ChatMessages) AddMessageFromFile(filename string) (*ChatMessage, error)
AddMessageFromFile reads the content of a file using os.ReadFile, then adds a new message with the file content and filename to the ChatMessages using the AddMessage method. If there's an error reading the file, it returns the error.
func (*ChatMessages) ClearMessages ¶
func (c *ChatMessages) ClearMessages()
func (*ChatMessages) DeleteMessage ¶
func (c *ChatMessages) DeleteMessage(id int64) error
func (*ChatMessages) FilterByOpenAIRoles ¶
func (c *ChatMessages) FilterByOpenAIRoles() []ChatMessage
func (*ChatMessages) FilterMessages ¶
func (c *ChatMessages) FilterMessages(role ROLES) (messages []ChatMessage, tokens int)
func (*ChatMessages) FindById ¶
func (c *ChatMessages) FindById(id int64) *ChatMessage
func (*ChatMessages) FindByOrder ¶
func (c *ChatMessages) FindByOrder(order uint) *ChatMessage
func (*ChatMessages) FindMessageByContent ¶
func (c *ChatMessages) FindMessageByContent(content string) (*ChatMessage, error)
func (*ChatMessages) LastMessage ¶
func (c *ChatMessages) LastMessage(role ROLES) *ChatMessage
func (*ChatMessages) LoadFromFile ¶
func (c *ChatMessages) LoadFromFile(filename string) (err error)
func (*ChatMessages) RecountTokens ¶
func (c *ChatMessages) RecountTokens() *ChatMessages
func (*ChatMessages) SaveChatInModelfileFormat ¶
func (c *ChatMessages) SaveChatInModelfileFormat(filename string) error
func (*ChatMessages) SaveToFile ¶
func (c *ChatMessages) SaveToFile(filename string) error
func (*ChatMessages) SetAssociatedId ¶
func (c *ChatMessages) SetAssociatedId(idUser, idAssistant int64) error
func (*ChatMessages) SetDescription ¶
func (c *ChatMessages) SetDescription(description string) *ChatMessages
func (*ChatMessages) SetId ¶
func (c *ChatMessages) SetId(id string) *ChatMessages
func (*ChatMessages) SetMessagesOrder ¶
func (c *ChatMessages) SetMessagesOrder() *ChatMessages
func (*ChatMessages) ToLangchainMessage ¶
func (c *ChatMessages) ToLangchainMessage() []llms.MessageContent
func (*ChatMessages) UpdateMessage ¶
func (c *ChatMessages) UpdateMessage(m ChatMessage) error
type ContextHolder ¶
func (ContextHolder) String ¶
func (c ContextHolder) String() string
type ContextService ¶
type ContextService struct {
Contexts []ContextHolder
}
func NewContextService ¶
func NewContextService() *ContextService
func (*ContextService) AddContext ¶
func (cs *ContextService) AddContext(ctx context.Context, cancelFn func())
func (*ContextService) AddContextWithId ¶
func (cs *ContextService) AddContextWithId(ctx context.Context, cancelFn func(), id int64)
func (*ContextService) CloseContext ¶
func (cs *ContextService) CloseContext(ctx context.Context) error
func (*ContextService) CloseContextById ¶
func (cs *ContextService) CloseContextById(id int64) error
func (*ContextService) CloseLastContext ¶
func (cs *ContextService) CloseLastContext() error
func (*ContextService) FindContextWithId ¶
func (cs *ContextService) FindContextWithId(id int64) *ContextHolder
func (*ContextService) Length ¶
func (cs *ContextService) Length() int
type FileMetadata ¶
type FileService ¶
type FileService struct {
// contains filtered or unexported fields
}
func NewFileService ¶
func NewFileService() (*FileService, error)
func (*FileService) Append ¶
func (s *FileService) Append(fileType FileType, msgContent, originalFileName string, msgId int64, data []byte) (*FileMetadata, error)
func (*FileService) Delete ¶
func (s *FileService) Delete(id string) error
func (*FileService) Get ¶
func (s *FileService) Get(id string) (vfs.File, *FileMetadata, error)
func (*FileService) GetByMsgId ¶
func (s *FileService) GetByMsgId(id int64, fileType FileType) (vfs.File, *FileMetadata, error)
func (*FileService) List ¶
func (s *FileService) List(fileType FileType) ([]FileMetadata, error)
type IContextService ¶
type IFileService ¶
type IFileService interface { Append(fileType FileType, msgContent string, originalFileName string, msgId int64, data []byte) (*FileMetadata, error) Delete(id string) error Get(id string) (vfs.File, *FileMetadata, error) GetByMsgId(id int64, fileType FileType) (vfs.File, *FileMetadata, error) List(fileType FileType) ([]FileMetadata, error) SaveToOS(id string, destinationPath string) error }
type PromptConfig ¶
type PromptConfig struct { ChatMessages *ChatMessages PreviousPrompt string UserPrompt string UpdateChan chan *ChatMessage Contexts IContextService Files IFileService }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.