AFM LangChain execution backend
Project description
AFM LangChain Backend
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file afm_langchain-0.1.4.tar.gz.
File metadata
- Download URL: afm_langchain-0.1.4.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e33687d1545f896dcd2058c28c8ad9c9e22f0f8e4745989e571473b32e34ba4
|
|
| MD5 |
43a076987cf6175dcbfeceaaae956728
|
|
| BLAKE2b-256 |
893479bf70401ec902f0d450680f15dbf80bd737d09f19b3c7c8a09495ac697d
|
File details
Details for the file afm_langchain-0.1.4-py3-none-any.whl.
File metadata
- Download URL: afm_langchain-0.1.4-py3-none-any.whl
- Upload date:
- Size: 11.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d176f57db3a654a8cf4e9ac8bc79a441be5678858c1eae25439f72a0d255673c
|
|
| MD5 |
6653c044033aa23128a531bcab55d1b5
|
|
| BLAKE2b-256 |
7e733740177ab5d52b1a9eed7293e9681fc134cb7d2fd5b27fe923d74690a2ed
|