Skip to main content

Tool retrieval and ranking algorithms for LLM agents

Project description

SAGE Tool Use

Tool retrieval and ranking algorithms for LLM agents

PyPI version Python 3.10+ License: MIT

🎯 Overview

sage-agentic-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-agentic-tooluse

# With embedding support
pip install isage-agentic-tooluse[embedding]

# Development installation
pip install isage-agentic-tooluse[dev]

🚀 Quick Start

Keyword-based Tool Selection

from sage_libs.sage_agentic_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_agentic_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_agentic_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_agentic_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_agentic_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

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

isage_agentic_tooluse-0.1.0.1-py3-none-any.whl (123.4 kB view details)

Uploaded Python 3

File details

Details for the file isage_agentic_tooluse-0.1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for isage_agentic_tooluse-0.1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 48709e4071cad289af2114352ea5e727fbc5b566394abc4d29971b4ea3dbb1b2
MD5 603c6d800844fd05894bd66db8d0be96
BLAKE2b-256 1e781922e69ec8574730b86fbe05b95e44812a0a0e1886b0cbaa592d9dcd6367

See more details on using hashes here.

Supported by

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