- Added initialization for the Search JSAPI factory in the Assistant module to streamline search operations. - Updated the DESIGN.md to reflect the new architecture of the search module, including detailed descriptions of the keyword extraction and QueryDSL generation processes. - Enhanced the interfaces for keyword extraction to require context, improving flexibility for different extraction modes. - Revised directory structures in the documentation to clarify the organization of search-related components, ensuring comprehensive guidance for developers.
35 lines
1.2 KiB
Go
35 lines
1.2 KiB
Go
package context
|
|
|
|
// SearchAPI defines the search JSAPI interface for ctx.search.*
|
|
// This interface is defined here to avoid circular dependency between context and search packages.
|
|
// The actual implementation is in agent/search/jsapi.go
|
|
type SearchAPI interface {
|
|
// Web executes web search
|
|
// Returns *types.Result or error information
|
|
Web(query string, opts map[string]interface{}) interface{}
|
|
|
|
// KB executes knowledge base search
|
|
// Returns *types.Result or error information
|
|
KB(query string, opts map[string]interface{}) interface{}
|
|
|
|
// DB executes database search
|
|
// Returns *types.Result or error information
|
|
DB(query string, opts map[string]interface{}) interface{}
|
|
|
|
// Parallel executes multiple searches in parallel
|
|
// Returns []*types.Result
|
|
Parallel(requests []interface{}) []interface{}
|
|
}
|
|
|
|
// SearchAPIFactory is a function type that creates a SearchAPI for a context
|
|
// This is set by the search package during initialization
|
|
var SearchAPIFactory func(ctx *Context) SearchAPI
|
|
|
|
// Search returns the search API for this context
|
|
// Returns nil if SearchAPIFactory is not set
|
|
func (ctx *Context) Search() SearchAPI {
|
|
if SearchAPIFactory == nil {
|
|
return nil
|
|
}
|
|
return SearchAPIFactory(ctx)
|
|
}
|