-
Notifications
You must be signed in to change notification settings - Fork 170
feat: add RAG chat functionality with LLM integration #3013
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Implement RAG (Retrieval-Augmented Generation) chat feature that enables conversational search using LLM providers. The feature integrates Fess search results as context for generating AI-powered responses. Key components: - LLM client abstraction with support for Ollama, OpenAI, and Gemini - Chat session management with message history - REST API with SSE streaming support (/api/v1/chat/stream) - Web UI with chat interface accessible from header - Configurable via fess_config.properties Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add test classes for the new RAG chat functionality: - ChatMessageTest: tests for ChatMessage entity and ChatSource - ChatSessionTest: tests for ChatSession entity - LlmMessageTest: tests for LlmMessage class - LlmChatRequestTest: tests for LlmChatRequest class - LlmChatResponseTest: tests for LlmChatResponse class - LlmExceptionTest: tests for LlmException class Co-authored-by: Claude <noreply@anthropic.com>
* test: add unit tests for improved test coverage Add unit tests for previously untested components: - Service layer: FessAppServiceTest for base service functionality - Storage: StorageItemTest, StorageTypeTest for storage classes - Pagers: 24 new pager tests covering GroupPager, RolePager, UserPager, SchedulerPager, PathMapPager, KeyMatchPager, ElevateWordPager, FailureUrlPager, JobLogPager, FileConfigPager, WebConfigPager, RelatedContentPager, RelatedQueryPager, RoleTypePager, SearchLogPager, WebAuthPager, FileAuthPager, ReqHeaderPager, SynonymPager, KuromojiPager, StopwordsPager, ProtwordsPager, StemmerOverridePager, LabelTypePager - App jobs: AllJobSchedulerTest, ScriptExecutorJobTest for job scheduling These tests address the major coverage gaps identified in the analysis of the service layer (0%), pager classes (22.6%), storage classes (0%), and app job classes (0%). * fix: correct pager test field references to match actual class fields Update pager tests to use correct fields that exist in the pager classes: - SearchLogPagerTest: Use queryId, userSessionId, requestedTimeRange, accessType, logType instead of nonexistent id, searchWord, versionNo - WebAuthPagerTest: Use port, username, webConfigId instead of hostname - FailureUrlPagerTest: Use threadName, errorCount, errorName instead of versionNo - FileAuthPagerTest: Use port, username, fileConfigId instead of hostname - JobLogPagerTest: Use jobStatus, target, scriptType instead of versionNo --------- Co-authored-by: Claude <noreply@anthropic.com>
Add assertSame methods (with and without message parameter) to the base test case class for JUnit 5 compatibility. Also apply code formatting to LlmChatRequestTest. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add missing @beforeeach and @test annotations for JUnit 5 compatibility. Update setUp method signature to match UnitFessTestCase base class. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implement RAG (Retrieval-Augmented Generation) chat feature that enables conversational search using LLM providers. The feature integrates Fess search results as context for generating AI-powered responses. Key components: - LLM client abstraction with support for Ollama, OpenAI, and Gemini - Chat session management with message history - REST API with SSE streaming support (/api/v1/chat/stream) - Web UI with chat interface accessible from header - Configurable via fess_config.properties Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add test classes for the new RAG chat functionality: - ChatMessageTest: tests for ChatMessage entity and ChatSource - ChatSessionTest: tests for ChatSession entity - LlmMessageTest: tests for LlmMessage class - LlmChatRequestTest: tests for LlmChatRequest class - LlmChatResponseTest: tests for LlmChatResponse class - LlmExceptionTest: tests for LlmException class Co-authored-by: Claude <noreply@anthropic.com>
Add assertSame methods (with and without message parameter) to the base test case class for JUnit 5 compatibility. Also apply code formatting to LlmChatRequestTest. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add documentation to getChatSessionManager() and getChatClient() methods in ComponentUtil for improved API clarity. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Remove redundant getChatSessionManager() and getChatClient() methods that were duplicated without Javadoc documentation, keeping only the properly documented versions. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…nd UI - Add debug logging to WebApiManagerFactory, ChatApiManager, ChatClient, and LlmClientManager for better request tracing - Improve error handling in stream responses to prevent writing to committed responses - Update header.jsp to toggle search bar visibility on chat page and add search link for navigation back to search - Enhance chat.css with flexbox layout for better viewport height usage - Add waiting indicator text when streaming response starts - Add i18n labels for chat feature across all language files - Register chatPage flag in ChatAction for conditional rendering Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…wn rendering Add enhanced streaming chat with multi-phase RAG (Retrieval-Augmented Generation) flow: - Add ChatIntent enum for classifying user intent (search, summary, FAQ, chat) - Add IntentDetectionResult and RelevanceEvaluationResult for structured LLM responses - Add ChatPhaseCallback for progress notifications during multi-phase processing - Add MarkdownRenderer using commonmark and OWASP HTML Sanitizer for safe HTML output - Enhance ChatClient with streamChatEnhanced() supporting: - Intent detection phase - Keyword search phase - Relevance evaluation phase - Content retrieval phase - Answer generation with streaming - Markdown to HTML rendering - Update chat.js to display phase progress and rendered HTML Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces RAG (Retrieval-Augmented Generation) chat functionality to Fess, enabling conversational search powered by LLMs. The implementation provides a complete chat interface with streaming support and multi-provider LLM integration.
Changes:
- Implemented LLM client abstraction layer with support for Ollama (fully implemented), OpenAI, and Gemini providers
- Added complete RAG chat workflow including intent detection, search, relevance evaluation, and answer generation
- Created REST API endpoints with Server-Sent Events (SSE) for real-time streaming responses
Reviewed changes
Copilot reviewed 96 out of 96 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/test/java/org/codelibs/fess/unit/UnitFessTestCase.java | Added assertSame helper methods for test assertions |
| src/test/java/org/codelibs/fess/storage/StorageTypeTest.java | Added unit tests for StorageType enum values |
| src/test/java/org/codelibs/fess/storage/StorageItemTest.java | Added unit tests for StorageItem data class |
| src/test/java/org/codelibs/fess/llm/*.java | Added comprehensive unit tests for LLM message, request, response, and exception classes |
| src/test/java/org/codelibs/fess/helper/MarkdownRendererTest.java | Added tests for Markdown rendering with XSS protection validation |
| src/test/java/org/codelibs/fess/entity/ChatSessionTest.java | Added tests for chat session management and message handling |
| src/test/java/org/codelibs/fess/entity/ChatMessageTest.java | Added tests for chat message entities and source tracking |
| src/test/java/org/codelibs/fess/chat/*.java | Added tests for chat intent detection, relevance evaluation, and phase callbacks |
| src/test/java/org/codelibs/fess/app/service/FessAppServiceTest.java | Added tests for query wrapping functionality |
| src/test/java/org/codelibs/fess/app/pager/*.java | Added tests for pager objects to improve code coverage |
| src/test/java/org/codelibs/fess/app/job/*.java | Added basic tests for job scheduler classes |
| src/main/webapp/js/chat.js | Implemented client-side chat interface with SSE streaming and URL sanitization |
| src/main/webapp/css/chat.css | Added responsive chat UI styles with Bootstrap 5 compatibility |
| src/main/webapp/WEB-INF/view/chat/chat.jsp | Created chat page template with message display and input areas |
| src/main/webapp/WEB-INF/view/index.jsp | Added chat navigation link when feature is enabled |
| src/main/webapp/WEB-INF/view/header.jsp | Added bidirectional navigation between search and chat modes |
| src/main/resources/fess_llm.xml | Configured DI components for chat and LLM clients |
| src/main/resources/fess_label_*.properties | Added internationalized labels for 14 languages |
| src/main/resources/fess_config.properties | Added 51 new configuration properties for RAG chat and LLM providers |
| src/main/resources/fess_api.xml | Registered ChatApiManager before SearchApiManager to prevent route conflicts |
| src/main/resources/fess.xml | Included fess_llm.xml configuration |
| src/main/java/org/codelibs/fess/util/ComponentUtil.java | Added helper methods for chat components |
| src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java | Added configuration interface methods for RAG chat settings |
| src/main/java/org/codelibs/fess/mylasta/action/FessLabels.java | Added label constants for chat UI |
| src/main/java/org/codelibs/fess/mylasta/action/FessHtmlPath.java | Added path constant for chat JSP |
| src/main/java/org/codelibs/fess/llm/*.java | Implemented LLM client interfaces and Ollama integration with streaming support |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Changes Made
LLM Integration (
org.codelibs.fess.llm):LlmClientinterface with implementations for Ollama, OpenAI, and GeminiLlmClientManagerfor provider selection and managementChat Core (
org.codelibs.fess.chat):ChatClientfor RAG workflow (search → context → LLM response)ChatSessionManagerfor session persistence and history managementChatMessageandChatSessionentitiesWeb Layer:
ChatActioncontroller with chat page and session managementChatApiManagerfor REST API endpoints (/api/v1/chat,/api/v1/chat/stream)Configuration:
fess_config.propertiesfor LLM providers and chat settingsfess_llm.xmland updates tofess.xml,fess_api.xmlTesting
Breaking Changes
Additional Notes
🤖 Generated with Claude Code