File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,16 +12,18 @@ class LLMFactory:
1212 """
1313
1414 @staticmethod
15- def get_provider () -> LLMProvider :
15+ def get_provider (provider_name : str = None ) -> LLMProvider :
1616 # 1. Respect explicit steering if set
17- if settings .LLM_PROVIDER :
18- if settings .LLM_PROVIDER == "openai" and settings .OPENAI_API_KEY :
17+ active_provider = provider_name or settings .LLM_PROVIDER
18+ if active_provider :
19+ if active_provider == "openai" and settings .OPENAI_API_KEY :
1920 return OpenAIProvider (api_key = settings .OPENAI_API_KEY )
20- if settings . LLM_PROVIDER == "groq" and settings .GROQ_API_KEY :
21+ if active_provider == "groq" and settings .GROQ_API_KEY :
2122 return GroqProvider (api_key = settings .GROQ_API_KEY )
22- if settings . LLM_PROVIDER == "mock" :
23+ if active_provider == "mock" :
2324 return MockProvider ()
2425
26+
2527 # 2. Automatic Detection (Heuristic Discovery)
2628 if settings .OPENAI_API_KEY :
2729 logger .info ("llm_factory_auto_detect" , provider = "OpenAI" )
Original file line number Diff line number Diff line change 11from pydantic import BaseModel , Field
22from enum import Enum
3+ from typing import Optional
4+
35
46
57class SlippageStatus (str , Enum ):
Original file line number Diff line number Diff line change 1+ from unittest .mock import patch , AsyncMock
2+ import pytest
3+ from src .agents .performance import SlippageAnalyst , TruthGapDetector
4+ from src .schemas .performance import SlippageStatus
5+
6+ @pytest .mark .asyncio
7+ async def test_slippage_analyst_mock ():
8+ analyst = SlippageAnalyst (provider_name = "mock" )
9+ analysis = await analyst .analyze_performance_gap (
10+ promised_tasks = ["Refactor DB" ],
11+ actual_work_done = "Fixed some typos"
12+ )
13+ assert analysis .fulfillment_ratio == 0.9
14+ assert analysis .status == SlippageStatus .ON_TRACK
15+
16+ @pytest .mark .asyncio
17+ async def test_truth_gap_detector_mock ():
18+ detector = TruthGapDetector (provider_name = "mock" )
19+ analysis = await detector .detect_gap (
20+ check_in_text = "I'm 90% done" ,
21+ technical_evidence = "0 lines changed"
22+ )
23+ assert analysis .gap_detected is False
24+ assert analysis .truth_score == 0.95
You can’t perform that action at this time.
0 commit comments