SAGE Tool Use
Tool retrieval and ranking algorithms for LLM agents
🎯 Overview
sage-tooluse provides a comprehensive suite of tool selection and ranking algorithms for LLM agents:
- Keyword Selector: Fast matching based on keyword overlap
- Embedding Selector: Semantic similarity using embeddings
- Hybrid Selector: Combines keyword and embedding approaches
- DFS-DT Selector: Decision tree-based tool selection
- Gorilla Adapter: Gorilla-style tool retrieval
📦 Installation
# Basic installation
pip install isage-tooluse
# With embedding support
pip install isage-tooluse[embedding]
# Development installation
pip install isage-tooluse[dev]
🚀 Quick Start
Keyword-based Tool Selection
from sage_libs.sage_tooluse import KeywordToolSelector
# Create selector
selector = KeywordToolSelector(tools=available_tools)
# Select tools for a query
selected = selector.select(
query="Get current weather in New York",
top_k=5
)
for tool in selected:
print(f"Tool: {tool.name}, Score: {tool.score}")
Embedding-based Tool Selection
from sage_libs.sage_tooluse import EmbeddingToolSelector
# Create selector with embedding model
selector = EmbeddingToolSelector(
tools=available_tools,
model_name="sentence-transformers/all-MiniLM-L6-v2"
)
# Select tools based on semantic similarity
selected = selector.select(
query="What's the weather like?",
top_k=5
)
Hybrid Tool Selection
from sage_libs.sage_tooluse import HybridToolSelector
# Combine keyword and embedding approaches
selector = HybridToolSelector(
tools=available_tools,
keyword_weight=0.3,
embedding_weight=0.7
)
selected = selector.select(query="...", top_k=5)
📚 Key Components
Selectors
- KeywordToolSelector: Fast keyword-based matching
- EmbeddingToolSelector: Semantic similarity using embeddings
- HybridToolSelector: Weighted combination of multiple selectors
- DFSDTToolSelector: Decision tree-based selection
- GorillaAdapter: Gorilla-style API-centric retrieval
Base Classes
- BaseToolSelector: Abstract base for all selectors
- ToolRegistry: Central registry for selector implementations
Schemas
- Tool: Tool representation with metadata
- ToolSelection: Selection result with scores
- SelectionContext: Context for tool selection
🏗️ Architecture
sage_libs.sage_tooluse/
├── __init__.py # Public API exports
├── base.py # Base selector interface
├── keyword_selector.py # Keyword-based selection
├── embedding_selector.py # Embedding-based selection
├── hybrid_selector.py # Hybrid selection strategy
├── dfsdt_selector.py # Decision tree selector
├── gorilla_selector.py # Gorilla-style retrieval
├── registry.py # Selector registry
├── schemas.py # Data schemas
└── retriever/ # Retrieval utilities
🎓 Use Cases
- Agent Tool Selection: Help agents choose the right tools
- API Discovery: Find relevant APIs for a task
- Function Calling: Select appropriate functions for LLMs
- Tool Recommendation: Recommend tools to users
- Multi-step Planning: Select tool sequences for complex tasks
🔗 Integration with SAGE
This package is part of the SAGE ecosystem and can be used with SAGE agents:
# Standalone usage
from sage_libs.sage_tooluse import HybridToolSelector
# With SAGE (when available, through interface layer)
from sage.libs.tooluse import create_selector
selector = create_selector("hybrid", tools=available_tools)
📖 Documentation
- Repository: https://github.com/intellistream/sage-tooluse
- SAGE Documentation: https://intellistream.github.io/SAGE-Pub/
- Issues: https://github.com/intellistream/sage-tooluse/issues
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
📄 License
MIT License - see LICENSE file for details.
🙏 Acknowledgments
Originally part of the sage-agentic package, now maintained as an independent repository for focused development and research.
📧 Contact
- Team: IntelliStream Team
- Email: shuhao_zhang@hust.edu.cn
- GitHub: https://github.com/intellistream
Part of the SAGE ecosystem - Stream Analytics for Generative AI Engines
Metadata
Release files for isage-tooluse 0.1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| isage_tooluse-0.1.0.0.tar.gz | 21.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| isage_tooluse-0.1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 49.3 kB
Release files / isage_tooluse-0.1.0.0.tar.gz
| Download URL | isage_tooluse-0.1.0.0.tar.gz |
|---|---|
| Size | 21.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e2818eed8aaa734d08c4d8c17cbe8299501c064b017e5fb526528b1c7f68697e
|
|
BLAKE2b-256 checksum How to use checksums |
ecf74b6a96b291bd65b67e49b9bf27807e36b6797b4a3749cfdb10e29a5bb7c5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.11
|
Release files / isage_tooluse-0.1.0.0-py3-none-any.whl
| Download URL | isage_tooluse-0.1.0.0-py3-none-any.whl |
|---|---|
| Size | 27.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
aa87d8d5a9b48917fdb99f977eaf68b0e65257001fcedc720789eac16490c8d3
|
|
BLAKE2b-256 checksum How to use checksums |
53c27c801431837bfddf742134b43185d198c2820b449d3ce0b84b3f210450b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.11
|