Add brain memory services and APIs
Introduce the backend pieces for brain memory ingestion, routing, and system telemetry so the new knowledge workflows can project data into a brain view. The supporting tests lock in the new behavior and keep the expanded backend surface stable. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
57
backend/app/schemas/brain.py
Normal file
57
backend/app/schemas/brain.py
Normal file
@@ -0,0 +1,57 @@
|
||||
from datetime import datetime
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class BrainOverviewOut(BaseModel):
|
||||
active_memory_count: int
|
||||
important_tag_count: int
|
||||
secondary_tag_count: int
|
||||
recent_memory_titles: list[str]
|
||||
|
||||
|
||||
class BrainMemoryOut(BaseModel):
|
||||
id: str
|
||||
memory_type: str
|
||||
title: str
|
||||
content: str
|
||||
importance: int
|
||||
confidence: float
|
||||
status: str
|
||||
created_at: datetime
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
class BrainTagOut(BaseModel):
|
||||
id: str
|
||||
name: str
|
||||
category: str
|
||||
priority: str
|
||||
score: float
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
class BrainEventOut(BaseModel):
|
||||
id: str
|
||||
source_type: str
|
||||
source_id: str
|
||||
event_type: str
|
||||
title: str | None
|
||||
content_summary: str | None
|
||||
status: str
|
||||
created_at: datetime
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
class BrainTagGroupsOut(BaseModel):
|
||||
important: list[BrainTagOut]
|
||||
secondary: list[BrainTagOut]
|
||||
|
||||
|
||||
class BrainLearnRunOut(BaseModel):
|
||||
events_considered: int
|
||||
candidates_created: int
|
||||
memories_promoted: int
|
||||
@@ -12,6 +12,7 @@ class MessageOut(BaseModel):
|
||||
content: str
|
||||
model: str | None
|
||||
tokens_used: int | None
|
||||
attachments: list[dict] | None = None
|
||||
created_at: datetime
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
@@ -35,7 +36,8 @@ class ChatRequest(BaseModel):
|
||||
message: str
|
||||
conversation_id: str | None = None
|
||||
agent_id: str | None = None
|
||||
file_ids: list[str] = [] # 新增
|
||||
model_name: str | None = None
|
||||
file_ids: list[str] = []
|
||||
|
||||
|
||||
class ChatResponse(BaseModel):
|
||||
@@ -43,3 +45,4 @@ class ChatResponse(BaseModel):
|
||||
message_id: str
|
||||
content: str
|
||||
agent_name: str
|
||||
model_name: str | None = None
|
||||
|
||||
Reference in New Issue
Block a user