Skip to main content

coreason-optimizer

Project description

coreason-optimizer

Automated Prompt Engineering / LLM Compilation / DSPy Integration for CoReason-AI

License: Prosperity 3.0 CI Status Code Style: Ruff Documentation

coreason-optimizer is the "Compiler" for the CoReason Agentic Platform. It automates prompt engineering by treating prompts as trainable weights, optimizing them against ground-truth datasets to maximize performance metrics.


Installation

pip install coreason-optimizer

Features

  • Automated Optimization: Rewrites instructions and selects examples to maximize a score, not human intuition.
  • Model-Specific Compilation: Generates optimized prompts specifically tuned for target models (e.g., GPT-4, Claude 3.5).
  • Continuous Learning: Re-runs optimization on recent logs to patch prompts against data drift.
  • Mutate-Evaluate Loop: Systematic cycle of drafting, evaluating, diagnosing, mutating, and selecting prompts.
  • Strategies: Includes BootstrapFewShot (mining successful traces) and MIPRO (Multi-prompt Instruction PRoposal Optimizer).
  • Integration: Works seamlessly with coreason-construct, coreason-archive, and coreason-assay.

For full product requirements, see docs/product_requirements.md.

Usage

Here is how to initialize and use the library to compile an agent:

from coreason_optimizer import OptimizerConfig, PromptOptimizer
from coreason_optimizer.core.interfaces import Construct
from coreason_optimizer.data import Dataset

# 1. Configuration
config = OptimizerConfig(
    target_model="gpt-4o",
    metric="exact_match",
    max_rounds=10
)

# 2. Load Data
dataset = Dataset.from_csv("data/gold_set.csv")
train_set, val_set = dataset.split(test_size=0.2)

# 3. Load Agent (Construct)
# In a real scenario, this would be imported from your agent code
# from src.agents.analyst import analyst_agent
class MockAgent(Construct):
    inputs = ["question"]
    outputs = ["answer"]
    system_prompt = "You are a helpful assistant."
agent = MockAgent()

# 4. Compile
optimizer = PromptOptimizer(config=config)
optimized_manifest = optimizer.compile(
    agent=agent,
    trainset=train_set,
    valset=val_set
)

print(f"Optimization complete. New Score: {optimized_manifest.performance_metric}")
print(f"Optimized Instruction: {optimized_manifest.optimized_instruction}")

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_optimizer-0.1.0.tar.gz (24.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_optimizer-0.1.0-py3-none-any.whl (36.6 kB view details)

Uploaded Python 3

File details

Details for the file coreason_optimizer-0.1.0.tar.gz.

File metadata

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

File hashes

Hashes for coreason_optimizer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3db7ee5ccbd0fd878d57a23452e6d4f34d020a1295265ab23bef57774b071288
MD5 2d06cfdf1206fc6b65967eb57ee4f8a5
BLAKE2b-256 2197b7a3654b798daee452288d7fd2e8465c1043bc3ddb0e14919e9f3666c3e3

See more details on using hashes here.

Provenance

The following attestation bundles were made for coreason_optimizer-0.1.0.tar.gz:

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

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_optimizer-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for coreason_optimizer-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 60a467224fc7e11010e1d3c8866aba1fc556f80f2bd4eed34c334a7d7b954f6a
MD5 0bd422645f32f7fee7422e1d2bde4c9c
BLAKE2b-256 889c2e1b911e7868fd79b96c453da44580fb02f3635301c9fa361353283b008b

See more details on using hashes here.

Provenance

The following attestation bundles were made for coreason_optimizer-0.1.0-py3-none-any.whl:

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

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