Spaces:
Sleeping
Sleeping
Dmitry Beresnev commited on
Commit Β·
a51a89f
1
Parent(s): 332826f
add new architectural diagram to readme file
Browse files135 unmodified lines136137138139140141128 unmodified lines270271272273274275276277278279280135 unmodified lines## ποΈ Architecture### Model Caching SystemThe API uses an intelligent LRU (Least Recently Used) cache to manage models in memory:128 unmodified lines```AGI/βββ app.py # Main FastAPI applicationβββ client_multi_model.py # Example clientβββ Dockerfile # Docker configurationβββ pyproject.toml # Python dependenciesβββ README.md # This file```### Adding New Models135 unmodified lines136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185128 unmodified lines314315316317318319320321322323324325135 unmodified lines## ποΈ Architecture### Current Control Plane ArchitectureThe repository now contains a C++ control plane for `llama-server` in addition to the legacy Python path.Detailed diagram:- [`docs/CPP_MANAGER_ARCHITECTURE_ASCII.md`](/Users/dmitryberesnev/Project/huggingface/agi/AGI/docs/CPP_MANAGER_ARCHITECTURE_ASCII.md)```textclient|v[llm-manager / Boost.Beast]|- auth|- token validation|- rate limiting|- request registry|- bounded priority queue|- scheduler|- queue metricsv[active llama-server worker]```### Components- `llm-manager (Boost.Beast)`: Main C++ HTTP server that exposes chat, control, cancel, and queue-metrics endpoints.- `Config Layer`: Loads runtime settings from `config.toml` and environment variables for server, queue, auth, limits, and backend process settings.- `API Key Auth`: Authenticates `Authorization: Bearer <token>` requests and maps them to `admin` or `user` roles.- `Token Validation`: Estimates prompt size from `messages + max_tokens` and rejects oversized requests before they hit the backend.- `Rate Limiter`: Applies per-key request and estimated-token budgets to protect the system from overload.- `Request Registry`: Tracks request lifecycle by `request_id`, including queued, running, cancelled, failed, and completed states.- `Priority Queue`: Holds queued work with bounded size and bounded token budget, and separates `admin` and `user` traffic.- `Scheduler`: Pulls work from the queue, applies fairness, and forwards one request at a time to the active backend worker.- `ModelManager`: Owns `llama-server` process lifecycle, including startup, readiness checks, model switching, and hard restarts.- `Queue Metrics`: Exposes queue and runtime telemetry at `GET /queue/metrics` in Prometheus-style text format.- `Active llama-server Worker`: The currently loaded backend inference process that serves `/v1/chat/completions`.### Runtime Notes- Only one backend worker is active at a time.- Queue admission is bounded by both request count and estimated tokens.- Per-request cancel is best-effort for running inference and may restart the active worker.- Streaming is not enabled by default and is explicitly rejected until relay support is implemented.### Model Caching SystemThe API uses an intelligent LRU (Least Recently Used) cache to manage models in memory:128 unmodified lines```AGI/βββ cpp/ # C++ llm-manager control planeβββ python/ # Legacy Python application modulesβββ docs/ # Design docs and architecture notesβββ Dockerfile # Docker configurationβββ pyproject.toml # Python dependenciesβββ README.md # This file```### Adding New Models
README.md+49-4