Skip to main content

AFM (Agent-Flavored Markdown) interpreter using LangChain

Project description

AFM LangChain Interpreter

A LangChain-based reference implementation of an interpreter for Agent-Flavored Markdown (AFM) files.

Features

  • Support for all interface types:
    • Console chat (interactive CLI)
    • Web chat (HTTP API + optional UI)
    • Webhook (WebSub-based event handling)
  • Multi-interface agents - run multiple interfaces simultaneously
  • MCP support for tools (Model Context Protocol)
  • Validation - dry-run mode to validate AFM definitions

Prerequisites

  • Python 3.12 or later.
  • uv for dependency management.

Installation

Using pipx (Recommended)

To run afm as a standalone command-line tool:

pipx install afm-cli

Using pip

pip install afm-cli

Quick Start

# Set your API Key
export OPENAI_API_KEY="your-api-key-here"

# Run with an AFM file
afm path/to/agent.afm.md

Configuration

Configuration via environment variables or CLI options:

  • OPENAI_API_KEY, ANTHROPIC_API_KEY, etc. (Required based on provider)
  • HTTP port can be set via -p or --port (default: 8000)

Running with Docker

# Build the image
docker build -t afm-langchain-interpreter .

# Run with an AFM file mounted and API key
docker run -v $(pwd)/path/to/agent.afm.md:/app/agent.afm.md \
  -e OPENAI_API_KEY=$OPENAI_API_KEY \
  -p 8000:8000 \
  afm-langchain-interpreter afm /app/agent.afm.md

Testing

uv run pytest

Project Structure

langchain-interpreter/
├── src/afm_cli/
│   ├── interfaces/        # Interface implementations (console, web, webhook)
│   ├── tools/             # Tool support (MCP server)
│   ├── resources/         # Static assets (web UI)
│   ├── agent.py           # Core agent logic
│   ├── cli.py             # CLI entry point
│   ├── parser.py          # AFM file parsing
│   ├── models.py          # Model configuration
│   ├── providers.py       # LLM provider handling
│   └── templates.py       # Prompt templates
├── tests/                 # Unit and integration tests
├── afm-samples/           # Example AFM definitions
├── Dockerfile             # Container build
├── pyproject.toml         # Python project configuration
└── uv.lock                # Dependency lock file

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_cli-0.2.0.tar.gz (39.1 kB view details)

Uploaded Source

Built Distribution

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

afm_cli-0.2.0-py3-none-any.whl (48.9 kB view details)

Uploaded Python 3

File details

Details for the file afm_cli-0.2.0.tar.gz.

File metadata

  • Download URL: afm_cli-0.2.0.tar.gz
  • Upload date:
  • Size: 39.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for afm_cli-0.2.0.tar.gz
Algorithm Hash digest
SHA256 7bc7686b79fbbfc80b7f8d193ae8f96a9cb345d40731e21df2180991103eb77d
MD5 5f7394b680bb1bb20f4a32896909f4aa
BLAKE2b-256 6f9a899c30e2a2ff8f42c61045b43a8bfd71e543c99e2e8956d13a93bd792323

See more details on using hashes here.

File details

Details for the file afm_cli-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: afm_cli-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 48.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for afm_cli-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e54cfe89e89ba6fadb9736d98f47b33230d83fc9c9620531d230832d2a3e1033
MD5 a833469aa568a08f3266567d00ceba91
BLAKE2b-256 dac07ab6a4e5aefb6f66300ad039aa20e3ef2823e3e68d22efb96cb7aa192493

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