Skip to main content

LangChain tools and toolkit for Beam Protocol agent-to-agent communication

Project description

beam-langchain

LangChain integration for the Beam Protocol.

This package bridges LangChain tools with Beam's agent-to-agent messaging model so an LLM can:

  • send natural-language messages to remote Beam agents with conversation.message
  • expose Beam agent capabilities as LangChain tools
  • use the hosted Beam directory at https://api.beam.directory

Installation

pip install beam-langchain

Quick Start

import asyncio

from beam_directory import BeamClient, BeamIdentity
from beam_langchain import BeamAgentTool, BeamToolkit


async def main() -> None:
    identity = BeamIdentity.generate(agent_name="planner", org_name="demo")
    client = BeamClient(identity=identity, directory_url="https://api.beam.directory")

    message_tool = BeamAgentTool(
        client=client,
        beam_id="researcher@demo.beam.directory",
        name="beam_researcher_message",
        description="Ask the remote research agent for a natural-language answer.",
    )

    reply = await message_tool._arun(message="Summarize today's support queue.")
    print(reply)

    toolkit = await BeamToolkit.afrom_agents(
        client,
        ["researcher@demo.beam.directory"],
    )
    for tool in toolkit.get_tools():
        print(tool.name)


asyncio.run(main())

API

BeamAgentTool

BeamAgentTool wraps Beam's conversation.message intent as a LangChain tool.

tool = BeamAgentTool(
    client=client,
    beam_id="support@demo.beam.directory",
)

answer = await tool._arun(
    message="What incidents are still open?",
    context={"priority": "high"},
)

BeamToolkit

BeamToolkit converts Beam agents and their advertised capabilities into LangChain tools.

from beam_directory.types import AgentSearchQuery

toolkit = await BeamToolkit.afrom_search(
    client,
    AgentSearchQuery(org="demo", limit=5),
)

tools = toolkit.get_tools()

Each discovered agent produces:

  • one BeamAgentTool for conversation.message
  • one intent tool per declared Beam capability

Development

cd packages/beam-langchain
python -m venv .venv
source .venv/bin/activate
pip install -e .
python -m unittest discover -s tests

License

Apache 2.0 — see ../../LICENSE.

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

beam_langchain-0.5.0.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

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

beam_langchain-0.5.0-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file beam_langchain-0.5.0.tar.gz.

File metadata

  • Download URL: beam_langchain-0.5.0.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for beam_langchain-0.5.0.tar.gz
Algorithm Hash digest
SHA256 b35b8b630b5685fde3a76670c7490cf779ab51d5fcd4c3e8c87b119576d37152
MD5 28460a34a2bc6011578c84dd34d29345
BLAKE2b-256 c85057586b07e4bdc8e231d5d18b3463ba34176736bf883e9fd66bc5db9c28ac

See more details on using hashes here.

File details

Details for the file beam_langchain-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: beam_langchain-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for beam_langchain-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9d9dbdcb30b85d043514a7a4452179e672d89b03bcea5579858dfdd5918d29c0
MD5 e40f005af92befb414b08a5b90718125
BLAKE2b-256 184dde2824242b8ee57712d1aa405774411968bea880ed04c9bc0fda1463ef09

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