fixed reasoning

This commit is contained in:
2026-06-10 13:06:44 +03:00
parent 8eb6505724
commit 07e9ef6e04
5 changed files with 105 additions and 36 deletions
+9 -1
View File
@@ -5,6 +5,7 @@ from typing import Any
from sqlalchemy.orm import Session
from app.config import get_settings
from app.llm.client import LLMClient
from app.memory.service import MemoryService
from app.projects.structuring import strip_markdown_json
@@ -61,6 +62,9 @@ async def _call_extractor(
*[f"- {f.get('content')}" for f in facts[:30]],
]
settings = get_settings()
extract_model = settings.memory_extract_model.strip() or None
llm = LLMClient()
result = await llm.complete(
[
@@ -72,11 +76,12 @@ async def _call_extractor(
+ "\n\n---\nДиалог:\nПользователь: "
+ user_text
+ "\nАссистент: "
+ (assistant_text[:1500] if assistant_text else "(нет ответа)")
+ assistant_text[:1500]
),
},
],
temperature=0.2,
model=extract_model,
)
raw = strip_markdown_json(result.get("content") or "")
if not raw:
@@ -98,6 +103,9 @@ async def extract_after_turn(
if not force and _should_skip_extraction(user_text):
return {"ok": True, "skipped": "short_message", "saved": []}
if not (assistant_text or "").strip():
return {"ok": True, "skipped": "no_assistant_reply", "saved": []}
memory = MemoryService(db)
snapshot = memory.snapshot(session_id)