coreason-construct
Project description
coreason-construct
The Standard Library for Cognitive Architecture.
Executive Summary
coreason-construct is the Standard Library for Cognitive Architecture.
It replaces ad-hoc prompt engineering with Type-Driven Generation. It integrates instructor to patch LLM clients, linking Pydantic schemas directly to the model's logits.
However, structure alone is not enough. The package provides a strictly typed library of Cognitive Components—Roles, Contexts, Logic Primitives, and Data Banks—that are assembled by the Weaver. The Weaver not only enforces output schema but also manages Dependency Resolution (context injection) and Token Optimization before the request is sent.
Functional Philosophy: The Assembler Pattern
"Prompts are not written; they are assembled. Outputs are not strings; they are Objects."
A Prompt is an object composed of:
- Identity (Who): The Role and its biases.
- Environment (Where): The regulatory and data context.
- Mode (How): The active reasoning style (e.g., "Six Hats", "Socratic").
- Data (Evidence): Few-shot examples and negative constraints.
- Task (What): The Structured Primitive (e.g., CohortLogic, Extract).
- Output (Type): The specific Pydantic model the LLM must populate.
Getting Started
Prerequisites
- Python 3.12+
- Poetry (for development)
Installation
pip install coreason-construct
Or with Poetry:
poetry add coreason-construct
Quick Start
Assemble a prompt for Adverse Event extraction using a standardized Role and Few-Shot Data.
from coreason_construct import Weaver
from coreason_construct.roles.library import SafetyScientist
from coreason_construct.data.library import AE_Examples
from coreason_construct.primitives.extract import ExtractionPrimitive
from coreason_construct.schemas.clinical import AdverseEvent
# 1. Initialize the Weaver
weaver = Weaver()
# 2. Add Components
# Automatically injects dependencies (e.g., HIPAA & GxP Contexts for SafetyScientist)
weaver.add(SafetyScientist)
# Injects Few-Shot examples for robust extraction
weaver.add(AE_Examples)
# 3. Add the Task (Primitive)
extractor = ExtractionPrimitive(
name="AE_Extractor",
schema=AdverseEvent
)
weaver.add(extractor)
# 4. Build the Prompt Configuration
user_input = "Patient reported mild nausea after taking the study drug."
config = weaver.build(user_input)
# The 'config' object is now ready to be sent to an LLM via instructor
print(config.system_message)
# Output includes:
# - Safety Scientist Persona
# - HIPAA/GxP Constraints
# - Few-Shot Examples (formatted JSON)
# - Extraction Instructions
Documentation
For more detailed information, please refer to the documentation:
- Usage Guide: Detailed explanation of components and the Weaver.
- Vignette: A narrative example of using coreason-construct.
- Product Requirements Document: The full PRD for this library.
License
Proprietary and Dual-Licensed. See LICENSE for details.
Project details
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 coreason_construct-0.4.1.tar.gz.
File metadata
- Download URL: coreason_construct-0.4.1.tar.gz
- Upload date:
- Size: 19.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ae8cc71c4f2c3cf804460522119a21a77f529c6199912650859c1271540c74a
|
|
| MD5 |
0e6903e1f0a44758e587d1228a152d23
|
|
| BLAKE2b-256 |
5867c85c8f15bfaad3ec60982db95de279012c9dd6615caa59b78733b75d4fed
|
Provenance
The following attestation bundles were made for coreason_construct-0.4.1.tar.gz:
Publisher:
publish.yml on CoReason-AI/coreason-construct
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
coreason_construct-0.4.1.tar.gz -
Subject digest:
7ae8cc71c4f2c3cf804460522119a21a77f529c6199912650859c1271540c74a - Sigstore transparency entry: 869839841
- Sigstore integration time:
-
Permalink:
CoReason-AI/coreason-construct@b4565d2ecfc248d8ffbbc1b2a485645cdb5f3ee9 -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/CoReason-AI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b4565d2ecfc248d8ffbbc1b2a485645cdb5f3ee9 -
Trigger Event:
release
-
Statement type:
File details
Details for the file coreason_construct-0.4.1-py3-none-any.whl.
File metadata
- Download URL: coreason_construct-0.4.1-py3-none-any.whl
- Upload date:
- Size: 31.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3fab9c6a56a63c0d852c7c2ea7e39ba2d041412f4a218e141b1ea9720ea2a09d
|
|
| MD5 |
3775646ad314ca73d4e8b49021b30548
|
|
| BLAKE2b-256 |
7350c3a20d549240ea921fffab5d7ccbec74069668436b24b614fdaff784759b
|
Provenance
The following attestation bundles were made for coreason_construct-0.4.1-py3-none-any.whl:
Publisher:
publish.yml on CoReason-AI/coreason-construct
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
coreason_construct-0.4.1-py3-none-any.whl -
Subject digest:
3fab9c6a56a63c0d852c7c2ea7e39ba2d041412f4a218e141b1ea9720ea2a09d - Sigstore transparency entry: 869839846
- Sigstore integration time:
-
Permalink:
CoReason-AI/coreason-construct@b4565d2ecfc248d8ffbbc1b2a485645cdb5f3ee9 -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/CoReason-AI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b4565d2ecfc248d8ffbbc1b2a485645cdb5f3ee9 -
Trigger Event:
release
-
Statement type: