searchtool

package
v1.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 24, 2025 License: AGPL-3.0 Imports: 9 Imported by: 0

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

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 New

func New(cfg Config) *SearchTool

New creates a new search tool.

func (*SearchTool) Call

func (t *SearchTool) Call(ctx tool.Context, args map[string]any) (map[string]any, error)

Call executes the search.

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) Name

func (t *SearchTool) Name() string

Name returns the tool name.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL