Generate business insights from summary and source data.
Project description
StorAI
storai is a reusable Python library that generates business insights from:
- summary-level data (monthly/periodic KPIs), and
- optional source-level data (row-level transactions/events).
It returns display-ready output, human-readable insights, reasons, and optional ML findings.
Install
pip install storai
Postgres support (driver):
pip install "storai[postgres]"
For development:
pip install -e ".[dev,test,postgres]"
Quick Start
DataFrame input
import pandas as pd
from storai import analyze
summary_df = pd.DataFrame(
{
"year": [2025, 2025, 2025, 2025],
"month": [7, 8, 9, 10],
"payment": [391585.01, 342235.81, 402424.61, 434446.20],
"visit_count": [1474, 1309, 1428, 1433],
}
)
source_df = summary_df.copy()
result = analyze(summary_df=summary_df, source_df=source_df)
print(result["insights"])
SQL input
from sqlalchemy import create_engine
from storai import analyze
engine = create_engine("postgresql+psycopg2://user:pass@host:5432/db")
summary_sql = """
select year, month, sum(payment_amount) as payment, sum(visit_count) as visit_count
from semantic.tbl_executive_summary
where year = 2025 and month in (7,8,9,10)
group by 1,2
"""
source_sql = """
select *
from semantic.tbl_executive_summary
where year = 2025 and month in (7,8,9,10)
"""
result = analyze(summary_sql=summary_sql, source_sql=source_sql, db_engine=engine)
print(result["insights"])
Output Contract
{
"display_df": pandas.DataFrame,
"display_rows": list[dict],
"source_sql": str | None,
"insights": list[{"insight": str, "reason": str}],
"ml_findings": {"outliers": list, "patterns": list},
}
Public API
storai.analyze(...)storai.story(...)(alias ofanalyze)storai.detect_insights(...)storai.compute_metrics(...)storai.detect_ml_findings(...)storai.infer_schema(...)
Project Layout
The package uses src layout for clean packaging boundaries:
src/storai/
api/
application/
analysis/
core/
data/
domain/
insights/
metrics/
ml/
narrative/
schema/
utils/
Build And Publish
Build distributions:
python -m build
Validate artifacts:
python -m twine check dist/*
Upload:
python -m twine upload dist/*
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file storai-0.1.2.tar.gz.
File metadata
- Download URL: storai-0.1.2.tar.gz
- Upload date:
- Size: 25.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce6678d360d3053f4af32ca8ffe9a31a89049b2b2714be80338755de5f15a9d1
|
|
| MD5 |
e4ccfb2c5c9c11e08ea40b407749b7fd
|
|
| BLAKE2b-256 |
b5e52d478367fcb7c8176f4fde88370c24b375a675462df8f14104dc187cb62e
|
File details
Details for the file storai-0.1.2-py3-none-any.whl.
File metadata
- Download URL: storai-0.1.2-py3-none-any.whl
- Upload date:
- Size: 28.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bda28393be437d18d44cee85397e440972a1456df70d790f6f1a79898011741b
|
|
| MD5 |
0c04ae83a4206a4e0629bc33a305fc48
|
|
| BLAKE2b-256 |
602bbacbe02f52e81fe5010b85f301c158a1ee57515e0c66a9a49565d824ae64
|