Skip to content

feat(chat): ChatService facade — unified chat CRUD + LLM generation (#645)#658

Merged
ShaerWare merged 1 commit intomainfrom
server/chat-service-facade-645
Mar 31, 2026
Merged

feat(chat): ChatService facade — unified chat CRUD + LLM generation (#645)#658
ShaerWare merged 1 commit intomainfrom
server/chat-service-facade-645

Conversation

@ShaerWare
Copy link
Copy Markdown
Owner

Summary

  • New ChatServiceImpl in modules/chat/facade.py — implements ChatService Protocol, wraps existing CRUD + sharing services, adds send_message() and stream_message() methods with full agentic RAG loop support
  • Refactored chat router — three endpoints (send, stream, edit/regenerate) now delegate LLM generation to the facade instead of ~500 lines of inline code
  • Extended StreamChunk schema with type field and event-specific fields (message, name, query, found) to support all SSE event types
  • Registered facade in ServiceContainer and orchestrator.py startup (Phase 7.4)

Architecture

Router retains HTTP concerns (auth, rate limiting, LLM backend resolution, image uploads, RAG config resolution). Facade owns the core flow: prompt assembly → RAG injection → context trimming → agentic tool loop → save response.

Closes #645

Test plan

  • All 183 existing tests pass
  • Python lint clean (ruff check)
  • Import verification (from modules.chat.facade import ChatServiceImpl)
  • CI green (lint-backend, lint-frontend, security)
  • Manual test: send message in admin chat (streaming)
  • Manual test: send message with agentic RAG enabled
  • Manual test: edit user message (triggers regeneration)
  • Manual test: regenerate assistant response

🤖 Generated with Claude Code

…645)

Implement ChatServiceImpl in modules/chat/facade.py that wraps existing
ChatService (CRUD) + ChatShareService with send_message() and stream_message()
methods, implementing the ChatService Protocol from protocols.py.

Refactored router to delegate LLM generation to the facade instead of inline
code. Removed ~500 lines of duplicated agentic RAG loop, prompt assembly, and
RAG injection from three router endpoints (send, stream, edit, regenerate).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ShaerWare ShaerWare merged commit 549f866 into main Mar 31, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Phase 7.4: ChatService facade — объединить chat CRUD + LLM-генерацию

2 participants