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.from_tools(tools, llm=llm, verbose=True)
        response = await agent.achat("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.4.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.4-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: llama_index_tools_agentbay-0.1.4.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.4.tar.gz
Algorithm Hash digest
SHA256 2defa46653acac21f371e9d598d670303140141cacc3518933f8fdb3bb2aac8f
MD5 6317ec442041ca5b9abb370bee35863b
BLAKE2b-256 1bb26776784643d084e7030a7e9cfb4e6c1096d968c55cdf1800393e35fe1221

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for llama_index_tools_agentbay-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 16d6b936860ffb6a27d8aa5c0d2358c0ad42be42f3d2a33ae57439ef1ce95397
MD5 3d229824c85fb94169d92de27bbfbb8b
BLAKE2b-256 9226f8b273273dbc640444a6f76b0421e54a8f4492912c065c66bd15acc3f2ef

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