Skip to content

Conversation

@marevol
Copy link
Contributor

@marevol marevol commented Jan 11, 2026

Summary

  • Add RAG (Retrieval-Augmented Generation) chat feature for conversational search
  • Implement LLM client abstraction supporting multiple providers (Ollama, OpenAI, Gemini)
  • Provide REST API with SSE streaming for real-time chat responses

Changes Made

  • LLM Integration (org.codelibs.fess.llm):

    • LlmClient interface with implementations for Ollama, OpenAI, and Gemini
    • LlmClientManager for provider selection and management
    • Request/response models with streaming callback support
  • Chat Core (org.codelibs.fess.chat):

    • ChatClient for RAG workflow (search → context → LLM response)
    • ChatSessionManager for session persistence and history management
    • ChatMessage and ChatSession entities
  • Web Layer:

    • ChatAction controller with chat page and session management
    • ChatApiManager for REST API endpoints (/api/v1/chat, /api/v1/chat/stream)
    • Chat UI with JavaScript SSE client and CSS styling
  • Configuration:

    • New properties in fess_config.properties for LLM providers and chat settings
    • DI configuration in fess_llm.xml and updates to fess.xml, fess_api.xml
    • i18n labels for English and Japanese

Testing

  • Unit tests for LLM clients and chat session management
  • Manual testing with Ollama local setup
  • SSE streaming verified in browser

Breaking Changes

  • None

Additional Notes

  • Default LLM provider is Ollama (local, no API key required)
  • Rate limiting enabled by default (10 requests/minute)
  • Session timeout configurable (default 30 minutes)

🤖 Generated with Claude Code

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>
@marevol marevol changed the title feat: add RAG chat functionality with LLM integration WIP: feat: add RAG chat functionality with LLM integration Jan 11, 2026
@marevol marevol self-assigned this Jan 11, 2026
@marevol marevol added this to the 15.5.0 milestone Jan 11, 2026
marevol and others added 12 commits January 11, 2026 18:06
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>
@marevol marevol requested a review from Copilot January 12, 2026 09:42
Copy link
Contributor

Copilot AI left a 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.

@marevol marevol changed the title WIP: feat: add RAG chat functionality with LLM integration feat: add RAG chat functionality with LLM integration Jan 12, 2026
@marevol marevol merged commit c836b46 into master Jan 12, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants