fixed memmory
This commit is contained in:
@@ -5,6 +5,7 @@ from typing import Any
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.config import get_settings
|
||||
from app.character.service import CharacterService
|
||||
from app.chat.notices import (
|
||||
POMODORO_TOOL_NAMES,
|
||||
@@ -16,6 +17,7 @@ from app.memory.context import (
|
||||
format_memory_context,
|
||||
get_memory_snapshot,
|
||||
)
|
||||
from app.memory.extract import extract_after_turn
|
||||
from app.projects.context import format_projects_context, get_projects_snapshot
|
||||
from app.db.models import ChatSession, Message
|
||||
from app.llm.client import LLMClient
|
||||
@@ -184,7 +186,20 @@ class ChatService:
|
||||
if final_content:
|
||||
self._save_message(session_id, "assistant", final_content)
|
||||
|
||||
yield self._sse("done", {})
|
||||
memory_meta: dict[str, Any] = {}
|
||||
if get_settings().memory_auto_extract:
|
||||
extraction = await extract_after_turn(
|
||||
self.db,
|
||||
session_id,
|
||||
user_text,
|
||||
final_content,
|
||||
)
|
||||
memory_meta = {
|
||||
"memory_extracted": extraction.get("count", 0),
|
||||
"memory_saved": extraction.get("saved", []),
|
||||
}
|
||||
|
||||
yield self._sse("done", memory_meta)
|
||||
return
|
||||
|
||||
yield self._sse("error", {"message": "Too many tool call rounds"})
|
||||
|
||||
Reference in New Issue
Block a user