A Finite State Machine hybrid with Large Language Models
// momentum
// why it's here
- Active: last commit today
- Built almost entirely by one person
- Health 100/100 with only 18 stars
- 7 releases in the last 90 days
// how to help
// readme
A language model call starts from nothing. A multi-turn conversation that must collect data, follow a set flow and decide the same way every time needs structure around the model. FSM-LLM is a Python framework for chatbots and agents that follow a fixed structure: you describe the conversation as a finite state machine in JSON, and the language model does the language work inside each state.
The split is simple. The model understands the user, pulls out facts and writes replies. The state machine decides where the conversation goes next, by rules evaluated in plain Python, so the same facts always lead to the same state. The framework keeps everything else: what was collected, the history, your hooks, sessions, budgets and an optional replayable log.
It is one package, fsm_llm, with a small core and subpackages on top: reasoning strategies, a workflow engine, agent patterns, a monitoring dashboard, an evaluation harness, runtime FSM synthesis and public test doubles. Every subpackage is built from the same parts as the core (stacked FSMs, message-free steps, one LLM layer), so there is one way to run a model, not one per subpackage.