- Introduced a new search configuration structure, allowing for detailed settings for web, knowledge base, database, citation, and weights. - Updated the `Assistant` model to include a `Search` field, enabling assistant-specific search configurations. - Enhanced the loading and merging logic for search configurations, ensuring global defaults can be overridden by assistant-specific settings. - Added comprehensive tests for loading, saving, and updating assistants with search configurations, verifying the integrity of search settings. - Updated documentation in DESIGN.md to reflect the new search configuration hierarchy and usage, clarifying the interaction between global and assistant-level settings.
29 lines
700 B
Go
29 lines
700 B
Go
package search
|
|
|
|
import (
|
|
"github.com/yaoapp/yao/agent/search/interfaces"
|
|
"github.com/yaoapp/yao/agent/search/types"
|
|
)
|
|
|
|
// Registry manages search handlers
|
|
type Registry struct {
|
|
handlers map[types.SearchType]interfaces.Handler
|
|
}
|
|
|
|
// NewRegistry creates a new handler registry
|
|
func NewRegistry() *Registry {
|
|
return &Registry{
|
|
handlers: make(map[types.SearchType]interfaces.Handler),
|
|
}
|
|
}
|
|
|
|
// Register registers a handler for a search type
|
|
func (r *Registry) Register(handler interfaces.Handler) {
|
|
r.handlers[handler.Type()] = handler
|
|
}
|
|
|
|
// Get returns the handler for a search type
|
|
func (r *Registry) Get(t types.SearchType) (interfaces.Handler, bool) {
|
|
h, ok := r.handlers[t]
|
|
return h, ok
|
|
}
|