Phase 3: Skills & Context — skill system, personal context, context layering

Backend:
- Skill model + migration (with FK on chats.skill_id)
- Personal + general skill CRUD services with access isolation
- Admin skill CRUD endpoints (POST/GET/PATCH/DELETE /admin/skills)
- User skill CRUD endpoints (POST/GET/PATCH/DELETE /skills/)
- Personal context GET/PUT at /users/me/context
- Extended context assembly: primary + personal context + skill prompt
- Chat creation/update now accepts skill_id with validation

Frontend:
- Skill selector dropdown in chat header (grouped: general + personal)
- Reusable skill editor form component
- Admin skills management page (/admin/skills)
- Personal skills page (/skills)
- Personal context editor page (/profile/context)
- Updated sidebar: Skills, My Context nav items + admin skills link
- English + Russian translations for all skill/context UI

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-19 12:55:02 +03:00
parent 70469beef8
commit 03afb7a075
33 changed files with 1387 additions and 62 deletions

View File

@@ -17,7 +17,7 @@ from app.schemas.chat import (
SendMessageRequest,
UpdateChatRequest,
)
from app.services import chat_service
from app.services import chat_service, skill_service
from app.services.ai_service import stream_ai_response
router = APIRouter(prefix="/chats", tags=["chats"])
@@ -29,7 +29,9 @@ async def create_chat(
user: Annotated[User, Depends(get_current_user)],
db: Annotated[AsyncSession, Depends(get_db)],
):
chat = await chat_service.create_chat(db, user, data.title)
if data.skill_id:
await skill_service.validate_skill_accessible(db, data.skill_id, user.id)
chat = await chat_service.create_chat(db, user, data.title, data.skill_id)
return ChatResponse.model_validate(chat)
@@ -60,7 +62,9 @@ async def update_chat(
user: Annotated[User, Depends(get_current_user)],
db: Annotated[AsyncSession, Depends(get_db)],
):
chat = await chat_service.update_chat(db, chat_id, user.id, data.title, data.is_archived)
if data.skill_id:
await skill_service.validate_skill_accessible(db, data.skill_id, user.id)
chat = await chat_service.update_chat(db, chat_id, user.id, data.title, data.is_archived, data.skill_id)
return ChatResponse.model_validate(chat)