Skip to main content

coreason-construct

Project description

coreason-construct

The Standard Library for Cognitive Architecture.

CI/CD Docker PyPI version PyPI - Python Version License codecov Ruff pre-commit

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:

  1. Identity (Who): The Role and its biases.
  2. Environment (Where): The regulatory and data context.
  3. Mode (How): The active reasoning style (e.g., "Six Hats", "Socratic").
  4. Data (Evidence): Few-shot examples and negative constraints.
  5. Task (What): The Structured Primitive (e.g., CohortLogic, Extract).
  6. 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:

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

coreason_construct-0.2.1.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

coreason_construct-0.2.1-py3-none-any.whl (27.0 kB view details)

Uploaded Python 3

File details

Details for the file coreason_construct-0.2.1.tar.gz.

File metadata

  • Download URL: coreason_construct-0.2.1.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for coreason_construct-0.2.1.tar.gz
Algorithm Hash digest
SHA256 d2b81d7456dfbfcbb5cfa28c8b6d39a366b2b58b47bb2818823d0f3c101f40ab
MD5 27baab082daf06a794cd36933f10ac02
BLAKE2b-256 64c90444a2fbd0c423c93e8eb2cb7d5587e65f53bda104aa4520a57f41953a10

See more details on using hashes here.

Provenance

The following attestation bundles were made for coreason_construct-0.2.1.tar.gz:

Publisher: publish.yml on CoReason-AI/coreason-construct

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file coreason_construct-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for coreason_construct-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 aea927c3055944a99a82f7c170960fca2d058b3ec1d81cec51dfe047e6edbcde
MD5 c49d9b1a3f8d0539a00b17936f41eabd
BLAKE2b-256 95fa13632fa4027076290888721bff1779670b8351200a12d4b8e6c94de380cc

See more details on using hashes here.

Provenance

The following attestation bundles were made for coreason_construct-0.2.1-py3-none-any.whl:

Publisher: publish.yml on CoReason-AI/coreason-construct

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page