- Introduced a new `Search` type to store intermediate processing results, including extracted keywords, entities, relations, and generated QueryDSL for improved debugging and citation support. - Updated the `executeAutoSearch` method to populate the new `Search` structure, ensuring all relevant data is captured during search execution. - Implemented methods for saving and retrieving search records in MongoDB and Redis, enhancing data persistence across sessions. - Revised localization files to include new keys for search-related messages, improving user experience. - Updated DESIGN.md to reflect changes in the search result structure and data flow, ensuring comprehensive documentation of the new features.
187 lines
5.5 KiB
Go
187 lines
5.5 KiB
Go
package mongo
|
|
|
|
import "github.com/yaoapp/yao/agent/store/types"
|
|
|
|
// Mongo represents a MongoDB-based conversation storage
|
|
type Mongo struct{}
|
|
|
|
// NewMongo create a new mongo store
|
|
func NewMongo() types.Store {
|
|
return &Mongo{}
|
|
}
|
|
|
|
// =============================================================================
|
|
// Chat Management
|
|
// =============================================================================
|
|
|
|
// CreateChat creates a new chat session
|
|
func (m *Mongo) CreateChat(chat *types.Chat) error {
|
|
// TODO: implement
|
|
return nil
|
|
}
|
|
|
|
// GetChat retrieves a single chat by ID
|
|
func (m *Mongo) GetChat(chatID string) (*types.Chat, error) {
|
|
// TODO: implement
|
|
return nil, nil
|
|
}
|
|
|
|
// UpdateChat updates chat fields
|
|
func (m *Mongo) UpdateChat(chatID string, updates map[string]interface{}) error {
|
|
// TODO: implement
|
|
return nil
|
|
}
|
|
|
|
// DeleteChat deletes a chat and its associated messages
|
|
func (m *Mongo) DeleteChat(chatID string) error {
|
|
// TODO: implement
|
|
return nil
|
|
}
|
|
|
|
// ListChats retrieves a paginated list of chats with optional grouping
|
|
func (m *Mongo) ListChats(filter types.ChatFilter) (*types.ChatList, error) {
|
|
// TODO: implement
|
|
return nil, nil
|
|
}
|
|
|
|
// =============================================================================
|
|
// Message Management
|
|
// =============================================================================
|
|
|
|
// SaveMessages batch saves messages for a chat
|
|
func (m *Mongo) SaveMessages(chatID string, messages []*types.Message) error {
|
|
// TODO: implement
|
|
return nil
|
|
}
|
|
|
|
// GetMessages retrieves messages for a chat with filtering
|
|
func (m *Mongo) GetMessages(chatID string, filter types.MessageFilter) ([]*types.Message, error) {
|
|
// TODO: implement
|
|
return nil, nil
|
|
}
|
|
|
|
// UpdateMessage updates a single message
|
|
func (m *Mongo) UpdateMessage(messageID string, updates map[string]interface{}) error {
|
|
// TODO: implement
|
|
return nil
|
|
}
|
|
|
|
// DeleteMessages deletes specific messages from a chat
|
|
func (m *Mongo) DeleteMessages(chatID string, messageIDs []string) error {
|
|
// TODO: implement
|
|
return nil
|
|
}
|
|
|
|
// =============================================================================
|
|
// Resume Management (only called on failure/interrupt)
|
|
// =============================================================================
|
|
|
|
// SaveResume batch saves resume records
|
|
func (m *Mongo) SaveResume(records []*types.Resume) error {
|
|
// TODO: implement
|
|
return nil
|
|
}
|
|
|
|
// GetResume retrieves all resume records for a chat
|
|
func (m *Mongo) GetResume(chatID string) ([]*types.Resume, error) {
|
|
// TODO: implement
|
|
return nil, nil
|
|
}
|
|
|
|
// GetLastResume retrieves the last resume record for a chat
|
|
func (m *Mongo) GetLastResume(chatID string) (*types.Resume, error) {
|
|
// TODO: implement
|
|
return nil, nil
|
|
}
|
|
|
|
// GetResumeByStackID retrieves resume records for a specific stack
|
|
func (m *Mongo) GetResumeByStackID(stackID string) ([]*types.Resume, error) {
|
|
// TODO: implement
|
|
return nil, nil
|
|
}
|
|
|
|
// GetStackPath returns the stack path from root to the given stack
|
|
func (m *Mongo) GetStackPath(stackID string) ([]string, error) {
|
|
// TODO: implement
|
|
return nil, nil
|
|
}
|
|
|
|
// DeleteResume deletes all resume records for a chat
|
|
func (m *Mongo) DeleteResume(chatID string) error {
|
|
// TODO: implement
|
|
return nil
|
|
}
|
|
|
|
// =============================================================================
|
|
// Assistant Management
|
|
// =============================================================================
|
|
|
|
// SaveAssistant saves assistant information
|
|
func (m *Mongo) SaveAssistant(assistant *types.AssistantModel) (string, error) {
|
|
// TODO: implement
|
|
return assistant.ID, nil
|
|
}
|
|
|
|
// UpdateAssistant updates specific fields of an assistant
|
|
func (m *Mongo) UpdateAssistant(assistantID string, updates map[string]interface{}) error {
|
|
// TODO: implement
|
|
return nil
|
|
}
|
|
|
|
// DeleteAssistant deletes an assistant
|
|
func (m *Mongo) DeleteAssistant(assistantID string) error {
|
|
// TODO: implement
|
|
return nil
|
|
}
|
|
|
|
// GetAssistants retrieves a list of assistants
|
|
func (m *Mongo) GetAssistants(filter types.AssistantFilter, locale ...string) (*types.AssistantList, error) {
|
|
// TODO: implement
|
|
return &types.AssistantList{}, nil
|
|
}
|
|
|
|
// GetAssistantTags retrieves all unique tags from assistants with filtering
|
|
func (m *Mongo) GetAssistantTags(filter types.AssistantFilter, locale ...string) ([]types.Tag, error) {
|
|
// TODO: implement
|
|
return []types.Tag{}, nil
|
|
}
|
|
|
|
// GetAssistant retrieves a single assistant by ID
|
|
func (m *Mongo) GetAssistant(assistantID string, fields []string, locale ...string) (*types.AssistantModel, error) {
|
|
// TODO: implement
|
|
return nil, nil
|
|
}
|
|
|
|
// DeleteAssistants deletes assistants based on filter conditions
|
|
func (m *Mongo) DeleteAssistants(filter types.AssistantFilter) (int64, error) {
|
|
// TODO: implement
|
|
return 0, nil
|
|
}
|
|
|
|
// =============================================================================
|
|
// Search Management
|
|
// =============================================================================
|
|
|
|
// SaveSearch saves a search record for a request
|
|
func (m *Mongo) SaveSearch(search *types.Search) error {
|
|
// TODO: implement
|
|
return nil
|
|
}
|
|
|
|
// GetSearches retrieves all search records for a request
|
|
func (m *Mongo) GetSearches(requestID string) ([]*types.Search, error) {
|
|
// TODO: implement
|
|
return nil, nil
|
|
}
|
|
|
|
// GetReference retrieves a single reference by request ID and index
|
|
func (m *Mongo) GetReference(requestID string, index int) (*types.Reference, error) {
|
|
// TODO: implement
|
|
return nil, nil
|
|
}
|
|
|
|
// DeleteSearches deletes all search records for a chat
|
|
func (m *Mongo) DeleteSearches(chatID string) error {
|
|
// TODO: implement
|
|
return nil
|
|
}
|