Skip to main content

SAGE Tool Use

Tool retrieval and ranking algorithms for LLM agents

PyPI version Python 3.10+ License: MIT

🎯 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

  1. Agent Tool Selection: Help agents choose the right tools
  2. API Discovery: Find relevant APIs for a task
  3. Function Calling: Select appropriate functions for LLMs
  4. Tool Recommendation: Recommend tools to users
  5. 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

🤝 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


Part of the SAGE ecosystem - Stream Analytics for Generative AI Engines

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

isage_tooluse-0.1.0.0.tar.gz (21.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

isage_tooluse-0.1.0.0-py3-none-any.whl (27.7 kB view details)

Uploaded Python 3

File details

Details for the file isage_tooluse-0.1.0.0.tar.gz.

File metadata

  • Download URL: isage_tooluse-0.1.0.0.tar.gz
  • Upload date:
  • Size: 21.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.11

File hashes

Hashes for isage_tooluse-0.1.0.0.tar.gz
Algorithm Hash digest
SHA256 e2818eed8aaa734d08c4d8c17cbe8299501c064b017e5fb526528b1c7f68697e
MD5 02af6ff3bebfbb4fb6aa20232a0f8a95
BLAKE2b-256 ecf74b6a96b291bd65b67e49b9bf27807e36b6797b4a3749cfdb10e29a5bb7c5

See more details on using hashes here.

File details

Details for the file isage_tooluse-0.1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for isage_tooluse-0.1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aa87d8d5a9b48917fdb99f977eaf68b0e65257001fcedc720789eac16490c8d3
MD5 b3e790c1e645889a44695958ed92015a
BLAKE2b-256 53c27c801431837bfddf742134b43185d198c2820b449d3ce0b84b3f210450b9

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0.0 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page