From 9d7395980e7ab1056f999f5889645a03b1684fcb Mon Sep 17 00:00:00 2001 From: Markov Andrey Date: Tue, 30 Jun 2026 20:58:00 +0000 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D0=B4=D0=B0=D0=BA=D1=82=D0=B8?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=B0=D1=82=D1=8C=20soma=5Fevaluate.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rag/functions/soma_evaluate.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/rag/functions/soma_evaluate.py b/rag/functions/soma_evaluate.py index 364222f..a752ae6 100644 --- a/rag/functions/soma_evaluate.py +++ b/rag/functions/soma_evaluate.py @@ -6,7 +6,7 @@ SOMA-анализ (LLM-as-judge) для оценки качества ответ import json import logging -from typing import Dict, Any, Optional +from typing import Dict, Any from rag.services.giga_client import GigaClient from rag.config_models import AppConfig @@ -61,15 +61,13 @@ async def soma_evaluate( default_result["error"] = "Отсутствует промпт soma_evaluate" return default_result - # Формируем полный промпт full_prompt = prompt_template.format( query=query, context=context[:3000] if context else "Нет контекста", answer=answer, ) - # Параметры из конфига (можно сделать отдельную секцию) - temperature = getattr(config, 'soma_temperature', 0.1) # низкая для детерминизма + temperature = getattr(config, 'soma_temperature', 0.1) timeout = getattr(config, 'soma_timeout', 30) try: @@ -79,14 +77,12 @@ async def soma_evaluate( system_prompt=None, file_id=None, temperature=temperature, - timeout=timeout, # нужно добавить timeout в GigaClient.chat (если нет, игнорировать) + timeout=timeout, ) - # Ожидаем JSON data = json.loads(response.strip()) scores = data.get("scores", {}) feedback = data.get("feedback", "") - # Приводим оценки к числам for key in scores: try: scores[key] = float(scores[key]) @@ -94,7 +90,6 @@ async def soma_evaluate( scores[key] = 3.0 overall = sum(scores.values()) / len(scores) if scores else 3.0 - # Порог можно задать в конфиге threshold = getattr(config, 'soma_threshold', 3.5) verdict = "pass" if overall >= threshold else "fail"