agentbee / src /tools /__init__.py
mangubee's picture
Stage 5: Performance optimization - retry logic, Groq integration, improved prompts
5890f66
raw
history blame
3.84 kB
"""
Tool implementations package
Author: @mangobee
This package contains all agent tools:
- web_search: Web search using Tavily/Exa
- file_parser: Multi-format file parsing (PDF/Excel/Word/Text)
- calculator: Safe mathematical expression evaluation
- vision: Multimodal image analysis using LLMs
Stage 2: All tools implemented with retry logic and error handling
"""
from src.tools.web_search import search, tavily_search, exa_search
from src.tools.file_parser import parse_file, parse_pdf, parse_excel, parse_word, parse_text
from src.tools.calculator import safe_eval
from src.tools.vision import analyze_image, analyze_image_gemini, analyze_image_claude
# Tool registry with metadata
# Schema matches LLM function calling requirements (parameters as dict, not list)
TOOLS = {
"web_search": {
"function": search,
"description": "Search the web for factual information, current events, Wikipedia articles, statistics, people, companies, and research. Use when question requires external knowledge not in context or files.",
"parameters": {
"query": {
"description": "Search query string",
"type": "string"
},
"max_results": {
"description": "Maximum number of search results to return (default: 5)",
"type": "integer"
}
},
"required_params": ["query"],
"category": "information_retrieval",
},
"parse_file": {
"function": parse_file,
"description": "Extract and parse content from uploaded files (PDF, Excel, Word, Text, CSV). Use when question references 'the file', 'uploaded document', 'attachment', or specific file formats. Reads file structure and text content.",
"parameters": {
"file_path": {
"description": "Absolute or relative path to the file to parse",
"type": "string"
}
},
"required_params": ["file_path"],
"category": "file_processing",
},
"calculator": {
"function": safe_eval,
"description": "Evaluate mathematical expressions and perform calculations (arithmetic, algebra, trigonometry, logarithms). Supports operators (+, -, *, /, **) and functions (sqrt, sin, cos, log, abs, etc). Use for any numerical computation or formula evaluation.",
"parameters": {
"expression": {
"description": "Mathematical expression to evaluate (e.g., '2 + 2', 'sqrt(16)', '25 * 37 + 100')",
"type": "string"
}
},
"required_params": ["expression"],
"category": "computation",
},
"vision": {
"function": analyze_image,
"description": "Analyze images or videos using multimodal AI vision models. Describe visual content, identify objects, read text from images, answer questions about photos or screenshots. Use when question mentions images, photos, pictures, videos, YouTube links, or visual content.",
"parameters": {
"image_path": {
"description": "Path to the image file to analyze",
"type": "string"
},
"question": {
"description": "Question to ask about the image (optional, defaults to 'Describe this image')",
"type": "string"
}
},
"required_params": ["image_path"],
"category": "multimodal",
},
}
__all__ = [
# Main unified tool functions
"search",
"parse_file",
"safe_eval",
"analyze_image",
# Specific implementations (for advanced use)
"tavily_search",
"exa_search",
"parse_pdf",
"parse_excel",
"parse_word",
"parse_text",
"analyze_image_gemini",
"analyze_image_claude",
# Tool registry
"TOOLS",
]