mirror of
https://github.com/mims-harvard/ToolUniverse.git
synced 2026-09-19 07:31:47 +08:00
08246bcd4d
* docs: expand redirect map with 15 additional legacy paths Adds redirects for paths uncovered in a second-pass audit against the live published site. Each destination verified to return HTTP 200 on https://zitniklab.hms.harvard.edu/ToolUniverse/. New /tutorials/ → /guide/, /tools/, /expand_tooluniverse/ redirects: - make_your_data_searchable, make_your_data_agent_searchable, build_search_and_share_datastores → guide/make_your_data_agent_searchable - skills → guide/skills_showcase - tool_finder → guide/finding_tools - overview → guide/index - remote_tools → tools/remote_tools - mcp_integration → expand_tooluniverse/remote_tools/mcp_integration Top-level legacy pages (404 at root, now redirected): - getting_started → guide/python_guide - deployment, contributing, changelog → about/<page> - faq → help/faq Local build confirms all 22 redirect stubs generate and that every destination file exists in the build output. * docs: fix broken sphinx-tabs, dead toctrees, orphan pages, missing image Build now produces 0 warnings/errors of these structural categories (down from ~280 such issues): - Re-enable sphinx_tabs.tabs extension (3.5.0 supports Sphinx 9.x); fixes 7 broken "Unknown directive type tabs" errors that made help/faq.html and help/troubleshooting.html render incomplete. - Drop 25+ dead toctree entries in api/modules.rst and api/tooluniverse.rst that referenced per-module pages never generated by sphinx-apidoc; modules.rst now points at the existing comprehensive tooluniverse autodoc page. - Wire 16 orphan pages into the master toctree so they're reachable from the navigation, including tooluniverse_case_study, visualization_tutorial, expert_feedback, literature_search_web_ui, euhealth, logging, openrouter, streaming, vllm, wechat_community, simbad_tools, the guide/index landing page, and the full expand_tooluniverse sub-tree. - Remove three stale ":doc:" links to old/{quickstart,installation, getting_started} from sitemap.rst (those directories are excluded from the build) and mark sitemap.rst as :orphan: since it's a parallel nav surface by design. - Mark MCP_TASKS_GUIDE.md as orphan and exclude the internal DOCUMENTATION_STRUCTURE.md meta-doc from the build. - Add the missing tools/remote/ui.jpg referenced by the remote expert_feedback page (previously: broken image). * docs: eliminate all 49 structural Sphinx ERRORs (broken tables, directives, headings) Round-3 build cleanup. Builds now finish with 0 structural ERRORs of any category (previous: 49 ERRORs spread across 20 files). Total warnings/errors dropped from 280 → 114; the remaining 114 are all in Python source-file docstrings (out of scope for a docs PR). Categories fixed: **Malformed tables** (8 files) Replace ASCII grid tables with mis-aligned pipes and inline-markdown pipe tables (which RST mis-parses as substitution references) with ``list-table`` directives that render correctly across all themes: - guide/literature_search_tools_tutorial.rst (two tables) - guide/cache_system.rst (env-var table whose first column overflowed) - guide/clinical_guidelines_tools.rst - guide/make_your_data_agent_searchable.rst - expand_tooluniverse/contributing/index.rst - expand_tooluniverse/contributing/remote_tools.rst - expand_tooluniverse/reference/index.rst **list-table indentation** (3 files) Option lines and list items were indented with 1 space (only valid for 3-space) so Sphinx silently dropped them and reported "exactly one bullet list expected": - guide/finding_tools.rst - guide/http_api.rst - guide/tools.rst **Code-block separators** (5 files, ~30 directives) Add the required blank line between an introductory paragraph and a following ``.. code-block::``. Without it, Sphinx treated the directive as a continuation of the paragraph and emitted "Unexpected indentation" for every line of the code: - guide/literature_search_tools_tutorial.rst - expand_tooluniverse/quick_start.rst - expand_tooluniverse/contributing/local_tools.rst - expand_tooluniverse/contributing/remote_tools.rst - guide/make_your_data_agent_searchable.rst **Heading-style + indentation** (3 files) - guide/building_ai_scientists/mcp_name_shortening.rst — strip stray leading spaces from two section titles + downgrade unknown ``.. critical::`` to ``.. important::`` - about/deployment.rst — remove rogue ``=========`` underline below numbered-list items that mis-led the parser into skipping heading levels - guide/make_your_data_agent_searchable.rst — extend four "title underline too short" underlines + convert four markdown ``` fences to RST literal blocks **Misc directive / target fixes** - guide/python_guide.rst — replace nonexistent ``.. success::`` with a tip-styled ``.. admonition::`` - guide/euhealth_tools_tutorial.rst — indent ``.. note::`` body so it is no longer an empty admonition - help/troubleshooting.rst — same fix + remove rogue ``=========`` line that was being read as a section overline - tools/cellosaurus_tools.rst — wrap ``CVCL_`` in literal backticks so the trailing underscore stops triggering missing-target lookups - expand_tooluniverse/index.rst — promote two leading-space bullet lists to standalone lists so the indentation is correct - expand_tooluniverse/reference/architecture.rst — switch ``.. graphviz::`` (extension not installed) to a plain ``.. code-block:: text``; the embedded content was Mermaid pseudo-code anyway - guide/tools.rst — strip leading space on a section title * docs: clear all remaining content warnings (lists, headings, refs, grids) Round-4 build cleanup. Builds now finish with 0 structural ERRORs and 0 content WARNINGs; the only remaining ~11 warnings are pre-existing autodoc infrastructure noise (duplicate object index entries from autosummary, and the ghost_tool / medrxiv_tool modules that genuinely fail to import) — none are in hand-written documentation. Fixes in this commit: **sphinx-design grids** (python_guide.rst) Re-indent two ``.. grid::`` blocks whose first card + options used 1-space indentation (Sphinx silently dropped them → "parent of grid-item should be grid-row"). Also fix a ``.. button-ref::`` whose content was indented 1 space, producing a broken ``:any:`` cross-reference, and point it at the absolute ``/api/modules``. **Numbered/bulleted sub-lists** (tool_composition, literature_search ×2, architecture, literature_search_web_ui, make_your_data, agentic_tools, finding_tools, euhealth) Insert the required blank line before nested lists and re-indent 1-space sub-bullets to align under their parent list marker. Clears ~80 "list ends without a blank line; unexpected unindent" warnings. **Title underlines** (logging, tool_caller, loading_tools, tool_composition, euhealth, make_your_data, contributing/local_tools, reference/index, remote_tools/tutorial, troubleshooting + bulk pass) Extend underlines shorter than their title text; strip stray leading spaces from section titles that Sphinx read as block quotes. **Stray markdown in RST** (make_your_data, local_tools) Convert leftover ``###`` headings and ``` ``` fences to proper RST directives; remove a rogue ``------`` separator that was being parsed as a section underline. **Duplicate autosectionlabel** (make_your_data) Rename the second "How it works" heading to "How sharing works". **uniprot_tools** (JSON + generated RST) Rephrase the ``min_length`` / ``max_length`` descriptions so the open-ended range syntax no longer contains a bare ``*`` that RST read as an unterminated emphasis marker. Fixed in the JSON source so it survives doc regeneration.
521 lines
14 KiB
ReStructuredText
521 lines
14 KiB
ReStructuredText
===============================
|
||
Tool Finder Tutorial
|
||
===============================
|
||
|
||
**Complete Tutorial to using ToolUniverse's three built-in tool discovery methods**
|
||
|
||
Introduction
|
||
============
|
||
|
||
ToolUniverse contains a vast repository of over 1000+ scientific tools. To help you quickly find the right tools for your research tasks, ToolUniverse provides three sophisticated tool finder methods, each optimized for different use cases and computational requirements.
|
||
|
||
Why Use Tool Finders?
|
||
---------------------
|
||
|
||
**The Challenge**: With hundreds of available tools across domains like bioinformatics, chemistry, literature search, and data analysis, manually browsing through tool lists is time-consuming and inefficient.
|
||
|
||
**The Solution**: ToolUniverse's tool finders allow you to describe your research task in natural language and automatically discover the most relevant tools.
|
||
|
||
**Three Approaches**:
|
||
- **Keyword Search**: Fast, precise, resource-efficient
|
||
- **LLM Search**: Intelligent, context-aware, handles complex queries
|
||
- **Embedding Search**: Semantic understanding, scalable, similarity-based
|
||
|
||
Overview of Tool Finder Methods
|
||
===============================
|
||
|
||
Strategic Trade-offs
|
||
--------------------
|
||
|
||
Each method offers different advantages:
|
||
|
||
.. list-table:: Tool Finder Comparison
|
||
:header-rows: 1
|
||
:widths: 20 25 25 25
|
||
|
||
* - Method
|
||
- Speed
|
||
- Semantic Understanding
|
||
- Resource Usage
|
||
* - **Keyword Search**
|
||
- Very Fast
|
||
- Basic
|
||
- Very Low
|
||
* - **LLM Search**
|
||
- Moderate
|
||
- Excellent
|
||
- High
|
||
* - **Embedding Search**
|
||
- Fast
|
||
- Good
|
||
- Moderate
|
||
|
||
When to Use Each Method
|
||
------------------------
|
||
|
||
** Keyword Search** - Use when:
|
||
- You know specific technical terms
|
||
- You need fast results
|
||
- Working with limited computational resources
|
||
- Looking for tools with specific names or exact terminology
|
||
|
||
** LLM Search** - Use when:
|
||
- You have complex, multi-step research questions
|
||
- Need intelligent interpretation of abstract goals
|
||
- Want tool sequence recommendations
|
||
- Have access to LLM APIs
|
||
|
||
** Embedding Search** - Use when:
|
||
- You want semantic similarity matching
|
||
- Need scalable search across large tool sets
|
||
- Looking for conceptually similar tools
|
||
- Want to find tools based on research intent rather than exact keywords
|
||
|
||
Method 1: Keyword Search
|
||
========================
|
||
|
||
How Keyword Search Works
|
||
------------------------
|
||
|
||
Keyword search uses a sophisticated text processing pipeline:
|
||
|
||
1. **Query Processing**:
|
||
|
||
- Tokenization via regular expressions
|
||
- Removal of 45+ common English stop words
|
||
- Suffix-based stemming using 20 morphological rules
|
||
- Generation of n-grams (bigrams and trigrams)
|
||
|
||
2. **Relevance Scoring**:
|
||
|
||
- Uses TF-IDF (Term Frequency-Inverse Document Frequency)
|
||
- Formula: ``Relevance = TF × IDF × log(1 + QueryFrequency)``
|
||
- Hierarchical bonus structure:
|
||
|
||
- Tool name matches: 2.0× multiplier
|
||
- Exact phrase matches: 1.5× multiplier
|
||
|
||
3. **Fast Matching**: Pre-built index ensures rapid search without ML dependencies
|
||
|
||
Using Keyword Search
|
||
---------------------
|
||
|
||
Basic Usage
|
||
~~~~~~~~~~~
|
||
|
||
.. code-block:: python
|
||
|
||
from tooluniverse import ToolUniverse
|
||
|
||
# Initialize ToolUniverse
|
||
tu = ToolUniverse()
|
||
# Load tool finder tools
|
||
tu.load_tools()
|
||
# if you want to load a subset of tools, `tool_finder` must be included in the list of tool types
|
||
# tu.load_tools(tool_type=["tool_finder", ...other tool types...])
|
||
|
||
# Use keyword search
|
||
result = tu.run({
|
||
"name": "Tool_Finder_Keyword",
|
||
"arguments": {
|
||
"description": "protein structure prediction",
|
||
"limit": 10
|
||
}
|
||
})
|
||
print(result)
|
||
|
||
Advanced Usage with Filters
|
||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
|
||
.. code-block:: python
|
||
|
||
from tooluniverse import ToolUniverse
|
||
|
||
# Initialize ToolUniverse
|
||
tu = ToolUniverse()
|
||
# Load tool finder tools
|
||
tu.load_tools()
|
||
|
||
# Search with category filtering
|
||
result = tu.run({
|
||
"name": "Tool_Finder_Keyword",
|
||
"arguments": {
|
||
"description": "drug discovery molecular similarity",
|
||
"limit": 5,
|
||
"categories": ["ChEMBL", "pubchem"] # Optional: filter by categories
|
||
}
|
||
})
|
||
|
||
Keyword Search Best Practices
|
||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
|
||
**Effective Queries**:
|
||
- Use specific scientific terminology: "CRISPR gene editing", "molecular docking", "phylogenetic analysis"
|
||
- Include domain-specific keywords: "protein", "drug", "genomic", "clinical"
|
||
- Use technical abbreviations: "PCR", "BLAST", "PDB"
|
||
|
||
Method 2: LLM Search
|
||
====================
|
||
|
||
How LLM Search Works
|
||
--------------------
|
||
|
||
LLM search leverages Large Language Models for intelligent tool discovery:
|
||
|
||
1. **Context Construction**: Creates detailed prompts combining user queries with tool specifications
|
||
2. **Intelligent Reasoning**: LLM analyzes context to infer optimal tools or tool sequences
|
||
3. **Complex Query Handling**: Excels at multi-step, abstract, or complex research questions
|
||
4. **Agentic Implementation**: Uses ToolUniverse's agentic tool framework
|
||
|
||
Using LLM Search
|
||
-----------------
|
||
|
||
Basic Usage
|
||
~~~~~~~~~~~
|
||
|
||
.. code-block:: python
|
||
|
||
from tooluniverse import ToolUniverse
|
||
|
||
# Initialize ToolUniverse
|
||
tu = ToolUniverse()
|
||
# Load tool finder tools
|
||
tu.load_tools()
|
||
|
||
# Set up environment variables first
|
||
import os
|
||
os.environ["AZURE_OPENAI_API_KEY"] = "your-api-key"
|
||
os.environ["AZURE_OPENAI_ENDPOINT"] = "https://your-endpoint.openai.azure.com"
|
||
|
||
# Use LLM search
|
||
result = tu.run({
|
||
"name": "Tool_Finder_LLM",
|
||
"arguments": {
|
||
"description": "I want to analyze the safety profile of a drug by looking at adverse events and clinical trial data",
|
||
"limit": 8
|
||
}
|
||
})
|
||
print(result)
|
||
|
||
Complex Multi-Step Queries
|
||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
|
||
.. code-block:: python
|
||
|
||
from tooluniverse import ToolUniverse
|
||
|
||
# Initialize ToolUniverse
|
||
tu = ToolUniverse()
|
||
# Load tool finder tools
|
||
tu.load_tools()
|
||
|
||
# Complex research workflow query
|
||
complex_query = """
|
||
I'm researching potential drug targets for Alzheimer's disease.
|
||
I need to:
|
||
1. Find proteins associated with Alzheimer's
|
||
2. Identify existing drugs that target these proteins
|
||
3. Search for recent literature on these drug-target interactions
|
||
4. Check for any adverse events reported for these drugs
|
||
"""
|
||
|
||
result = tu.run({
|
||
"name": "Tool_Finder_LLM",
|
||
"arguments": {
|
||
"description": complex_query,
|
||
"limit": 12
|
||
}
|
||
})
|
||
|
||
print(result)
|
||
|
||
Abstract Goal Interpretation
|
||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
|
||
.. code-block:: python
|
||
|
||
from tooluniverse import ToolUniverse
|
||
|
||
# Initialize ToolUniverse
|
||
tu = ToolUniverse()
|
||
# Load tool finder tools
|
||
tu.load_tools()
|
||
|
||
# Abstract research goals
|
||
abstract_queries = [
|
||
"I want to understand the molecular basis of cancer drug resistance",
|
||
"Help me find computational tools for personalized medicine research",
|
||
"I'm looking for ways to predict drug-drug interactions",
|
||
"Find tools for analyzing genetic variants in rare diseases"
|
||
]
|
||
|
||
for query in abstract_queries:
|
||
result = tu.run({
|
||
"name": "Tool_Finder_LLM",
|
||
"arguments": {
|
||
"description": query,
|
||
"limit": 6
|
||
}
|
||
})
|
||
|
||
print(f"\n🎯 Query: {query}")
|
||
print(f"Result: {result}")
|
||
|
||
LLM Search Best Practices
|
||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
|
||
**Effective Strategies**:
|
||
- Describe your research context and goals clearly
|
||
- Mention specific diseases, molecules, or research areas
|
||
- Include workflow steps if you have a multi-step process
|
||
- Ask for reasoning to understand why tools were recommended
|
||
|
||
Method 3: Embedding Search
|
||
==========================
|
||
|
||
How Embedding Search Works
|
||
--------------------------
|
||
|
||
Embedding search uses semantic similarity for tool discovery:
|
||
|
||
1. **Model Training**: Fine-tuned embedding model on synthetic query-tool pairs
|
||
2. **Offline Indexing**: Tool specifications converted to semantic vectors and stored in vector database
|
||
3. **Online Querying**: User queries converted to vectors and matched via cosine similarity
|
||
4. **Semantic Understanding**: Captures conceptual relationships beyond keyword matching
|
||
|
||
Using Embedding Search
|
||
-----------------------
|
||
|
||
Basic Usage
|
||
~~~~~~~~~~~
|
||
|
||
.. code-block:: python
|
||
|
||
from tooluniverse import ToolUniverse
|
||
|
||
# Initialize ToolUniverse
|
||
tu = ToolUniverse()
|
||
# Load tool finder tools
|
||
tu.load_tools()
|
||
|
||
# Use embedding search
|
||
result = tu.run({
|
||
"name": "Tool_Finder",
|
||
"arguments": {
|
||
"description": "analyze protein interactions",
|
||
"limit": 10
|
||
}
|
||
})
|
||
|
||
print(result)
|
||
|
||
Semantic Similarity Examples
|
||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
|
||
.. code-block:: python
|
||
|
||
from tooluniverse import ToolUniverse
|
||
|
||
# Initialize ToolUniverse
|
||
tu = ToolUniverse()
|
||
# Load tool finder tools
|
||
tu.load_tools()
|
||
|
||
# Embedding search excels at conceptual matching
|
||
semantic_queries = [
|
||
# These queries will find conceptually related tools
|
||
# even if exact keywords don't match
|
||
"molecular interactions", # Finds protein, drug, gene interaction tools
|
||
"therapeutic compounds", # Finds drug, chemical, pharmaceutical tools
|
||
"genetic variations", # Finds mutation, SNP, variant analysis tools
|
||
"disease mechanisms", # Finds pathway, target, biomarker tools
|
||
"clinical outcomes" # Finds trial, efficacy, safety tools
|
||
]
|
||
|
||
for query in semantic_queries:
|
||
result = tu.run({
|
||
"name": "Tool_Finder",
|
||
"arguments": {
|
||
"description": query,
|
||
"limit": 5
|
||
}
|
||
})
|
||
|
||
print(f"\n🔍 Semantic search for: '{query}'")
|
||
print(f"Result: {result}")
|
||
|
||
Advanced Embedding Search
|
||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||
|
||
.. code-block:: python
|
||
|
||
from tooluniverse import ToolUniverse
|
||
|
||
# Initialize ToolUniverse
|
||
tu = ToolUniverse()
|
||
# Load tool finder tools
|
||
tu.load_tools()
|
||
|
||
# Fine-tune search parameters
|
||
result = tu.run({
|
||
"name": "Tool_Finder",
|
||
"arguments": {
|
||
"description": "computational drug design",
|
||
"limit": 15,
|
||
"categories": ["ChEMBL", "pubchem", "opentarget"] # Filter categories
|
||
}
|
||
})
|
||
print(result)
|
||
|
||
Comparing Search Methods
|
||
========================
|
||
|
||
Practical Comparison
|
||
---------------------
|
||
|
||
Let's compare all three methods on the same query:
|
||
|
||
.. code-block:: python
|
||
|
||
from tooluniverse import ToolUniverse
|
||
|
||
# Initialize ToolUniverse
|
||
tu = ToolUniverse()
|
||
# Load tool finder tools
|
||
tu.load_tools()
|
||
|
||
query = "find drugs for treating diabetes"
|
||
|
||
# Method 1: Keyword Search
|
||
keyword_result = tu.run({
|
||
"name": "Tool_Finder_Keyword",
|
||
"arguments": {"description": query, "limit": 5}
|
||
})
|
||
|
||
# Method 2: LLM Search
|
||
llm_result = tu.run({
|
||
"name": "Tool_Finder_LLM",
|
||
"arguments": {"description": query, "limit": 5}
|
||
})
|
||
|
||
# Method 3: Embedding Search
|
||
embedding_result = tu.run({
|
||
"name": "Tool_Finder",
|
||
"arguments": {"description": query, "limit": 5}
|
||
})
|
||
|
||
# Compare results
|
||
print("🔍 KEYWORD SEARCH RESULTS:")
|
||
print(keyword_result)
|
||
|
||
print("\n🧠 LLM SEARCH RESULTS:")
|
||
print(llm_result)
|
||
|
||
print("\n🎯 EMBEDDING SEARCH RESULTS:")
|
||
print(embedding_result)
|
||
|
||
Performance Analysis
|
||
---------------------
|
||
|
||
Measure and compare performance:
|
||
|
||
.. code-block:: python
|
||
|
||
from tooluniverse import ToolUniverse
|
||
|
||
# Initialize ToolUniverse
|
||
tu = ToolUniverse()
|
||
# Load tool finder tools
|
||
tu.load_tools()
|
||
import time
|
||
|
||
test_queries = [
|
||
"protein structure analysis",
|
||
"drug adverse events",
|
||
"gene expression profiling",
|
||
"molecular similarity search"
|
||
]
|
||
|
||
def benchmark_search_method(method_name, queries):
|
||
times = []
|
||
total_results = 0
|
||
|
||
for query in queries:
|
||
start_time = time.time()
|
||
result = tu.run({
|
||
"name": method_name,
|
||
"arguments": {"description": query, "limit": 5}
|
||
})
|
||
end_time = time.time()
|
||
|
||
times.append(end_time - start_time)
|
||
total_results += len(result)
|
||
|
||
avg_time = sum(times) / len(times)
|
||
return avg_time, total_results
|
||
|
||
# Benchmark all methods
|
||
methods = [
|
||
"Tool_Finder_Keyword",
|
||
"Tool_Finder_LLM",
|
||
"Tool_Finder"
|
||
]
|
||
|
||
for method in methods:
|
||
avg_time, total_results = benchmark_search_method(method, test_queries)
|
||
print(f"{method}:")
|
||
print(f" Average time: {avg_time:.3f}s")
|
||
print(f" Total results: {total_results}")
|
||
|
||
Troubleshooting
|
||
===============
|
||
|
||
Common Issues and Solutions
|
||
----------------------------
|
||
|
||
**Issue**: LLM search fails
|
||
|
||
.. code-block:: python
|
||
|
||
# Check API configuration
|
||
import os
|
||
|
||
required_env_vars = [
|
||
"AZURE_OPENAI_API_KEY",
|
||
"AZURE_OPENAI_ENDPOINT"
|
||
]
|
||
|
||
for var in required_env_vars:
|
||
if not os.getenv(var):
|
||
print(f"❌ Missing environment variable: {var}")
|
||
else:
|
||
print(f"✅ {var} is set")
|
||
|
||
|
||
Conclusion
|
||
==========
|
||
|
||
ToolUniverse's three tool finder methods provide powerful and flexible approaches to discovering the right tools for your research:
|
||
|
||
** Keyword Search**: Perfect for precise, fast searches with technical terminology
|
||
|
||
** LLM Search**: Ideal for complex, multi-step research workflows requiring intelligence
|
||
|
||
** Embedding Search**: Excellent for semantic similarity and conceptual tool discovery
|
||
|
||
**Key Takeaways**:
|
||
|
||
1. **Choose the right method** for your specific use case and computational constraints
|
||
2. **Combine methods** for comprehensive tool discovery
|
||
3. **Optimize queries** based on the search method's strengths
|
||
4. **Use fallback strategies** when initial searches don't yield results
|
||
|
||
Happy tool hunting!
|
||
|
||
.. seealso::
|
||
|
||
- :doc:`../guide/tools` - Overview of all tools
|
||
- :doc:`../api/modules` - API reference
|
||
- :doc:`../tools/tools_config_index` - Tool catalog by category
|
||
- :doc:`../help/troubleshooting` - Common issues and solutions
|