Documentation
¶
Index ¶
- type BM25
- func (bm *BM25) AddDocument(doc Document)
- func (bm *BM25) AddDocuments(docs []Document)
- func (bm *BM25) Clear()
- func (bm *BM25) DocumentCount() int
- func (bm *BM25) GetDocument(id string) *Document
- func (bm *BM25) RemoveDocument(id string) bool
- func (bm *BM25) Search(query string, topK int) []SearchResult
- func (bm *BM25) UpdateDocument(doc Document) bool
- type Document
- type SearchResult
- type ToolIndex
- func (ti *ToolIndex) Clear()
- func (ti *ToolIndex) Count() int
- func (ti *ToolIndex) Export() ([]byte, error)
- func (ti *ToolIndex) GetActiveTools() []ToolIndexEntry
- func (ti *ToolIndex) GetAllTools() []ToolIndexEntry
- func (ti *ToolIndex) GetDeferredTools() []ToolIndexEntry
- func (ti *ToolIndex) GetTool(name string) *ToolIndexEntry
- func (ti *ToolIndex) Import(data []byte) error
- func (ti *ToolIndex) IndexTool(tool tools.Tool, source string, deferred bool) error
- func (ti *ToolIndex) IndexToolEntry(entry ToolIndexEntry) error
- func (ti *ToolIndex) RemoveTool(name string) bool
- func (ti *ToolIndex) Search(query string, topK int) []ToolSearchResult
- func (ti *ToolIndex) SearchByCategory(category string) []ToolIndexEntry
- type ToolIndexEntry
- type ToolSearchResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BM25 ¶
type BM25 struct {
// contains filtered or unexported fields
}
BM25 实现 BM25 搜索算法 BM25 (Best Matching 25) 是一种经典的文本相关性排序算法
func (*BM25) RemoveDocument ¶
RemoveDocument 从索引中移除文档 注意:这个操作需要重建索引,性能较低
type Document ¶
type Document struct {
ID string // 文档唯一标识
Content string // 文档内容
Metadata map[string]any // 附加元数据
}
Document 可搜索的文档
type SearchResult ¶
SearchResult 搜索结果
type ToolIndex ¶
type ToolIndex struct {
// contains filtered or unexported fields
}
ToolIndex 工具索引系统 使用 BM25 算法对工具进行索引和搜索
func (*ToolIndex) GetActiveTools ¶
func (ti *ToolIndex) GetActiveTools() []ToolIndexEntry
GetActiveTools 获取所有活跃的工具(非延迟加载)
func (*ToolIndex) GetAllTools ¶
func (ti *ToolIndex) GetAllTools() []ToolIndexEntry
GetAllTools 获取所有工具条目
func (*ToolIndex) GetDeferredTools ¶
func (ti *ToolIndex) GetDeferredTools() []ToolIndexEntry
GetDeferredTools 获取所有延迟加载的工具
func (*ToolIndex) GetTool ¶
func (ti *ToolIndex) GetTool(name string) *ToolIndexEntry
GetTool 获取工具条目
func (*ToolIndex) IndexToolEntry ¶
func (ti *ToolIndex) IndexToolEntry(entry ToolIndexEntry) error
IndexToolEntry 直接索引条目(用于 MCP 延迟加载的工具)
func (*ToolIndex) RemoveTool ¶
RemoveTool 从索引中移除工具
func (*ToolIndex) Search ¶
func (ti *ToolIndex) Search(query string, topK int) []ToolSearchResult
Search 搜索工具
func (*ToolIndex) SearchByCategory ¶
func (ti *ToolIndex) SearchByCategory(category string) []ToolIndexEntry
SearchByCategory 按分类搜索
type ToolIndexEntry ¶
type ToolIndexEntry struct {
Name string `json:"name"`
Description string `json:"description"`
InputSchema map[string]any `json:"input_schema"`
Category string `json:"category,omitempty"`
Keywords []string `json:"keywords,omitempty"`
Examples []tools.ToolExample `json:"examples,omitempty"`
Deferred bool `json:"deferred"`
Source string `json:"source"` // "builtin", "mcp", "custom"
Metadata map[string]any `json:"metadata,omitempty"`
}
ToolIndexEntry 工具索引条目
type ToolSearchResult ¶
type ToolSearchResult struct {
Entry ToolIndexEntry `json:"entry"`
Score float64 `json:"score"`
Rank int `json:"rank"`
Snippets []string `json:"snippets,omitempty"` // 匹配的文本片段
}
ToolSearchResult 工具搜索结果
Click to show internal directories.
Click to hide internal directories.