/
YoungFreddy
/
NetologyPipeLineService
Обзор
Документация
Войти
/
YoungFreddy
/
NetologyPipeLineService
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
config/validator.py
39 строк
1 KB
Igor
Initial commit: LLM сервис с FastAPI, pipeline, ретраями, fallback, кэшем
18 июл 2026, 17:01
18 июл 2026, 17:01
5b26a48
Код
Авторство
О чём код?
"""Валидатор конфигурации: проверяет обязательные поля и границы значений.""" from typing import Any, Dict, List def validate_config(config: Dict[str, Any]) -> List[str]: """Валидирует обязательные поля конфигурации. Args: config: Словарь с конфигурацией. Returns: Список ошибок валидации (пуст, если ошибок нет). """ errors = [] if not config.get("api_key"): errors.append("Missing required field: api_key") if not config.get("model"): errors.append("Missing required field: model") temperature = config.get("temperature") if temperature is not None and not (0 <= temperature <= 2): errors.append("temperature must be between 0 and 2") max_tokens = config.get("max_tokens") if max_tokens is not None and max_tokens <= 0: errors.append("max_tokens must be positive") max_retries = config.get("max_retries") if max_retries is not None and max_retries <= 0: errors.append("max_retries must be positive") api_timeout = config.get("api_timeout") if api_timeout is not None and api_timeout <= 0: errors.append("api_timeout must be positive") return errors