Flama开源框架 支持生产级API与LLM服务开发部署

Flama: a Python framework for development and deployment of production-ready APIs, machine learning, and LLM services

精选理由

Flama这个开源框架,能帮你开发部署生产级API和LLM服务,和普通框架比更统一架构,还能自动处理多种模型格式。

AI 摘要

Flama是一个开源Python框架,基于Asynchronous Server Gateway Interface(ASGI),用于开发部署生产级web API、机器学习服务和大型语言模型(LLM)应用;其子系统包含依赖注入系统,可从类型注解解析参数,还支持Pydantic等格式;内置JWT认证、WebSocket端点等功能,可通过命令行界面管理应用。

原文 · arXiv: Anthropic

Flama: a Python framework for development and deployment of production-ready APIs, machine learning, and LLM services

We present Flama, an open-source Python framework for developing and deploying production-ready web APIs, machine learning services, and large-language-model (LLM) applications. Built on the Asynchronous Server Gateway Interface (ASGI), Flama offers a type-driven, async-first programming model that unifies REST API development, predictive model serving, and generative AI inference in one architecture. It is organised around seven subsystems: a component-based dependency injection system resolving handler parameters from type annotations at startup; a pluggable schema layer supporting Pydantic, Marshmallow and Typesystem behind a single adapter; an automatic CRUD generator turning a SQLAlchemy table and a schema class into REST endpoints backed by the Repository and Unit of Work patterns; a portable binary format (.flm) packaging models from scikit-learn, TensorFlow, PyTorch and Hugging Face Transformers with their metadata for zero-code deployment; a multi-backend LLM server running vLLM (Linux/CUDA) or MLX (Apple Silicon) and exposing four wire protocols (OpenAI, Anthropic, Ollama, and a native streaming dialect) through a shared codec; a Rust-accelerated core compiled via Maturin for routing, JSON encoding, compression and parsing; and a Model Context Protocol module turning any application into an MCP server over JSON-RPC 2.0. Built-in capabilities include JWT authentication, two pagination strategies, background tasks in threads or processes, WebSocket endpoints, Server-Sent Event and NDJSON streaming, OpenAPI 3.2.0 generation from handler signatures, and a command-line interface for running applications and for serving, packaging and inspecting models. We describe the architecture, present the programming model through worked examples, and compare Flama with existing frameworks, model serving platforms and LLM inference engines.