Phase 2: Chat & AI Core — Claude API streaming, chat UI, admin context

Backend:
- Chat, Message, ContextFile models + Alembic migration
- Chat CRUD with per-user limit enforcement (max_chats)
- SSE streaming endpoint: saves user message, streams Claude response,
  saves assistant message with token usage metadata
- Context assembly: primary context file + conversation history
- Admin context CRUD (GET/PUT with version tracking)
- Anthropic SDK integration with async streaming
- Chat ownership isolation (users can't access each other's chats)

Frontend:
- Chat page with sidebar chat list + main chat window
- Real-time SSE streaming via fetch + ReadableStream
- Message bubbles with Markdown rendering (react-markdown)
- Auto-growing message input (Enter to send, Shift+Enter newline)
- Zustand chat store for streaming state management
- Admin primary context editor with unsaved changes warning
- Updated routing: /chat, /chat/:chatId, /admin/context
- Enabled Chat and Admin sidebar navigation
- English + Russian translations for all new UI

Infrastructure:
- nginx: disabled proxy buffering for SSE support
- Added ANTHROPIC_API_KEY and CLAUDE_MODEL to config

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-19 12:38:30 +03:00
parent 7c752cae6b
commit 70469beef8
39 changed files with 4168 additions and 47 deletions

View File

@@ -42,6 +42,28 @@
"welcome": "Welcome, {{name}}",
"subtitle": "Your personal AI health assistant"
},
"chat": {
"new_chat": "New Chat",
"no_chats": "No chats yet. Create one to get started.",
"no_messages": "Start a conversation...",
"select_chat": "Select a chat to start messaging",
"type_message": "Type a message...",
"send": "Send",
"archive": "Archive",
"unarchive": "Unarchive",
"delete_confirm": "Are you sure you want to delete this chat?",
"limit_reached": "Chat limit reached",
"streaming": "AI is thinking..."
},
"admin": {
"context_editor": "Primary Context Editor",
"context_placeholder": "Enter the system prompt for the AI assistant...",
"save": "Save",
"saved": "Saved",
"unsaved_changes": "Unsaved changes",
"version": "Version",
"characters": "characters"
},
"common": {
"loading": "Loading...",
"error": "An error occurred",

View File

@@ -42,6 +42,28 @@
"welcome": "Добро пожаловать, {{name}}",
"subtitle": "Ваш персональный ИИ-ассистент по здоровью"
},
"chat": {
"new_chat": "Новый чат",
"no_chats": "Пока нет чатов. Создайте первый.",
"no_messages": "Начните разговор...",
"select_chat": "Выберите чат для начала общения",
"type_message": "Введите сообщение...",
"send": "Отправить",
"archive": "Архивировать",
"unarchive": "Разархивировать",
"delete_confirm": "Вы уверены, что хотите удалить этот чат?",
"limit_reached": "Достигнут лимит чатов",
"streaming": "ИИ думает..."
},
"admin": {
"context_editor": "Редактор основного контекста",
"context_placeholder": "Введите системный промпт для ИИ-ассистента...",
"save": "Сохранить",
"saved": "Сохранено",
"unsaved_changes": "Несохранённые изменения",
"version": "Версия",
"characters": "символов"
},
"common": {
"loading": "Загрузка...",
"error": "Произошла ошибка",