Quick Start¶
Need more background information?
Installation¶
To install Vulcan within your project, simply add vulcan-core as a dependency using your preferred package manager:
The package provides a number of optional extras depending on how you intend to integrate Vulcan into your project.
Simple Rules¶
Before we can begin expressing rules, we must declare facts that represent the domain for which we want to reason:
| Python | |
|---|---|
- Classes that inherit from
Factare created automatically as Python dataclasses. Subclasses must declare the types for all fields.
Once the facts are declared, they may be used to express logical conditions and actions:
- Vulcan uses advanced Python AST parsing to simplify condition and action expressions. This allows for a more natural and readable syntax without the need to instantiate
Factobjects. - Vulcan facts are immutable, therefore the
thenblock of a rule must create a newFactinstance.
A rule has two required parts: when and then. You can think of the when statement like an "if" statement in code. However, unlike imperative coding, rules are only evaluated when the facts they depend on change. The result of a rule is a change in another fact, expressed in the then statement.
Once we have our rules, we can define our initial knowledge base and run the rules:
We can "peek" at the state of the knowledge base at any time:
| Python | |
|---|---|
| Text Output | |
|---|---|
QueuedOrder fact, but now we do. If we change our Inventory amount, we can see the QueuedOrder fact value change: | Text Output | |
|---|---|
QueuedOrder fact has a value of 0 rather than the previous 10. This is because our second rule has fired given the criteria of inventory being greater than 10. AI Rules¶
Unlike a traditional rules engine, Vulcan rules can also express natural language conditions. In order to use AI rules, you will need to install Vulcan with the correct dependency for the type of LLM you wish to use (or implement your own adapter). For this example, we will be using OpenAI:
OpenAI Credentials
To run AI examples in this guide, you must have an OpenAI account and an OPENAI_API_KEY environment variable present.
| Text Output | |
|---|---|
Data-Augmented Rules¶
Not only can we express rules using natural language and evaluate facts, we can also define facts with similarity search properties and use them as RAG rules. This allows AI rules to evaluate vast amounts of information by limiting information to only what's relevant to the inquiry.
Defining a similarity attribute on a Fact is simple:
For the purpose of this example, we will now create a simple Chroma VectorStore using the LangChain API via an adapter:
From here we can instantiate the fact and add it to the knowledge base along with a rule that references the similarity attribute of the fact:
| Text Output | |
|---|---|
Explainability Reporting¶
A powerful feature of Vulcan is the ability to explain the reasoning behind rule-based decisions. Explainability reports allow insight into how the rules engine arrived at a result, especially in complex scenarios where multiple rules may interact or when AI rules are involved.
To enable explainability reporting, call engine.evaluate(audit=True) and then inspect the result of engine.yaml_report():
report:
iterations:
- id: 0
timestamp: '2025-07-14T16:07:14.742891Z'
elapsed: 2.441
matches:
- rule: 205a7ab3:Order more apples if delicious
timestamp: '2025-07-14T16:07:14.742920Z'
elapsed: 2.441
evaluation: True = Are {Inventory.apple_kind|fuji|} considered delicious by most people?
consequences:
QueuedOrder.apples: 50
rationale: Fuji apples are generally considered delicious by most people due to their sweetness and crisp texture.
The above report shows the values used during rule evaluation, the consequences of the rules, and the AI's reasoning. By decomposing complex LLM prompts into smaller queries, Vulcan allows logical composition through computation, not prediction, with full explainability of how complex decisions are made.