Documentation
¶
Overview ¶
Package toolsearch finds tools by what they say of themselves, for an agent offered more tools than its requests should carry: a catalog of the tools kept out of the requests, searched with BM25 over Porter2 stems, a listing of it that fits a budget of tokens, the entries of a call made through the bridge and the arguments of such a call checked against the tool's schema
Index ¶
- Constants
- func Bridge(name string) bool
- func Estimate(text string) int
- func Short(description string, most int) string
- func Stem(token string) string
- func Text(name, label, description string, parameters []string) string
- func Tokens(text string) []string
- func Validate(name string, parameters, args map[string]any) string
- type Call
- type Catalog
- type Entry
- type Form
- type Group
- type Hidden
- type Listed
Constants ¶
const ( SearchTool = "tool_search" DescribeTool = "tool_describe" CallTool = "tool_call" )
Names of the three tools that reach the tools found by search, which no other tool may take
const ( MostQueries = 7 MostNames = 10 )
Most queries one search takes and most names one describe takes
const ( SourceMCP = "mcp" SourcePlugin = "plugin" )
Where a tool found by search comes from, as the results say it
const ( Coverage = 0.5 MinCovered = 4 )
Share of the answerable terms of a query an entry must hold once the query has at least MinCovered of them, so a long query whose words are only scattered across tools finds nothing
const CharsPerToken = 4.0
Characters a token is taken to be where no counter counts them, which errs toward fewer tokens
const MostCalls = 10
Most entries one tool_call runs
const SummaryChars = 80
Longest summary of a tool a listing gives, its first sentence cut on a word
Variables ¶
This section is empty.
Functions ¶
func Short ¶
The first sentence of a description, its runs of space made one, cut on a word at most so many characters long with an ellipsis
func Stem ¶
Porter2 stem of one lower case token, so "issues" finds create_issue: kept once worked out, the same for the index and the query
func Text ¶
What of a tool is searched: the words of its name, its label when the name does not hold it, its description and the names of its parameters
func Tokens ¶
Lower case alphanumeric runs of the text, each stemmed, so what is indexed and what is asked meet
func Validate ¶
Why the arguments a tool_call gives the tool of the name do not fit its parameters, as the model reads it: the required ones it lacks, else the violation of the schema python-jsonschema's best_match would pick, with where it is and the parameters to retry with. Empty when they fit, and when the schema can't be checked here: one that refers to a schema elsewhere, which is never fetched, or one that does not compile, so a call is refused only for what is certainly wrong
Types ¶
type Call ¶
One tool a tool_call runs: its name and its arguments as a JSON object, every number as the model wrote it
type Catalog ¶
type Catalog struct {
// contains filtered or unexported fields
}
Tools a search looks through, with what BM25 counts over all of them
func NewCatalog ¶
A catalog of the entries, each indexed by the stems of its searched text
type Entry ¶
type Entry struct {
Name string
Description string
// Where it comes from as the results say it, SourceMCP or SourcePlugin, and the toolset it is of
Source, SourceName string
// Word the listing groups it under, such as the name of its MCP server
Label string
// Names of its parameters at the top of its schema, in their order, and those every call must give
Parameters, Required []string
// contains filtered or unexported fields
}
One tool a search may find
type Form ¶
type Form string
How much of the tools found by search a listing names, from the most to none
const ( // Every tool by its name and the first sentence of its description Full Form = "full" // Every tool by its name alone Names Form = "names" // The larger groups by their size alone, the others by their tools Mixed Form = "mixed" // Every group by its size alone Groups Form = "groups" // Nothing None Form = "none" )
func Listing ¶
func Listing(groups []Group, hidden []Hidden, budget int, count func(text string) int, always bool) (string, Form)
The listing of the tools found by search that fits the budget of tokens as the count counts them: every tool with its summary, else every tool by name, else the largest groups summarized first, else every group summarized; empty when not even that fits, unless always is set, when every group is summarized whatever it takes. With the form it took