Metadata-Version: 2.4
Name: afm-cli
Version: 0.2.0
Summary: AFM (Agent-Flavored Markdown) interpreter using LangChain
License-Expression: Apache-2.0
Classifier: Development Status :: 3 - Alpha
Classifier: Programming Language :: Python :: 3.11
Requires-Dist: langchain>=1.2.8
Requires-Dist: pyyaml>=6.0
Requires-Dist: pydantic>=2.0
Requires-Dist: langchain-openai>=1.1.7
Requires-Dist: langchain-anthropic>=1.3.1
Requires-Dist: jsonschema>=4.26.0
Requires-Dist: fastapi>=0.128.1
Requires-Dist: httpx>=0.28.1
Requires-Dist: uvicorn>=0.40.0
Requires-Dist: mcp>=1.26.0
Requires-Dist: langchain-mcp-adapters>=0.2.1
Requires-Dist: click>=8.0.0
Requires-Dist: textual>=2.1.0
Requires-Python: >=3.11
Project-URL: Repository, https://github.com/RadCod3/reference-implementations-afm
Description-Content-Type: text/markdown

# AFM LangChain Interpreter

A LangChain-based reference implementation of an interpreter for [Agent-Flavored Markdown (AFM)](https://github.com/wso2/agent-flavored-markdown) 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](https://www.python.org/) 3.12 or later.
- [uv](https://docs.astral.sh/uv/) for dependency management.

## Installation

### Using pipx (Recommended)

To run `afm` as a standalone command-line tool:

```bash
pipx install afm-cli
```

### Using pip

```bash
pip install afm-cli
```

## Quick Start

```bash
# 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

```bash
# 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

```bash
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
