AgentBay tools integration for LlamaIndex - provides browser automation, file operations, and command execution capabilities
Project description
LlamaIndex Tools Integration: AgentBay
This package provides AgentBay tools integration for LlamaIndex, enabling browser automation, file operations, and command execution capabilities in your LlamaIndex applications.
Installation
pip install llama-index-tools-agentbay
Requirements
- Python >= 3.8
- llama-index-core >= 0.12.0
- wuying-agentbay-sdk >= 0.9.0
- AgentBay API key (get it from AgentBay Console)
Quick Start
import os
from llama_index.llms.dashscope import DashScope
from llama_index.core.agent import ReActAgent
from llama_index.tools.agentbay import create_browser_agent_tools
# Create AgentBay browser tools (automatically handles all setup)
browser_tools = create_browser_agent_tools()
# Create LLM
llm = DashScope(
model_name="qwen-plus",
api_key=os.getenv("DASHSCOPE_API_KEY")
)
# Create Agent with AgentBay tools
agent = ReActAgent.from_tools(browser_tools, llm=llm, verbose=True)
# Use the agent
response = agent.chat("Please take a screenshot of https://www.example.com")
print(response)
Features
Two Simple Tool Sets
For Browser Automation:
create_browser_agent_tools()- Complete browser automation toolkit- Screenshot capture
- Browser endpoint access (for Playwright)
- File operations
- Command execution
For Code Execution:
create_code_agent_tools()- Complete code execution toolkit- Python code execution
- JavaScript code execution
- File operations (read, write, list, download)
- Command execution
Usage Examples
Browser Automation
from llama_index.tools.agentbay import create_browser_agent_tools
from llama_index.core.agent import ReActAgent
# Create browser tools (screenshot, file ops, commands)
tools = create_browser_agent_tools()
# Create agent
agent = ReActAgent.from_tools(tools, llm=llm)
# Use the agent
response = agent.chat("Take a screenshot of https://github.com")
Code Execution
from llama_index.tools.agentbay import create_code_agent_tools
from llama_index.core.agent import ReActAgent
# Create code execution tools (Python, JavaScript, file ops, commands)
tools = create_code_agent_tools()
# Create agent
agent = ReActAgent.from_tools(tools, llm=llm)
# Use the agent to run code
response = agent.chat("""
Create a CSV file with sample data and analyze it with pandas:
1. Create a CSV with sales data (product, quantity, price)
2. Read it with pandas
3. Calculate total revenue
4. Show the results
""")
Benefits:
- Direct code execution (no file upload needed)
- Supports Python and JavaScript
- Includes file operations for saving results
- Faster and more reliable
Choosing the Right Tool Set
Simple decision:
- Need browser automation? →
create_browser_agent_tools() - Need to run code (Python/JS)? →
create_code_agent_tools()
Both tool sets include file operations and command execution, so you get everything you need in one function call.
Environment Variables
Set your API keys as environment variables:
export AGENTBAY_API_KEY="your-agentbay-api-key"
export DASHSCOPE_API_KEY="your-dashscope-api-key" # For DashScope LLM
Advanced Features
RAG Integration for Insights
Automatically extract and index insights from code execution results:
from llama_index.tools.agentbay import create_code_agent_tools, create_rag_manager
# Create tools and RAG manager
tools = create_code_agent_tools()
rag_manager = create_rag_manager()
# Use with your agent to execute code and store results
# The RAG manager can index execution results for later querying
# Query the RAG index
answer = rag_manager.query("What insights did we discover?")
print(answer)
Complete 4-Stage Demo: See /examples/ for full workflow examples.
API Reference
Main Functions
create_browser_agent_tools()
- Returns: List of tools for browser automation
- Includes: screenshot, browser info, file operations, commands
- Use when: You need to automate browser tasks
create_code_agent_tools()
- Returns: List of tools for code execution
- Includes: Python/JS execution, file operations, commands
- Use when: You need to run code or process data
Both functions automatically handle session management and cleanup.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT License
Links
Support
For issues and questions:
- AgentBay SDK: GitHub Issues
- LlamaIndex: GitHub Issues
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llama_index_tools_agentbay-0.1.1.tar.gz.
File metadata
- Download URL: llama_index_tools_agentbay-0.1.1.tar.gz
- Upload date:
- Size: 16.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a60423fef02c5edb6f93cfdb882bb244f2b8480c0736481bbb87e57cb5fcfa4
|
|
| MD5 |
cfac40b30135c2a4c80b4500efe8d157
|
|
| BLAKE2b-256 |
3f2a6d9682e507cf2d4729ceec8f350246c7abfbd68d7af9e1e5ee486b04c485
|
File details
Details for the file llama_index_tools_agentbay-0.1.1-py3-none-any.whl.
File metadata
- Download URL: llama_index_tools_agentbay-0.1.1-py3-none-any.whl
- Upload date:
- Size: 20.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
21db579dfc43a1a4e2a6fae04218c3f162ef859037a6b64c870cc45c9e3c9ffc
|
|
| MD5 |
041dc2d431fde21163aeef49b8beb1e8
|
|
| BLAKE2b-256 |
08743ad3d70364c27ffcd477f90d7946296b2fc8436bc099b9fe9a827b1d37c7
|