Commit Graph

52 Commits

Author SHA1 Message Date
Scarlet Moore
cddc5160e8 work/llm-error-framework (#35)
* feat: enhance error handling and logging in DocumentAdder

* feat: implement robust error handling utilities for API exceptions

* style: fix formatting issues

* feat: implement retry logic for LLM API calls to handle rate limits and timeouts

* feat: enhance document validation and error handling in file uploads

* feat: enhance valid tools configuration and error handling in project structure

* feat: refactor error handling and validation functions for improved robustness

* fix: pre-commit format

* feat: implement configuration validation for tool consistency and enhance error handling in file uploads

* feat: add exception hierarchy for LLM service errors to improve error handling

* chore: update repo roster images [skip ci]

* chore: update repo roster images [skip ci]

* Integrate documentation updates and rebase onto upstream dev

* Implement error handling utilities and validation functions

* feat: implement multi-provider support with enhanced capability handling and model extraction

* fix: enhance error handling and validation across multiple modules

* chore: remove unused local environment configuration file

* commit

* fix: improve error handling and logging in utilities and error handler

* fix: enhance error handling and logging across multiple modules

* fix: enhance async initialization and validation in multiple modules

* feat: implement LLM error framework

- Add LLM-specific exception classes in exceptions.py
- Create error mapping utilities for standardized error handling
- Implement base provider interface with error handling
- Add OpenAI provider implementation with error mapping
- Define LLM types and response structures

* feat: add missing registry and telemetry modules

- Add registry.py for provider registration system
- Add telemetry.py for basic LLM call tracking
- Complete the LLM error framework implementation

* fix(llm): safer sync wrapper + smarter retries + optional openai mapping

* Fix LLM error framework and code quality improvements

* feat: update environment configuration and improve logging in LLM services

* Update README.md

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Refactor code structure for improved readability and maintainability

* chore: update documentation, improve error handling, and enhance file upload validation

* feat: enhance error handling and configuration validation across multiple modules

* feat: add configuration for pytest, improve error handling, and enhance byte formatting utilities

---------

Co-authored-by: scrrlt <smo0051@student.monash.edu>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2026-01-13 16:58:13 +11:00
Scarlet Moore
eafdf21dd0 Merge pull request #24 from HKUDS/dev
Dev
2026-01-12 11:12:31 +11:00
Tushar Khatri
2de2772d43 Implement LlamaIndex RAG pipeline with dynamic provider selection
- Refactor knowledge base initialization to support dynamic RAG provider selection
  based on RAG_PROVIDER environment variable instead of hardcoded RAGAnything

- Implement VectorIndexer component for dense vector storage
  * Support FAISS for fast similarity search when available
  * Fallback to pickle-based storage with numpy cosine similarity
  * Store normalized vectors and metadata separately
  * Create vector_store directory structure for LlamaIndex KBs

- Implement DenseRetriever component for vector-based search
  * FAISS-based fast search when available
  * Numpy cosine similarity fallback
  * Return clean, formatted context without truncation or relevance prefixes
  * Compatible with existing RAG pipeline interface

- Update LlamaIndexPipeline to use PDFParser instead of TextParser
  * PDFParser uses PyMuPDF for reliable PDF text extraction
  * Supports both MinerU pre-parsed content and direct PDF parsing
  * Prevents raw PDF binary data from being indexed

- Modify KnowledgeBaseInitializer to use RAGService
  * Remove direct RAGAnything instantiation and configuration
  * Use RAGService which respects RAG_PROVIDER environment variable
  * Support all registered providers: raganything, lightrag, llamaindex, academic
  * Add generic statistics display for provider-agnostic KB info
  * Reduce initialization code from ~200 to ~90 lines

- Add PyMuPDF dependency for PDF text extraction
  * Required for PDFParser to extract clean text from PDF files
  * Version constraint: PyMuPDF>=1.23.0

- Fix DenseRetriever output formatting
  * Remove relevance score prefixes from retrieved chunks
  * Remove 800-character truncation limit
  * Use clean newline separators for better LLM context
  * Return formatted content suitable for direct LLM consumption

Storage structure comparison:
- RAGAnything/LightRAG: Uses rag_storage/ with knowledge graph files
- LlamaIndex: Uses vector_store/ with FAISS index or pickle embeddings

Key differences:
- RAGAnything: Makes 50-100+ LLM calls during KB creation for entity/relation extraction
- LlamaIndex: Makes 0 LLM calls during KB creation, only embedding API calls
- LlamaIndex is faster, cheaper, and avoids rate limits during indexing
- LLM only used during search/chat to generate final answers from retrieved context

Tested with:
- PDF document parsing and indexing
- Vector similarity search and retrieval
- Dynamic provider switching via environment variable
- Fallback to numpy when FAISS unavailable
2026-01-11 15:34:22 +05:30
Scarlet Moore
d7d2728a7a Merge pull request #11 from HKUDS/dev
Dev
2026-01-11 11:51:39 +11:00
Andres
e3b332fce4 Merge pull request #1 from Andres77872/dev
Dev
2026-01-10 10:34:20 -06:00
andres
239bc5dcc5 "Clean up formatting and fix code style inconsistencies across web search modules." 2026-01-10 00:49:45 -06:00
andres
a2ec0f202e "Remove deprecated web_search.py and update web search configuration with support for multiple providers." 2026-01-10 00:36:36 -06:00
Scarlet Moore
8f167c847e Merge branch 'dev' of https://github.com/HKUDS/DeepTutor into integrate/hk-dev 2026-01-10 01:06:21 +00:00
Pancake
1b3150e42e improve llm services 2026-01-10 01:08:21 +08:00
scrrlt
8161451d01 web: update lockfile (rebased on upstream/dev) 2026-01-09 16:07:59 +11:00
Scarlet Moore
307c8fda6e Web audit scaffolding: add Playwright config, fix tsconfig types, harden error fallback check and baseURL handling in compliance suite; add audit scripts and devdep for @playwright/test. 2026-01-09 15:59:25 +11:00
Bingxi Zhao
84509677f5 fix: docker deployment 2026-01-09 09:44:51 +08:00
Bingxi Zhao
df034d854b fix: llm providers, frontend 2026-01-09 09:29:17 +08:00
Pancake
42fb0ec8fd release ver0.4.0 2026-01-09 00:57:28 +08:00
Pancake
99ae39fcec Add new development files: RAG diagnostics, chat session detail, text parser 2026-01-09 00:47:24 +08:00
Pancake
efc2007911 Apply local configuration and UI enhancements after dev merge 2026-01-09 00:43:52 +08:00
Pancake
89fab8ace1 Merge dev into main: service refactoring with preserved main features 2026-01-08 21:11:11 +08:00
Bingxi Zhao (Frank)
00dbb53f07 Merge branch 'main' into feat/llm_models_support 2026-01-08 19:58:15 +08:00
kushal garg
317ad41851 minor ui improvements and sync with backend, also addition of llm providers 2026-01-08 15:42:43 +05:30
kushal garg
5143bff055 these werent made by me but have to commit them 2026-01-08 15:39:40 +05:30
Pancake
8d25d121ad fix: ui, security and web-search 2026-01-07 10:53:01 +08:00
Bingxi Zhao (Frank)
63f6d87bbe Merge pull request #51 from tusharkhatriofficial/ui/theme
UI/theme
2026-01-07 10:33:55 +08:00
RinCodeForge927
e071c3755b security: patch path traversal in jspdf and tighten pre-commit hooks
Cleaning up some critical vulnerabilities found during the last audit. Specifically:
- Upgraded jspdf in web/ to fix a critical Path Traversal vulnerability.
- Removed --exit-zero from ruff pre-commit hooks so we actually block broken code instead of just auto-fixing and moving on.
- Re-enabled ESLint in the pre-commit pipeline to maintain frontend code standards.
- Updated vitepress in docs/ to clear out some moderate CVEs in the dev server dependencies.
2026-01-06 23:52:01 +07:00
Pancake
cf595bf562 refactor: restructure project architecture with new services and logging modules 2026-01-06 23:49:33 +08:00
Tushar Khatri
44acb1a844 Complete RAG plugin system integration with full knowledge base support
✅ Fixed RAG Provider Selection Persistence:
- get_current_provider() now reads from env directly (not cached)
- Settings save button now saves environment variables
- Backend persists changes to .env file
- RAG provider selection survives page refreshes and server restarts

✅ Integrated Plugin System into Knowledge Base Upload Flow:
- initializer.py: Use RAG-Anything for extraction + selected plugin for indexing
- add_documents.py: Same hybrid approach for adding new documents
- Both LightRAG and LlamaIndex work seamlessly end-to-end

✅ Plugin Storage Architecture:
- LightRAG: data/knowledge_bases/{kb}/rag_storage/
- LlamaIndex: data/knowledge_bases/{kb}/llamaindex_storage/
- Both auto-create directories, no conflicts

✅ Complete Upload Flow:
1. User uploads files → saved to raw/
2. System checks RAG_PROVIDER from .env
3. RAG-Anything extracts content (PDFs, images, tables)
4. Extracted text fed to selected RAG plugin
5. Plugin builds index in provider-specific directory

✅ Files Modified:
- src/tools/rag_tool.py - Fixed get_current_provider()
- web/app/settings/page.tsx - Save env vars in handleSave()
- src/api/routers/settings.py - Persist to .env file
- src/knowledge/initializer.py - Plugin integration
- src/knowledge/add_documents.py - Plugin integration
- src/rag/plugins/lightrag.py - Auto-create directories
- src/rag/plugins/llamaindex.py - New plugin + auto-create dirs
- requirements.txt - Added llama-index dependencies

Result: Users can now seamlessly switch between LightRAG and LlamaIndex,
upload documents via dashboard, and everything works perfectly from start to end.
2026-01-06 17:47:20 +05:30
Tushar Khatri
bf21580e6c feat: implement flexible RAG plugin system with UI
Implement a modular plugin system for RAG providers that allows users to easily switch between different RAG implementations without code changes.

Core Features:
• Plugin-based architecture with automatic discovery
• Drop-in plugin support (no inheritance or factory patterns)
• Beautiful settings UI with dropdown selector
• Zero vendor lock-in - switch RAG systems instantly

Architecture:
• Created src/rag/ module with plugin infrastructure
• Auto-discovery plugin loader scans plugins directory
• Simple 3-function interface (initialize, search, delete)
• Plugin metadata with version, modes, and requirements

Backend Changes:
• Refactored src/tools/rag_tool.py to use plugin system
• Added RAG_PROVIDER environment variable to .env
• Created /api/v1/settings/rag/providers endpoint
• Updated settings API with RAG category configuration
• Migrated existing LightRAG implementation to plugin

Frontend Changes:
• Added RAG Provider section to settings page UI
• Beautiful dropdown with real-time provider descriptions
• Shows supported modes for each provider
• Auto-updates when new plugins are added

Plugin System Benefits:
✅ No code changes needed to add new RAG systems
✅ Community-friendly - anyone can contribute plugins
✅ Each knowledge base can use different RAG providers
✅ 50% less boilerplate than traditional patterns
✅ Production-ready with comprehensive documentation

Files Added:
- src/rag/__init__.py - Module initialization
- src/rag/plugin_loader.py - Auto-discovery engine
- src/rag/plugins/__init__.py - Plugins package
- src/rag/plugins/_template.py - Template for new plugins
- src/rag/plugins/lightrag.py - LightRAG plugin (default)
- src/rag/README.md - Complete documentation

Files Modified:
- src/tools/rag_tool.py - Refactored to use plugins
- src/api/routers/settings.py - Added RAG endpoints
- web/app/settings/page.tsx - Added RAG UI section
- .env - Added RAG_PROVIDER configuration

Usage:
# Switch RAG via .env
RAG_PROVIDER=lightrag

# Or via settings UI
Settings → General → RAG Provider dropdown

# Add new RAG (3 steps):
1. cp src/rag/plugins/_template.py src/rag/plugins/my_rag.py
2. Implement 3 functions (initialize, search, delete)
3. Done! Auto-discovered and available in UI

Technical Details:
- Plugin loader uses importlib for dynamic loading
- Validates required functions at load time
- Caches plugin instances for performance
- Supports multiple concurrent RAG providers
- Thread-safe plugin management

Documentation:
Comprehensive README.md with:
- Quick start guide
- API reference
- Plugin creation tutorial
- Usage examples
- Architecture diagrams

This implementation provides maximum flexibility while maintaining simplicity, enabling easy experimentation with different RAG systems and community contributions.
2026-01-06 17:16:20 +05:30
Tushar Khatri
485f8b5e4d Update web/app/settings/page.tsx
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-06 12:14:35 +05:30
Tushar Khatri
2218a743ed refactor: clean up theme system per code review
- Remove generation artifact (IMPLEMENTATION_COMPLETE.md)
- Consolidate duplicate theme checks in settings page
- Simplify theme precedence logic (localStorage > backend)
- Remove all console.log statements from theme code
- Add debounced auto-save (500ms) to prevent API spam
- Centralize theme API with subscriptions and constants
- Improve error handling (silent fails for localStorage)
- Guard all localStorage access for SSR compatibility

Addresses all feedback from @scrrlt review:
- No more redundant theme logic
- Single source of truth for theme operations
- Proper error handling without console noise
- Debounced network calls for better performance
2026-01-06 11:57:02 +05:30
Pancake
27712e1fe9 fix docker 2026-01-06 12:33:49 +08:00
Tushar Khatri
09fb559093 feat: improve settings UX with auto-save theme and sticky save button 2026-01-06 00:53:34 +05:30
Tushar Khatri
15f928fd68 feat: implement robust theme persistence with localStorage and SSR safety 2026-01-06 00:40:14 +05:30
Bingxi Zhao (Frank)
f6235d7ca0 Merge pull request #48 from HKUDS/dependabot/npm_and_yarn/web/types/node-25.0.3
chore(deps): bump @types/node from 22.19.3 to 25.0.3 in /web
2026-01-06 02:12:59 +08:00
dependabot[bot]
83fbdbaeb8 chore(deps): bump @types/node from 22.19.3 to 25.0.3 in /web
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 22.19.3 to 25.0.3.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

---
updated-dependencies:
- dependency-name: "@types/node"
  dependency-version: 25.0.3
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-05 18:11:53 +00:00
Bingxi Zhao (Frank)
12781eba65 Merge pull request #45 from HKUDS/dependabot/npm_and_yarn/web/tailwind-merge-3.4.0
chore(deps): bump tailwind-merge from 2.6.0 to 3.4.0 in /web
2026-01-06 02:09:21 +08:00
Bingxi Zhao (Frank)
dbef94a4c2 Merge pull request #44 from HKUDS/dependabot/npm_and_yarn/web/framer-motion-12.24.0
chore(deps): bump framer-motion from 11.18.2 to 12.24.0 in /web
2026-01-06 02:08:57 +08:00
Bingxi Zhao (Frank)
25b83982cd Merge pull request #47 from HKUDS/dependabot/npm_and_yarn/web/react-markdown-10.1.0
chore(deps): bump react-markdown from 9.1.0 to 10.1.0 in /web
2026-01-06 02:08:10 +08:00
dependabot[bot]
5c1a1b1ba8 chore(deps): bump framer-motion from 11.18.2 to 12.24.0 in /web
Bumps [framer-motion](https://github.com/motiondivision/motion) from 11.18.2 to 12.24.0.
- [Changelog](https://github.com/motiondivision/motion/blob/main/CHANGELOG.md)
- [Commits](https://github.com/motiondivision/motion/compare/v11.18.2...v12.24.0)

---
updated-dependencies:
- dependency-name: framer-motion
  dependency-version: 12.24.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-05 18:05:30 +00:00
dependabot[bot]
4e865dab57 chore(deps): bump react-markdown from 9.1.0 to 10.1.0 in /web
Bumps [react-markdown](https://github.com/remarkjs/react-markdown) from 9.1.0 to 10.1.0.
- [Release notes](https://github.com/remarkjs/react-markdown/releases)
- [Changelog](https://github.com/remarkjs/react-markdown/blob/main/changelog.md)
- [Commits](https://github.com/remarkjs/react-markdown/compare/9.1.0...10.1.0)

---
updated-dependencies:
- dependency-name: react-markdown
  dependency-version: 10.1.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-05 18:04:17 +00:00
dependabot[bot]
affcc1819d chore(deps): bump tailwind-merge from 2.6.0 to 3.4.0 in /web
Bumps [tailwind-merge](https://github.com/dcastil/tailwind-merge) from 2.6.0 to 3.4.0.
- [Release notes](https://github.com/dcastil/tailwind-merge/releases)
- [Commits](https://github.com/dcastil/tailwind-merge/compare/v2.6.0...v3.4.0)

---
updated-dependencies:
- dependency-name: tailwind-merge
  dependency-version: 3.4.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-05 17:58:46 +00:00
dependabot[bot]
1de3b76d73 chore(deps): bump lucide-react in /web in the npm-minor-patch group
Bumps the npm-minor-patch group in /web with 1 update: [lucide-react](https://github.com/lucide-icons/lucide/tree/HEAD/packages/lucide-react).


Updates `lucide-react` from 0.460.0 to 0.562.0
- [Release notes](https://github.com/lucide-icons/lucide/releases)
- [Commits](https://github.com/lucide-icons/lucide/commits/0.562.0/packages/lucide-react)

---
updated-dependencies:
- dependency-name: lucide-react
  dependency-version: 0.562.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: npm-minor-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-05 17:58:30 +00:00
Bingxi Zhao
d9abd3aa68 feat: release ver0.3.0 2026-01-06 01:56:17 +08:00
ahmedjawedaj
1c31299390 feat: Dynamic LLM Provider Support (Local & Cloud)
Enables seamless switching between multiple LLM providers, including robust support for local environments.

Changes:
- feat(core): Dynamic LLMProvider logic allows switching between OpenAI, Anthropic, Ollama, LM Studio, etc.
- feat(web): New settings UI for managing multiple provider configurations.
- feat(api): Intelligent connection testing with URL sanitization (fixes /chat/completions errors).
- feat(local): Auto-configuration for local providers (Ollama, LM Studio) including optional API keys.
- feat(web): Enhanced model fetching strategies for non-standard local APIs (/api/tags, /api/v0/models).
- fix(dashboard): System status tests now support local provider configurations.

This allows users to run DeepTutor entirely locally or hybrid with cloud providers.
2026-01-05 20:17:27 +05:00
Tushar Khatri
d312b9d7a3 fix(UI): unrendered markdown in ActivityDetail card 2026-01-04 19:08:51 +05:30
RinCodeForge927
86ff7f1ea2 feat: enhance websocket security and documentation
Updated WebSocket URL construction logic to clearly state security intent and updated README to recommend WSS for production.
2026-01-02 13:05:31 +07:00
Bingxi Zhao
6632cde879 update to Next.js 16 & React 19 from old version 2026-01-01 02:36:51 +08:00
Bingxi Zhao
bb30e89846 update to Next.js 16 & React 19 from old version 2026-01-01 02:12:06 +08:00
Bingxi Zhao
5dcda4948f improve install scripts and session management 2026-01-01 01:39:38 +08:00
Tushar Khatri
6d9df87bc4 fix(ui): knowledge base modal backdrop and positioning 2025-12-31 21:12:33 +05:30
Pancake
ba63fcad37 update 2025-12-29 13:25:10 +08:00
Pancake
4ecc0a18c4 update 2025-12-29 12:52:34 +08:00