mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-27 19:25:15 +02:00
feat: enhance memory API responses with limits and update UI components for memory limit handling
This commit is contained in:
parent
fa6d7c60bf
commit
73043a0756
9 changed files with 132 additions and 51 deletions
|
|
@ -1,9 +1,11 @@
|
|||
"""First-class memory service for user and team markdown memory."""
|
||||
|
||||
from .schemas import MemoryLimits, MemoryRead
|
||||
from .service import (
|
||||
MemoryScope,
|
||||
SaveResult,
|
||||
extract_and_save,
|
||||
memory_limits,
|
||||
read_memory,
|
||||
reset_memory,
|
||||
save_memory,
|
||||
|
|
@ -18,9 +20,12 @@ from .validation import (
|
|||
__all__ = [
|
||||
"MEMORY_HARD_LIMIT",
|
||||
"MEMORY_SOFT_LIMIT",
|
||||
"MemoryLimits",
|
||||
"MemoryRead",
|
||||
"MemoryScope",
|
||||
"SaveResult",
|
||||
"extract_and_save",
|
||||
"memory_limits",
|
||||
"read_memory",
|
||||
"reset_memory",
|
||||
"save_memory",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
"""Structured output schemas for memory extraction."""
|
||||
"""Schemas for memory API responses and structured extraction."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
|
|
@ -7,6 +7,20 @@ from typing import Literal
|
|||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class MemoryLimits(BaseModel):
|
||||
"""Canonical memory size limits exposed to clients."""
|
||||
|
||||
soft: int
|
||||
hard: int
|
||||
|
||||
|
||||
class MemoryRead(BaseModel):
|
||||
"""Memory document payload returned by user and team memory APIs."""
|
||||
|
||||
memory_md: str
|
||||
limits: MemoryLimits
|
||||
|
||||
|
||||
class MemoryExtractionDecision(BaseModel):
|
||||
"""Structured extraction result; avoids string sentinel parsing."""
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ from typing import Any, Literal
|
|||
from uuid import UUID
|
||||
|
||||
from langchain_core.messages import HumanMessage
|
||||
from pydantic import BaseModel
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
|
|
@ -19,9 +18,10 @@ from app.services.memory.prompts import (
|
|||
USER_MEMORY_EXTRACT_PROMPT,
|
||||
)
|
||||
from app.services.memory.rewrite import forced_rewrite
|
||||
from app.services.memory.schemas import MemoryExtractionDecision
|
||||
from app.services.memory.schemas import MemoryExtractionDecision, MemoryLimits
|
||||
from app.services.memory.validation import (
|
||||
MEMORY_HARD_LIMIT,
|
||||
MEMORY_SOFT_LIMIT,
|
||||
soft_limit_warning,
|
||||
strip_preamble_to_first_heading,
|
||||
validate_bullet_format,
|
||||
|
|
@ -68,8 +68,8 @@ class SaveResult:
|
|||
return data
|
||||
|
||||
|
||||
class MemoryRead(BaseModel):
|
||||
memory_md: str
|
||||
def memory_limits() -> MemoryLimits:
|
||||
return MemoryLimits(soft=MEMORY_SOFT_LIMIT, hard=MEMORY_HARD_LIMIT)
|
||||
|
||||
|
||||
def _normalize_scope(scope: MemoryScope | str) -> MemoryScope:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue