- Implemented SaveAttachment, DeleteAttachment, GetAttachments, and GetAttachment methods for managing file attachments. - Introduced SaveKnowledge, DeleteKnowledge, GetKnowledges, and GetKnowledge methods for handling knowledge collections. - Enhanced the Store interface to include methods for attachment and knowledge management. - Updated tests to cover new attachment and knowledge functionalities, ensuring robust validation and error handling.
139 lines
4.3 KiB
Go
139 lines
4.3 KiB
Go
package store
|
|
|
|
// Mongo represents a MongoDB-based conversation storage
|
|
type Mongo struct{}
|
|
|
|
// NewMongo create a new mongo store
|
|
func NewMongo() Store {
|
|
return &Mongo{}
|
|
}
|
|
|
|
// GetChats retrieves a list of chats
|
|
func (m *Mongo) GetChats(sid string, filter ChatFilter, locale ...string) (*ChatGroupResponse, error) {
|
|
return &ChatGroupResponse{}, nil
|
|
}
|
|
|
|
// GetChat retrieves a single chat's information
|
|
func (m *Mongo) GetChat(sid string, cid string, locale ...string) (*ChatInfo, error) {
|
|
return &ChatInfo{}, nil
|
|
}
|
|
|
|
// GetChatWithFilter retrieves a single chat's information with filter options
|
|
func (m *Mongo) GetChatWithFilter(sid string, cid string, filter ChatFilter, locale ...string) (*ChatInfo, error) {
|
|
return &ChatInfo{}, nil
|
|
}
|
|
|
|
// GetHistory retrieves chat history
|
|
func (m *Mongo) GetHistory(sid string, cid string, locale ...string) ([]map[string]interface{}, error) {
|
|
return []map[string]interface{}{}, nil
|
|
}
|
|
|
|
// GetHistoryWithFilter retrieves chat history with filter options
|
|
func (m *Mongo) GetHistoryWithFilter(sid string, cid string, filter ChatFilter, locale ...string) ([]map[string]interface{}, error) {
|
|
return []map[string]interface{}{}, nil
|
|
}
|
|
|
|
// SaveHistory saves chat history
|
|
func (m *Mongo) SaveHistory(sid string, messages []map[string]interface{}, cid string, context map[string]interface{}) error {
|
|
return nil
|
|
}
|
|
|
|
// DeleteChat deletes a single chat
|
|
func (m *Mongo) DeleteChat(sid string, cid string) error {
|
|
return nil
|
|
}
|
|
|
|
// DeleteAllChats deletes all chats
|
|
func (m *Mongo) DeleteAllChats(sid string) error {
|
|
return nil
|
|
}
|
|
|
|
// UpdateChatTitle updates chat title
|
|
func (m *Mongo) UpdateChatTitle(sid string, cid string, title string) error {
|
|
return nil
|
|
}
|
|
|
|
// SaveAssistant saves assistant information
|
|
func (m *Mongo) SaveAssistant(assistant map[string]interface{}) (interface{}, error) {
|
|
return assistant["assistant_id"], nil
|
|
}
|
|
|
|
// DeleteAssistant deletes an assistant
|
|
func (m *Mongo) DeleteAssistant(assistantID string) error {
|
|
return nil
|
|
}
|
|
|
|
// GetAssistants retrieves a list of assistants
|
|
func (m *Mongo) GetAssistants(filter AssistantFilter, locale ...string) (*AssistantResponse, error) {
|
|
return &AssistantResponse{}, nil
|
|
}
|
|
|
|
// GetAssistant retrieves a single assistant by ID
|
|
func (m *Mongo) GetAssistant(assistantID string, locale ...string) (map[string]interface{}, error) {
|
|
return nil, nil
|
|
}
|
|
|
|
// DeleteAssistants deletes assistants based on filter conditions (not implemented)
|
|
func (m *Mongo) DeleteAssistants(filter AssistantFilter) (int64, error) {
|
|
return 0, nil
|
|
}
|
|
|
|
// GetAssistantTags retrieves all unique tags from assistants
|
|
func (m *Mongo) GetAssistantTags(locale ...string) ([]Tag, error) {
|
|
return []Tag{}, nil
|
|
}
|
|
|
|
// SaveAttachment saves attachment information
|
|
func (m *Mongo) SaveAttachment(attachment map[string]interface{}) (interface{}, error) {
|
|
return attachment["file_id"], nil
|
|
}
|
|
|
|
// DeleteAttachment deletes an attachment
|
|
func (m *Mongo) DeleteAttachment(fileID string) error {
|
|
return nil
|
|
}
|
|
|
|
// GetAttachments retrieves a list of attachments
|
|
func (m *Mongo) GetAttachments(filter AttachmentFilter, locale ...string) (*AttachmentResponse, error) {
|
|
return &AttachmentResponse{}, nil
|
|
}
|
|
|
|
// GetAttachment retrieves a single attachment by file ID
|
|
func (m *Mongo) GetAttachment(fileID string, locale ...string) (map[string]interface{}, error) {
|
|
return nil, nil
|
|
}
|
|
|
|
// DeleteAttachments deletes attachments based on filter conditions
|
|
func (m *Mongo) DeleteAttachments(filter AttachmentFilter) (int64, error) {
|
|
return 0, nil
|
|
}
|
|
|
|
// SaveKnowledge saves knowledge collection information
|
|
func (m *Mongo) SaveKnowledge(knowledge map[string]interface{}) (interface{}, error) {
|
|
return knowledge["collection_id"], nil
|
|
}
|
|
|
|
// DeleteKnowledge deletes a knowledge collection
|
|
func (m *Mongo) DeleteKnowledge(collectionID string) error {
|
|
return nil
|
|
}
|
|
|
|
// GetKnowledges retrieves a list of knowledge collections
|
|
func (m *Mongo) GetKnowledges(filter KnowledgeFilter, locale ...string) (*KnowledgeResponse, error) {
|
|
return &KnowledgeResponse{}, nil
|
|
}
|
|
|
|
// GetKnowledge retrieves a single knowledge collection by ID
|
|
func (m *Mongo) GetKnowledge(collectionID string, locale ...string) (map[string]interface{}, error) {
|
|
return nil, nil
|
|
}
|
|
|
|
// DeleteKnowledges deletes knowledge collections based on filter conditions
|
|
func (m *Mongo) DeleteKnowledges(filter KnowledgeFilter) (int64, error) {
|
|
return 0, nil
|
|
}
|
|
|
|
// Close closes the store and releases any resources
|
|
func (m *Mongo) Close() error {
|
|
return nil
|
|
}
|