обновлен процесс обработки данных

This commit is contained in:
Даниил Грабарь
2026-10-26 11:29:03 +10:00
parent 1059b47978
commit 879d90605c
6 changed files with 219 additions and 32 deletions
+3
View File
@@ -4,6 +4,7 @@ import re
from typing import Literal
from pydantic import Field, field_validator
from pydantic_ai.exceptions import UnexpectedModelBehavior
from llm.config import ConfigModel
from .prompts import render
from .language import validate_texts, action_text
@@ -63,6 +64,8 @@ async def enrich(episode, config, agent, prompts):
except Exception as exc:
# API exceptions may contain request headers. Persist the class only.
error = {'scenario_id': episode['scenario_id'], 'error_type': type(exc).__name__, 'attempts': attempt + 1}
if not isinstance(exc, (ValueError, UnexpectedModelBehavior)) and attempt == config.retries:
raise RuntimeError(f'Запрос LLM не выполнен: {type(exc).__name__}. Генерация остановлена.') from None
if isinstance(exc, ValueError):
prompt = render(prompts.teacher_retry, canonical({'instruction': episode['instruction'], 'scene': teacher_scene,
'validation_error': str(exc)[:500]}))