Skip to main content

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:

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

llama_index_tools_agentbay-0.1.0.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

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

llama_index_tools_agentbay-0.1.0-py3-none-any.whl (20.2 kB view details)

Uploaded Python 3

File details

Details for the file llama_index_tools_agentbay-0.1.0.tar.gz.

File metadata

  • Download URL: llama_index_tools_agentbay-0.1.0.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.13.7 Darwin/24.6.0

File hashes

Hashes for llama_index_tools_agentbay-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e4fa72a23312c14ec31fc0b400ea4b15f4eefa8ad68779972b34740bc1880d80
MD5 c3514905e331d4eec839396780e9aa79
BLAKE2b-256 3f58fec730dd7902b68bc2b05bb304a38e872f29f6c026e5976fcb0168a59d7a

See more details on using hashes here.

File details

Details for the file llama_index_tools_agentbay-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for llama_index_tools_agentbay-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d4ca6abeb3aec9ed605ac8953b1cbe0ab9c66043b16971c493b72b80e72fe4cc
MD5 ddff67f3e926dfbdccc74a36e3a1d74d
BLAKE2b-256 0b33a9aad6b25c4839423f265a6128ad69ca1450540b5874b0d38b79774da6bd

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