Skip to content
Joe Curlee (w4ffl35) edited this page Dec 1, 2025 · 2 revisions

LLM Tools

AI Runner provides a comprehensive set of tools that the LLM can use to interact with external services, manage knowledge, search the web, and more.

Overview

Tools are LangChain-compatible functions that extend the LLM's capabilities beyond text generation. The LLM autonomously decides when to use tools based on user requests.

Tool Categories

Search Tools

Tool Description
search_web Search the web using DuckDuckGo
search_news Search recent news articles
scrape_website Extract content from a specific URL

Example:

User: "What's the latest news about AI?"
AI: [calls search_news(query="artificial intelligence news")]

Knowledge Tools

Tool Description
record_knowledge Save a fact to the knowledge base
search_knowledge_base Search stored knowledge
rag_search Search indexed documents

Example:

User: "Remember that my favorite programming language is Python"
AI: [calls record_knowledge(text="User's favorite programming language is Python", section="Preferences")]

Utility Tools

Tool Description
get_current_datetime Get current date and time
get_weather Get weather for a location
calculate Perform mathematical calculations

System Tools

Tool Description
update_mood Update the AI's emotional state
clear_conversation Clear chat history
toggle_tts Enable/disable text-to-speech

Image Generation Tools

Tool Description
generate_image Generate images with Stable Diffusion
describe_image Describe an image using vision model

Aggregated Search

The AggregatedSearchTool provides a unified interface for searching multiple services:

from airunner.components.tools.search_tool import AggregatedSearchTool

# Search across multiple sources
results = await AggregatedSearchTool.aggregated_search(
    query="python asyncio",
    category="web"
)

Supported Services

  • DuckDuckGo - General web search
  • Google Custom Search - Google search API
  • Wikipedia - Encyclopedia search
  • arXiv - Academic papers
  • NewsAPI - News articles
  • StackExchange - Q&A sites
  • GitHub - Code repositories
  • OpenLibrary - Book search

Web Content Extraction

The WebContentExtractor extracts and processes content from web pages:

from airunner.components.tools.web_content_extractor import WebContentExtractor

# Extract main content from URL
content = WebContentExtractor.extract("https://example.com/article")

# Get clean text for RAG ingestion
clean_text = content.main_text

Features

  • Main content extraction (removes ads, navigation)
  • Metadata extraction (title, author, date)
  • Clean text output for LLM processing
  • Support for various content types

Tool Registration

Tools use the @tool decorator for automatic registration:

from airunner.components.llm.core.tool_registry import tool, ToolCategory

@tool(
    name="my_custom_tool",
    category=ToolCategory.RESEARCH,
    description="Does something useful",
    keywords=["custom", "useful"],  # For discovery
    defer_loading=False,  # True = loaded on-demand
    requires_api=False,  # True = needs API instance
)
def my_custom_tool(param1: str, param2: int = 10) -> str:
    """
    Tool docstring used for LLM guidance.
    
    Args:
        param1: First parameter description
        param2: Second parameter description
        
    Returns:
        Result description
    """
    return f"Result: {param1}, {param2}"

Code Execution

The LLM can execute Python code to orchestrate multiple tools:

# LLM calls execute_code tool
execute_code(code='''
# Batch search example
results = []
for query in ["topic1", "topic2", "topic3"]:
    results.append(search_web(query=query))
result = {"searches": results}
''')

This reduces round-trips and keeps intermediate data efficient.

See Tool-Agent-System for details.

Configuration

Installing Search Dependencies

pip install airunner[search]

API Keys

Some tools require API keys:

# Google Custom Search
export GOOGLE_API_KEY=your_key
export GOOGLE_CSE_ID=your_cse_id

# NewsAPI
export NEWS_API_KEY=your_key

# Weather
export OPENWEATHER_API_KEY=your_key

See Also

Clone this wiki locally