|
17 | 17 | from time import perf_counter |
18 | 18 | from typing import Any, Optional |
19 | 19 |
|
20 | | -from .engine.prompt_builder import append_output_instructions, resolve_output_schema |
21 | | -from .engine.react_runner import build_llm, build_react_agent, extract_tools_used, make_tool_logging_callback |
22 | 20 | from .engine.callbacks import make_streaming_callback |
23 | 21 | from .engine.event_bus import AgentEvent, agent_event_bus |
| 22 | +from .engine.prompt_builder import append_output_instructions, resolve_output_schema |
| 23 | +from .engine.react_runner import ( |
| 24 | + build_llm, |
| 25 | + build_react_agent, |
| 26 | + extract_tools_used, |
| 27 | + make_tool_logging_callback, |
| 28 | +) |
24 | 29 | from .evaluator import compute_score |
25 | 30 | from .evaluator import evaluate_run as _evaluate_criteria |
26 | 31 | from .models import ( |
|
41 | 46 | logger = logging.getLogger(__name__) |
42 | 47 |
|
43 | 48 |
|
| 49 | +def _default_model(explicit_model: str = "") -> str: |
| 50 | + if explicit_model: |
| 51 | + return explicit_model |
| 52 | + if os.getenv("AGENT_BACKEND", "").strip().lower() == "openai": |
| 53 | + return os.getenv("OPENAI_MODEL", "gpt-4o-mini") |
| 54 | + return os.getenv("LITELLM_MODEL", "github_copilot/gpt-4o") |
| 55 | + |
| 56 | + |
44 | 57 | # ============================================================================ |
45 | 58 | # CALCULATIONS (pure — no side effects, no I/O) |
46 | 59 | # ============================================================================ |
@@ -182,13 +195,13 @@ def __init__( |
182 | 195 | tool_registry: ToolRegistry, |
183 | 196 | db_path: Optional[Path] = None, |
184 | 197 | openai_api_key: str = "", |
185 | | - openai_model: str = "gpt-4o-mini", |
| 198 | + openai_model: str = "", |
186 | 199 | openai_base_url: str = "", |
187 | 200 | recursion_limit: int = 10, |
188 | 201 | ) -> None: |
189 | 202 | self._registry = tool_registry |
190 | 203 | self._api_key = openai_api_key or os.getenv("OPENAI_API_KEY", "") |
191 | | - self._model = openai_model or os.getenv("OPENAI_MODEL", "gpt-4o-mini") |
| 204 | + self._model = _default_model(openai_model) |
192 | 205 | self._base_url = openai_base_url or os.getenv("OPENAI_BASE_URL", "") |
193 | 206 | self._recursion_limit = recursion_limit |
194 | 207 | self._db_path = db_path or ( |
|
0 commit comments