Files
Prompt-optimizer/tests/integration/test_dspy_adapters.py
FullStackDev f516ca4be6 fix: multi-model routing — each adapter uses own dspy.LM instance
- DSPyLLMAdapter now accepts dspy.LM instead of model string, uses dspy.context(lm=...)
- DSPyJudgeAdapter, DSPyProposerAdapter, DSPySyntheticAdapter each accept and use own LM
- OptimizationConfig gains per-model api_base/api_key_env override fields
- cli/app.py creates separate dspy.LM per adapter with per-model overrides
- New unit tests verify each adapter isolates its LM from global config

Fixes Bug #1 (multi-model config not wired) and Bug #2 (DSPyLLMAdapter ignores model param).

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-03-29 12:31:48 +00:00

29 lines
789 B
Python

"""Integration tests for DSPy adapters using DSPy mock LM."""
from __future__ import annotations
import dspy
import pytest
from prometheus.domain.entities import Prompt
from prometheus.infrastructure.llm_adapter import DSPyLLMAdapter
@pytest.fixture
def mock_lm() -> dspy.LM:
"""Create a DSPy mock LM that returns predictable responses."""
lm = dspy.utils.DummyLM(
[
{"output": "Mock output response"},
]
)
return lm
class TestDSPyLLMAdapter:
def test_execute_returns_response(self, mock_lm: dspy.LM) -> None:
adapter = DSPyLLMAdapter(lm=mock_lm)
prompt = Prompt(text="Answer the question.")
result = adapter.execute(prompt, "What is 2+2?")
assert isinstance(result, str)
assert len(result) > 0