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

Uploaded Python 3

File details

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

File metadata

  • Download URL: beam_langchain-0.5.1.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.1.tar.gz
Algorithm Hash digest
SHA256 738561b9151aa31aacd0938768222086c40c758a54ee2382912cdb179f93e4df
MD5 df2336ea5a62a8136fb71fd080d7c5e3
BLAKE2b-256 3520f1f691b13e39b59b548d692fe4129254ee897e7578285dc0f2535ef226e6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: beam_langchain-0.5.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e354ef28c3ce2bfd11504bef9076ad0a878af02af210ac32a26d8dc2849f38c9
MD5 acf6b1d7ad66f713f3e7f49655206240
BLAKE2b-256 6b614ab703160719209d7fe835c031ddbb99815a638503e2009d38a54e78f6ca

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