Initial commit: PROMETHEUS v0.1.0 - Prompt optimizer

- Clean architecture (domain/application/infrastructure)
- DSPy-based evolution engine with scoring
- CLI via pyproject.toml entry point
- Unit + integration tests (~300 tests)
- Configs for glm-5.1 and glm-4.5-air models
- Z.AI endpoint integration
This commit is contained in:
2026-03-29 11:44:03 +00:00
commit 837a44970f
49 changed files with 6599 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
"""
Bootstrap — synthetic input generation.
Creates a pool of test inputs from the task description.
This replaces the need for a labelled dataset.
"""
from __future__ import annotations
import random
from prometheus.domain.entities import SyntheticExample
from prometheus.domain.ports import SyntheticGeneratorPort
class SyntheticBootstrap:
"""Orchestrates synthetic input generation.
Depends only on the abstract port, not on DSPy directly.
"""
def __init__(self, generator: SyntheticGeneratorPort, seed: int = 42):
self._generator = generator
self._rng = random.Random(seed)
def run(self, task_description: str, n_examples: int) -> list[SyntheticExample]:
"""Generate the synthetic pool in a single call.
Single call minimizes LLM cost (1 call instead of N),
and the LLM can ensure diversity in a single generation.
"""
examples = self._generator.generate_inputs(task_description, n_examples)
self._rng.shuffle(examples)
return examples
def sample_minibatch(
self,
pool: list[SyntheticExample],
size: int,
) -> list[SyntheticExample]:
"""Sample a minibatch from the synthetic pool."""
size = min(size, len(pool))
return self._rng.sample(pool, size)