English | 中文
An LLM-based AIOps fault prevention framework. It combines time-series anomaly detection, causal graph construction, and LLM reasoning to automatically analyze system risk metrics and identify potential failures.
Note: The open-source version has removed the data collection module. Users cannot pull monitoring data directly via code. Demo data and demonstration cases are provided under
./data/collected_data/demo/— you can use them to experience and test the full analysis pipeline out of the box.
- Python 3.9+
- An OpenAI-compatible LLM API endpoint
git clone <repository-url>
cd chaincraft
pip install -r requirements.txtcp .env.example .env
# Edit .env and fill in your LLM API configurationKey environment variables:
OPENAI_API_BASE— API base URLOPENAI_API_KEY— API keyLLM_MODEL— LLM model nameEMBEDDING_MODEL— Embedding model name
python main.pyBy default, main.py runs all four workflows sequentially using the demo cases. You can enable or disable individual workflows by commenting/uncommenting the corresponding _timed_run(...) calls at the bottom of the file.
Runs the full analysis pipeline — anomaly detection (Prophet), metric analysis (LLM), and causal analysis (PCMCI) — on historical cases.
Use case: Preprocess historical fault cases to generate analysis results that serve as the foundation for building the knowledge base.
from main import batch_analyze_cases
batch_analyze_cases(['case1'], collect_data=False, enable_iteration=True)Performs inference analysis on new or ongoing cases to identify potential fault risks.
Use case: Analyze current system states to detect emerging fault patterns and generate inference results.
from main import batch_inference_cases
batch_inference_cases(['case2'], collect_data=False, enable_iteration=True)Processes fault reports from analyzed cases and stores them into a ChromaDB vector knowledge base for future retrieval.
Use case: Build and expand the RAG knowledge base from historical fault cases. Run after Workflow 1.
from main import batch_deal_fault_reports
batch_deal_fault_reports(['case1'])Processes inference reports using RAG-based similar case retrieval and propagation chain reranking to produce risk predictions.
Use case: Generate actionable risk predictions by matching current inference results against the historical knowledge base. Run after Workflows 2 and 3.
from main import batch_deal_inference_reports
batch_deal_inference_reports(['case2'], use_structure_rag=True, use_chain_rerank=True)Each analysis step (anomaly detection, metric analysis, causal analysis) can be skipped to reuse previously computed results:
from main import batch_analyze_cases
batch_analyze_cases(
['case1'],
run_anomaly_detection=False, # reuse from ANOMALY_DETECTION_READ_PATH
run_causal_analysis=False, # reuse from ANALYSIS_READ_PATH
)Demo data is located in ./data/collected_data/demo/ and includes two cases:
case1— A historical fault case for knowledge base buildingcase2— A prediction case for inference validation
Each case contains time-series metrics (all_metrics.csv) and raw metric CSVs organized under {app}_{app_group}/metric/.
All configuration is managed through environment variables loaded from .env or system environment. See .env.example for the full list of available options.
This project is licensed under the Apache License 2.0.