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.1.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.1.0-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: beam_langchain-0.1.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.1.0.tar.gz
Algorithm Hash digest
SHA256 1bd13441246bc2962e6978ca420cbc59b25fd6e97d75a6b114835aff3a75f8fd
MD5 4b3069b8ac5b29e6c833bb8aa23ce6d9
BLAKE2b-256 7df8111eb2f9d057226c00c6cae3e752876a2529d5d30ae97b6d14b8d6f4801f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: beam_langchain-0.1.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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ce0faf0ef9860af1ae1fb645589760802bc8ca4b8c77106b602c8b7e580313c0
MD5 f9b4fc15f2ab1031c25c321936dde00e
BLAKE2b-256 d84323eab64e71840a0b17b1ac2e646a4ce3c7bc14041a20d65ceb53bf3471a9

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