3 releases (breaking)
| 0.3.0 | Feb 1, 2026 |
|---|---|
| 0.2.0 | Jan 15, 2026 |
| 0.1.0 | Jan 15, 2026 |
#171 in Database implementations
70 downloads per month
Used in thulp-skills
93KB
2K
SLoC
thulp-query
Query engine for searching and filtering tools in the Thulp framework.
Overview
This crate provides a DSL for querying tool definitions by various criteria such as name, description, parameters, and more. It's particularly useful for building intelligent tool discovery systems that can match user intent to available tools.
Features
- Query tools by name with wildcard support
- Filter by description keywords
- Match tools with specific parameters
- Filter by parameter count (min/max)
- Combine criteria with AND/OR logic
- Natural language query parsing
- Efficient execution against tool collections
Usage
use thulp_query::{QueryBuilder, QueryCriteria};
use thulp_core::ToolDefinition;
// Create a query using the builder pattern
let query = QueryBuilder::new()
.name("file_*")
.description("read")
.min_parameters(1)
.build();
// Execute against a collection of tools
let tools: Vec<ToolDefinition> = vec![/* ... */];
let results = query.execute(&tools);
Natural Language Queries
The crate also supports parsing natural language queries:
use thulp_query::parse_query;
// Parse a natural language query
let criteria = parse_query("name:search and has:query").unwrap();
let query = Query::new(criteria);
Query Criteria
Name(String)- Match tools by name (supports wildcards with*)Description(String)- Match tools by description keywordHasParameter(String)- Match tools with specific parameterMinParameters(usize)- Match tools with at least N parametersMaxParameters(usize)- Match tools with at most N parametersAnd(Vec<QueryCriteria>)- Combine criteria with ANDOr(Vec<QueryCriteria>)- Combine criteria with ORNot(Box<QueryCriteria>)- Negate a criteria
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Dependencies
~3–5MB
~96K SLoC