Skip to main content

bh-sentinel-core

PyPI Downloads

Clinical decision support: pattern-based safety signal detection for behavioral health. Not a diagnostic tool.

Clinical Use Notice: bh-sentinel is clinical decision support software. It is not a diagnostic tool, not FDA-cleared, and not a substitute for clinical judgment. All outputs are signals for clinician review. See CLINICAL_DISCLAIMER.md.

bh-sentinel-core is the foundational library of the bh-sentinel project. It provides deterministic, regex-based safety signal detection with configurable rules, negation handling, temporal awareness, and an emotion lexicon.

Installation

pip install bh-sentinel-core

Dependencies

Minimal: pydantic, pyyaml. No ML libraries required.

What's Included

  • Pattern Matcher -- compiled regex engine with negation and temporal awareness
  • Rules Engine -- configurable severity escalation, de-escalation, and compound risk detection
  • Flag Taxonomy -- 40 flags across 6 clinical domains (self-harm, harm to others, medication, substance use, clinical deterioration, protective factors)
  • Text Preprocessor -- sentence splitting, normalization, and character offset tracking
  • Negation Detector -- "denies SI", "no suicidal ideation" handling
  • Temporal Detector -- past vs. present tense detection ("used to cut" vs. "is cutting")
  • Emotion Lexicon -- project-owned behavioral health lexicon with 11-category density scoring
  • Pipeline -- orchestrator that runs all layers and produces structured results

Quick Start

from bh_sentinel.core import Pipeline

pipeline = Pipeline()
result = pipeline.analyze_sync(
    "Patient reports suicidal ideation for the past two days. "
    "Stopped taking my medication last week."
)

for flag in result.flags:
    print(f"[{flag.severity}] {flag.name} (confidence: {flag.confidence})")

print(f"Immediate review: {result.summary.requires_immediate_review}")
print(f"Recommended: {result.summary.recommended_action}")

Adding the ML Layer

For semantic classification on top of pattern matching, install the companion bh-sentinel-ml package and enable Layer 2:

pip install bh-sentinel-ml
from bh_sentinel.core import Pipeline

pipeline = Pipeline(enable_transformer=True)  # auto-downloads pinned model on first run

bh-sentinel-core remains installable and usable on its own -- it has no runtime dependency on onnxruntime, tokenizers, or huggingface_hub. The ml imports are lazy-loaded only when enable_transformer=True.

Documentation

See the main repository for full documentation, architecture details, flag taxonomy reference, and the release process.

License

Apache License 2.0. See LICENSE for details.

Metadata

Release files for bh-sentinel-core 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bh-sentinel-core 0.1.2
File Size Uploaded
bh_sentinel_core-0.1.2.tar.gz 46.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bh-sentinel-core 0.1.2
File Interpreter ABI Platform
bh_sentinel_core-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 101.7 kB

Release files / bh_sentinel_core-0.1.2.tar.gz

Download URL bh_sentinel_core-0.1.2.tar.gz
Size 46.8 kB
Tags Source
SHA-256 checksum
How to use checksums
73a3dde325bfa260a69eac8686849fb48526d460c141837cfb3762663f1eb260
BLAKE2b-256 checksum
How to use checksums
71c30ed1d095a19ead60c456044765acd68892287e8686d9dee1940623ed2efd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 30, 2026.

Transparency log

Release files / bh_sentinel_core-0.1.2-py3-none-any.whl

Download URL bh_sentinel_core-0.1.2-py3-none-any.whl
Size 54.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cef51e4f3d1c5d57f606ea95b3b290c7137c8424095074d23eb8a86f47615522
BLAKE2b-256 checksum
How to use checksums
2fdbee5f18979f5d2a5a17d757d027f5f1c5e8485ff95b67eacdeea774cd55f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 30, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page