Documentation
¶
Overview ¶
Package searchtool provides a search tool for agents to query document stores.
The search tool enables agents to perform semantic search across configured document stores, supporting features like:
- Scoped access (agent can only search assigned stores)
- Multiple store search with result aggregation
- Rich result metadata including source attribution
Derived from legacy pkg/tools/search.go
Index ¶
- type Config
- type SearchResponse
- type SearchResult
- type SearchTool
- func (t *SearchTool) Call(ctx tool.Context, args map[string]any) (map[string]any, error)
- func (t *SearchTool) Description() string
- func (t *SearchTool) IsLongRunning() bool
- func (t *SearchTool) Name() string
- func (t *SearchTool) RegisterStore(name string, store *rag.DocumentStore)
- func (t *SearchTool) RequiresApproval() bool
- func (t *SearchTool) Schema() map[string]any
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Stores maps store names to document stores.
Stores map[string]*rag.DocumentStore
// AvailableStores limits which stores this agent can search.
// Empty means all stores are available.
AvailableStores []string
// MaxLimit is the maximum results per search (safety limit).
// Default: 50
MaxLimit int
// DefaultLimit is the default results when limit not specified.
// Default: 10
DefaultLimit int
}
Config configures the search tool.
type SearchResponse ¶
type SearchResponse struct {
Results []SearchResult `json:"results"`
Total int `json:"total"`
Query string `json:"query"`
Duration string `json:"duration"`
StoresUsed []string `json:"stores_used"`
}
SearchResponse is returned to the agent.
type SearchResult ¶
type SearchResult struct {
DocumentID string `json:"document_id"`
StoreName string `json:"store_name"`
Content string `json:"content"`
Score float32 `json:"score"`
ChunkIndex int `json:"chunk_index,omitempty"`
SourcePath string `json:"source_path,omitempty"`
Title string `json:"title,omitempty"`
StartLine int `json:"start_line,omitempty"`
EndLine int `json:"end_line,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`
}
SearchResult represents a single search result.
type SearchTool ¶
type SearchTool struct {
// contains filtered or unexported fields
}
SearchTool allows agents to search document stores.
Key features:
- Scoped to specific document stores per agent
- Aggregates results from multiple stores
- Returns rich metadata for source attribution
Derived from legacy pkg/tools/search.go:SearchTool
func (*SearchTool) Description ¶
func (t *SearchTool) Description() string
Description returns the tool description with current store stats.
func (*SearchTool) IsLongRunning ¶
func (t *SearchTool) IsLongRunning() bool
IsLongRunning returns false - search is quick.
func (*SearchTool) RegisterStore ¶
func (t *SearchTool) RegisterStore(name string, store *rag.DocumentStore)
RegisterStore adds a document store.
func (*SearchTool) RequiresApproval ¶
func (t *SearchTool) RequiresApproval() bool
RequiresApproval returns false - search is read-only.
func (*SearchTool) Schema ¶
func (t *SearchTool) Schema() map[string]any
Schema returns the JSON schema for parameters.