Fixed RPG

This commit is contained in:
2026-06-01 07:44:38 +03:00
parent 600ad78f05
commit d4cd8f02f4
30 changed files with 1516 additions and 816 deletions
+4 -11
View File
@@ -1,11 +1,11 @@
from fastapi import APIRouter, HTTPException
from services.memory import (
get_all_sessions,
get_session,
get_or_create_session,
delete_session,
update_session_title,
update_session_persona,
get_history,
get_message_count,
update_session_rpg,
update_session_facts,
@@ -16,7 +16,6 @@ from services.memory import (
get_quests,
get_last_message_preview,
fork_session,
get_session,
)
from models.schemas import ForkSessionRequest
@@ -30,11 +29,7 @@ async def list_sessions():
for s in sessions:
count = await get_message_count(s["session_id"])
preview = await get_last_message_preview(s["session_id"])
result.append({
**s,
"message_count": count,
"last_message_preview": preview,
})
result.append({**s, "message_count": count, "last_message_preview": preview})
return result
@@ -44,9 +39,8 @@ async def list_quests(session_id: str):
@router.get("/{session_id}")
async def get_session(session_id: str):
sessions = await get_all_sessions()
s = next((x for x in sessions if x["session_id"] == session_id), None)
async def get_session_route(session_id: str):
s = await get_session(session_id)
if not s:
raise HTTPException(status_code=404, detail="Сессия не найдена")
return s
@@ -86,4 +80,3 @@ async def fork_session_route(session_id: str, req: ForkSessionRequest):
async def remove_session(session_id: str):
await delete_session(session_id)
return {"status": "deleted", "session_id": session_id}