- Implemented UpdateAssistant method in Mongo, Redis, and Xun stores to allow partial updates of assistant fields. - Updated Store interface to include the new UpdateAssistant method, enhancing the flexibility of assistant management. - Added comprehensive tests for UpdateAssistant functionality, covering various scenarios including single and multiple field updates, JSON field handling, and error cases. - Updated API routes to support PUT requests for updating assistants, ensuring proper permission checks and response handling.
96 lines
3 KiB
Go
96 lines
3 KiB
Go
package store
|
|
|
|
import "github.com/yaoapp/yao/agent/store/types"
|
|
|
|
// Redis represents a Redis-based conversation storage
|
|
type Redis struct{}
|
|
|
|
// NewRedis create a new redis store
|
|
func NewRedis() types.Store {
|
|
return &Redis{}
|
|
}
|
|
|
|
// GetChats retrieves a list of chats
|
|
func (r *Redis) GetChats(sid string, filter types.ChatFilter, locale ...string) (*types.ChatGroupResponse, error) {
|
|
return &types.ChatGroupResponse{}, nil
|
|
}
|
|
|
|
// GetChat retrieves a single chat's information
|
|
func (r *Redis) GetChat(sid string, cid string, locale ...string) (*types.ChatInfo, error) {
|
|
return &types.ChatInfo{}, nil
|
|
}
|
|
|
|
// GetChatWithFilter retrieves a single chat's information with filter options
|
|
func (r *Redis) GetChatWithFilter(sid string, cid string, filter types.ChatFilter, locale ...string) (*types.ChatInfo, error) {
|
|
return &types.ChatInfo{}, nil
|
|
}
|
|
|
|
// GetHistory retrieves chat history
|
|
func (r *Redis) GetHistory(sid string, cid string, locale ...string) ([]map[string]interface{}, error) {
|
|
return []map[string]interface{}{}, nil
|
|
}
|
|
|
|
// GetHistoryWithFilter retrieves chat history with filter options
|
|
func (r *Redis) GetHistoryWithFilter(sid string, cid string, filter types.ChatFilter, locale ...string) ([]map[string]interface{}, error) {
|
|
return []map[string]interface{}{}, nil
|
|
}
|
|
|
|
// SaveHistory saves chat history
|
|
func (r *Redis) SaveHistory(sid string, messages []map[string]interface{}, cid string, context map[string]interface{}) error {
|
|
return nil
|
|
}
|
|
|
|
// DeleteChat deletes a single chat
|
|
func (r *Redis) DeleteChat(sid string, cid string) error {
|
|
return nil
|
|
}
|
|
|
|
// DeleteAllChats deletes all chats
|
|
func (r *Redis) DeleteAllChats(sid string) error {
|
|
return nil
|
|
}
|
|
|
|
// UpdateChatTitle updates chat title
|
|
func (r *Redis) UpdateChatTitle(sid string, cid string, title string) error {
|
|
return nil
|
|
}
|
|
|
|
// SaveAssistant saves assistant information
|
|
func (r *Redis) SaveAssistant(assistant *types.AssistantModel) (string, error) {
|
|
return assistant.ID, nil
|
|
}
|
|
|
|
// UpdateAssistant updates specific fields of an assistant
|
|
func (r *Redis) UpdateAssistant(assistantID string, updates map[string]interface{}) error {
|
|
return nil
|
|
}
|
|
|
|
// DeleteAssistant deletes an assistant
|
|
func (r *Redis) DeleteAssistant(assistantID string) error {
|
|
return nil
|
|
}
|
|
|
|
// GetAssistants retrieves a list of assistants
|
|
func (r *Redis) GetAssistants(filter types.AssistantFilter, locale ...string) (*types.AssistantList, error) {
|
|
return &types.AssistantList{}, nil
|
|
}
|
|
|
|
// GetAssistant retrieves a single assistant by ID
|
|
func (r *Redis) GetAssistant(assistantID string, locale ...string) (*types.AssistantModel, error) {
|
|
return nil, nil
|
|
}
|
|
|
|
// DeleteAssistants deletes assistants based on filter conditions (not implemented)
|
|
func (r *Redis) DeleteAssistants(filter types.AssistantFilter) (int64, error) {
|
|
return 0, nil
|
|
}
|
|
|
|
// GetAssistantTags retrieves all unique tags from assistants with filtering
|
|
func (r *Redis) GetAssistantTags(filter types.AssistantFilter, locale ...string) ([]types.Tag, error) {
|
|
return []types.Tag{}, nil
|
|
}
|
|
|
|
// Close closes the store and releases any resources
|
|
func (r *Redis) Close() error {
|
|
return nil
|
|
}
|