- Implemented SettingsPage for configuring default provider, temperature, and model paths. - Added SuitePage for managing a suite of questions with features to add, edit, duplicate, and delete questions. - Introduced TypeScript configuration files for app and node environments. - Set up Vite configuration for development server with API proxying to backend.
104 lines
2.9 KiB
Python
104 lines
2.9 KiB
Python
"""Import shim for the ``.core`` engine package.
|
|
|
|
``.core`` is a hidden directory, so it cannot be imported as a normal package.
|
|
The CLI (``auto-test.py``) works around this by putting the directory on
|
|
``sys.path`` and importing its modules flat. We do the same thing here, in one
|
|
place, so the rest of the server can just ``from .core_bridge import run_suite``.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
ROOT_DIR = Path(__file__).resolve().parent.parent
|
|
CORE_DIR = ROOT_DIR / ".core"
|
|
|
|
if str(CORE_DIR) not in sys.path:
|
|
sys.path.insert(0, str(CORE_DIR))
|
|
|
|
# ruff: noqa: E402 (imports must follow the sys.path mutation above)
|
|
from config import ( # type: ignore[import-not-found]
|
|
DEFAULT_PROVIDER_NAME,
|
|
DEFAULT_TEMPERATURE,
|
|
MODELS_DIR,
|
|
RESULTS_DIR,
|
|
TEMPLATE_PATH,
|
|
TESTS_DIR,
|
|
ensure_directories,
|
|
)
|
|
from engine_loader import ( # type: ignore[import-not-found]
|
|
EngineLoadError,
|
|
detect_architecture,
|
|
load_engine_class,
|
|
)
|
|
from prompts import load_test_prompts # type: ignore[import-not-found]
|
|
from providers import ( # type: ignore[import-not-found]
|
|
LocalEngineProvider,
|
|
ModelInfo,
|
|
Provider,
|
|
ProviderError,
|
|
get_provider,
|
|
list_provider_names,
|
|
)
|
|
from reporting import ( # type: ignore[import-not-found]
|
|
TemplateNotFoundError,
|
|
append_sections,
|
|
finalize_report_summary,
|
|
replace_analysis_section,
|
|
sanitize_model_name,
|
|
)
|
|
from runner import TestRunError, run_suite # type: ignore[import-not-found]
|
|
from settings import ( # type: ignore[import-not-found]
|
|
get_local_model_paths,
|
|
load_settings,
|
|
save_settings,
|
|
set_local_model_paths,
|
|
)
|
|
|
|
__all__ = [
|
|
"CORE_DIR",
|
|
"DEFAULT_PROVIDER_NAME",
|
|
"EngineLoadError",
|
|
"detect_architecture",
|
|
"load_engine_class",
|
|
"DEFAULT_TEMPERATURE",
|
|
"MODELS_DIR",
|
|
"ModelInfo",
|
|
"Provider",
|
|
"ProviderError",
|
|
"RESULTS_DIR",
|
|
"ROOT_DIR",
|
|
"TEMPLATE_PATH",
|
|
"TESTS_DIR",
|
|
"TemplateNotFoundError",
|
|
"TestRunError",
|
|
"LocalEngineProvider",
|
|
"append_sections",
|
|
"ensure_directories",
|
|
"finalize_report_summary",
|
|
"replace_analysis_section",
|
|
"get_local_model_paths",
|
|
"get_provider",
|
|
"list_provider_names",
|
|
"load_settings",
|
|
"load_test_prompts",
|
|
"run_suite",
|
|
"sanitize_model_name",
|
|
"save_settings",
|
|
"set_local_model_paths",
|
|
]
|
|
|
|
|
|
def provider_kwargs(provider_name: str) -> dict:
|
|
"""Build constructor kwargs for a provider, mirroring the runner's logic."""
|
|
if provider_name == LocalEngineProvider.name:
|
|
custom_paths = [Path(p).expanduser() for p in get_local_model_paths()]
|
|
return {"search_paths": [path for path in custom_paths if path]}
|
|
return {}
|
|
|
|
|
|
def build_provider(provider_name: str) -> Provider:
|
|
"""Instantiate a provider with the correct per-provider configuration."""
|
|
return get_provider(provider_name, **provider_kwargs(provider_name))
|