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:
93
tests/conftest.py
Normal file
93
tests/conftest.py
Normal file
@@ -0,0 +1,93 @@
|
||||
"""Shared test fixtures."""
|
||||
from __future__ import annotations
|
||||
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import pytest
|
||||
|
||||
from prometheus.domain.entities import (
|
||||
EvalResult,
|
||||
Prompt,
|
||||
SyntheticExample,
|
||||
Trajectory,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def seed_prompt() -> Prompt:
|
||||
return Prompt(text="You are a helpful assistant. Answer the question.")
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def task_description() -> str:
|
||||
return "Answer factual questions accurately and concisely."
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def synthetic_pool() -> list[SyntheticExample]:
|
||||
return [
|
||||
SyntheticExample(input_text=f"Test input {i}", id=i) for i in range(20)
|
||||
]
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_eval_result() -> EvalResult:
|
||||
return EvalResult(
|
||||
scores=[0.3, 0.5, 0.4, 0.6, 0.2],
|
||||
feedbacks=[
|
||||
"Incomplete answer",
|
||||
"Missing key detail",
|
||||
"Wrong format",
|
||||
"Partially correct",
|
||||
"Completely off topic",
|
||||
],
|
||||
trajectories=[
|
||||
Trajectory(
|
||||
input_text=f"Input {i}",
|
||||
output_text=f"Output {i}",
|
||||
score=s,
|
||||
feedback=f,
|
||||
prompt_used="test prompt",
|
||||
)
|
||||
for i, (s, f) in enumerate(
|
||||
zip(
|
||||
[0.3, 0.5, 0.4, 0.6, 0.2],
|
||||
[
|
||||
"Incomplete answer",
|
||||
"Missing key detail",
|
||||
"Wrong format",
|
||||
"Partially correct",
|
||||
"Completely off topic",
|
||||
],
|
||||
)
|
||||
)
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_llm_port() -> MagicMock:
|
||||
"""Mock LLMPort that returns canned responses."""
|
||||
port = MagicMock()
|
||||
port.execute.return_value = "This is a mock response."
|
||||
return port
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_judge_port() -> MagicMock:
|
||||
"""Mock JudgePort that returns moderate scores."""
|
||||
port = MagicMock()
|
||||
port.judge_batch.return_value = [
|
||||
(0.5, "Moderate quality, needs improvement."),
|
||||
] * 5
|
||||
return port
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_proposer_port() -> MagicMock:
|
||||
"""Mock ProposerPort that returns a slightly modified prompt."""
|
||||
port = MagicMock()
|
||||
port.propose.return_value = Prompt(
|
||||
text="You are a very helpful assistant. Answer the question precisely."
|
||||
)
|
||||
return port
|
||||
Reference in New Issue
Block a user