Skip to main content

AFM LangChain execution backend

Project description

AFM LangChain Backend

PyPI version Python version License

LangChain execution backend for Agent-Flavored Markdown (AFM) agents.

This package implements the AgentRunner protocol from afm-core, providing LLM orchestration using the LangChain framework.

Features

  • AgentRunner Protocol Implementation: Pluggable backend for AFM agents
  • LLM Provider Support: OpenAI and Anthropic models
  • MCP Tool Integration: Connect external tools via Model Context Protocol
  • Conversation Management: Session history and state management
  • Plugin Registration: Auto-discovered via Python entry points

Installation

This package is typically installed as part of afm-cli. For LangChain-specific use:

pip install afm-langchain

Supported Providers

OpenAI

model:
  provider: openai
  name: gpt-4o  # or other OpenAI models

Requires: OPENAI_API_KEY environment variable

Anthropic

model:
  provider: anthropic
  name: claude-sonnet-4-5  # or other Claude models

Requires: ANTHROPIC_API_KEY environment variable

Development

Setup

This project uses uv for dependency management.

# Clone the repository
git clone https://github.com/wso2/reference-implementations-afm.git
cd python-interpreter

# Install dependencies
uv sync

# Activate the virtual environment
source .venv/bin/activate

Running Tests

# Run afm-langchain tests
uv run pytest packages/afm-langchain/tests/

# Run with coverage
uv run pytest packages/afm-langchain/tests/ --cov=afm_langchain

Code Quality

# Format code
uv run ruff format

# Lint code
uv run ruff check

Project Structure

packages/afm-langchain/src/afm_langchain/
├── __init__.py
├── backend.py          # LangChainRunner implementation
├── model_factory.py    # LLM provider factory
├── mcp_manager.py      # MCP tool management
└── tools_adapter.py    # Tool calling adapter

Usage

The LangChain backend is automatically registered and used when you run an AFM agent:

from afm.runner import get_runner

# Get the LangChain runner
runner = get_runner("langchain")

# Run an agent
result = await runner.run(agent, user_input)

Documentation

For comprehensive documentation, see the project README.

License

Apache-2.0

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

afm_langchain-0.1.3.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

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

afm_langchain-0.1.3-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: afm_langchain-0.1.3.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for afm_langchain-0.1.3.tar.gz
Algorithm Hash digest
SHA256 adf698525e27b1e5bd6325d185f4d9442f5878a03d10197f155a69f1c86a7658
MD5 e79476b494b87f5a3c33f3c65e261c1a
BLAKE2b-256 e24d591507ba249b251d87b1c154ab49372ab46bfa8ce0b4e0c26d41dbde9196

See more details on using hashes here.

File details

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

File metadata

  • Download URL: afm_langchain-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for afm_langchain-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2d081b4d4a268c036049d0822d49860e4039c9a0110f82f4ef691e224cc5ddd7
MD5 bdc4b65a6493e407ae78cdc0297d8ff1
BLAKE2b-256 aa02df734c6358b9127739363c1ef912525938e587916c3a4bc8a0ed81618db8

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