Skip to main content

AFM (Agent-Flavored Markdown) core: parser, CLI, protocols, and interfaces

Project description

AFM Core

PyPI version Python version License

Core library for Agent-Flavored Markdown (AFM) - providing parsing, validation, and interface implementations.

Features

  • AFM File Parser: Extracts YAML frontmatter and Markdown content (Role, Instructions sections)
  • Pydantic Models: Type-safe validation of AFM schema for agents, interfaces, and tools
  • Interface Implementations: Console chat, web chat, and webhook interfaces
  • AgentRunner Protocol: Pluggable backend system for different execution frameworks
  • CLI Framework: Entry point for the afm command with validation and run commands

Installation

This package is typically installed as part of afm-cli. For development or custom integrations:

pip install afm-core

Usage

from afm.parser import parse_afm_file

# Parse an AFM file (returns an AFMRecord)
record = parse_afm_file("agent.afm.md")

# Access parsed data
print(f"Agent: {record.metadata.name}")
print(f"Model: {record.metadata.model.provider}/{record.metadata.model.name}")
print(f"Interfaces: {[i.type for i in record.metadata.interfaces]}")
print(f"Role: {record.role}")
print(f"Instructions: {record.instructions}")

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

Running Tests

# Run all tests
uv run pytest packages/afm-core/tests/

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

Code Quality

# Format code
uv run ruff format

# Lint code
uv run ruff check

Project Structure

packages/afm-core/src/afm/
├── __init__.py
├── cli.py              # CLI entry point
├── exceptions.py       # Custom exceptions
├── models.py           # Pydantic models
├── parser.py           # AFM file parsing
├── runner.py           # AgentRunner protocol and runner utilities
├── schema_validator.py # Schema validation
├── templates.py        # Prompt templates
├── update.py           # Update checker
├── variables.py        # Variable substitution
└── interfaces/         # Interface implementations
    ├── __init__.py
    ├── base.py         # Interface utilities (get_interfaces, get_http_path)
    ├── console_chat.py
    ├── web_chat.py
    └── webhook.py

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_core-0.1.6.tar.gz (30.0 kB view details)

Uploaded Source

Built Distribution

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

afm_core-0.1.6-py3-none-any.whl (41.7 kB view details)

Uploaded Python 3

File details

Details for the file afm_core-0.1.6.tar.gz.

File metadata

  • Download URL: afm_core-0.1.6.tar.gz
  • Upload date:
  • Size: 30.0 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_core-0.1.6.tar.gz
Algorithm Hash digest
SHA256 b547a0b62913da1e7a9694c5bdfae7b6d3d8d0ad27d383020d2ea97dc3cfa45b
MD5 033299229819b0e43e5295d8871a9af2
BLAKE2b-256 c2a9d25b2a0882c148996392fe350f7c94aa04a2176b59d3b78c393d4f959e18

See more details on using hashes here.

File details

Details for the file afm_core-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: afm_core-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 41.7 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_core-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 71318cf27ee9692c95eb7833f2f46dc19aa76239d46ec94e26e3224d4c048888
MD5 83c229f34321fcf9c1417294dadeecf0
BLAKE2b-256 4d19076ae4fd801d3cbb57fef5b15d94dab60b5a108b0711a69960dd099bea8d

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