Skip to main content

AgentBay tools integration for LlamaIndex - provides browser automation, file operations, and command execution capabilities

Project description

LlamaIndex Tools Integration: AgentBay

AgentBay tools integration for LlamaIndex, enabling browser automation, file operations, and command execution.

Installation

pip install llama-index-tools-agentbay llama-index-llms-openai-like

Setup

Set your API keys as environment variables:

export AGENTBAY_API_KEY="your-agentbay-api-key"
export DASHSCOPE_API_KEY="your-dashscope-api-key"  # Optional: For DashScope LLM

Quick Start

Use the context manager for automatic resource cleanup:

import os
import asyncio
from llama_index.llms.openai_like import OpenAILike
from llama_index.core.agent import ReActAgent
from llama_index.tools.agentbay import create_code_tools, AgentBaySessionManager
from contextlib import contextmanager

@contextmanager
def agentbay_tools():
    manager = AgentBaySessionManager(api_key=os.getenv("AGENTBAY_API_KEY"))
    try:
        yield create_code_tools(manager)
    finally:
        manager.cleanup()

async def main():
    llm = OpenAILike(
        model="qwen-plus",
        api_key=os.getenv("DASHSCOPE_API_KEY"),
        api_base="https://dashscope.aliyuncs.com/compatible-mode/v1",
        is_chat_model=True
    )

    with agentbay_tools() as tools:
        # Note: ReActAgent in llama-index-core >= 0.14.0 is workflow-based
        agent = ReActAgent(tools=tools, llm=llm, verbose=True)
        response = await agent.run(user_msg="Calculate the 10th Fibonacci number using Python")
        print(response.response)

if __name__ == "__main__":
    asyncio.run(main())

Available Tools

  • Code Execution: create_code_tools (Recommended) - Run Python/JS code directly.
  • Browser Automation: create_browser_tools - Take screenshots, inspect pages.
  • File Operations: create_filesystem_tools - Read/Write files.
  • Command Execution: create_command_tools - Run shell commands.

RAG Integration

Extract insights from execution results:

from llama_index.tools.agentbay import create_rag_manager

rag = create_rag_manager()
rag.add_execution_result("result content", "task description")
print(rag.query("What was the result?"))

Support

License

MIT

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.3.tar.gz (12.0 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.3-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: llama_index_tools_agentbay-0.1.3.tar.gz
  • Upload date:
  • Size: 12.0 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.3.tar.gz
Algorithm Hash digest
SHA256 6dc9c0dccc66b73fc505772fba2886240de801253f7329fe7a623e1f268d2213
MD5 5488a2303bdc8436370ff18ce177eec4
BLAKE2b-256 1bd11c35743654e30659ddd5e2640a6e3c3582d081738be42968f645f3413f3d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for llama_index_tools_agentbay-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 78910c0077d228574861cc17603326f466dc855b68345e8c1eda618179dae4ea
MD5 c627a7dd346d09f777d809361ecb0811
BLAKE2b-256 63231564f4f868cb8e1b36e79e2a3758b2e87c187ee36c0c729e23fd4b503390

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