Spaces:
Runtime error
Runtime error
Commit History
-
Merge branch 'main' of hf.co:spaces/rwxcloud/local-rag-chatbot
Erick Brito6f5d231 -
initial commit
Verified signaturee9511d1
-
fix: Update Gradio components for v6.0 API compatibilityβ
Julien Simon +1: Claude Opus 4.5Move css and theme parameters from gr.Blocks() to launch(), remove deprecated type and show_copy_button parameters from gr.Chatbot. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>29178b4 -
refactor: Simplify codebase and consolidate testsβ
Julien Simon +1: Claude Opus 4.5- Extract shared utilities: get_top_chunk_index(), get_document_source() - Add HYBRID_ALPHA_UI_DEFAULT to centralize config - Simplify score normalization in HybridRetriever - Fix redundant branches in hybrid search - Simplify update_rag_controls() in handlers - Consolidate 10 fragmented test files into 4 main files - Remove duplicate fixtures and test code Net reduction: 115 lines (-853/+738) Test files: 28 β 20 Coverage: 98.86% Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>b39a3c2 -
docs: Add CLAUDE.md with architecture guidance for Claude Codeβ
Julien Simon +1: Claude Opus 4.5Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>b57addf
-
fix: Batch document additions to avoid ChromaDB size limitβ
Julien Simon +1: Claude Opus 4.5ChromaDB has a max batch size of 5461 documents. When adding large numbers of chunks (e.g., 59336), the upsert fails. Added batching function to split documents into chunks of 5000. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>35ad3d5 -
chore: Exclude PDF directories from version controlβ
Julien Simon +1: Claude Opus 4.5PDFs should be added locally by users as needed. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>1f6e10e -
docs: Add llama.cpp setup instructions for Trinity-Mini Q8 modelβ
Julien Simon +1: Claude Opus 4.5Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>cc10075 -
refactor: Reorganize PDFs and improve error handlingβ
Julien Simon +1: Claude Opus 4.5- Move arXiv research papers to pdf_research/ directory - Add IEA energy reports and publications to pdf_energy/ - Update README to reflect new document content (clean energy, renewables, EVs, CCUS) - Create pdf symlink for default document source - Improve security by hiding internal error details from users in stream output - Replace print statements with proper logger.warning/error calls - Remove TEST_REVIEW.md and .DS_Store files - Add consistent trailing newlines to source files Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>ed005f8
-
fix: Address code review security and quality issuesβ
Julien Simon +1: Claude Opus 4.5Security fixes: - Add path traversal protection via document filter allowlist - Add input length validation (MAX_QUERY_LENGTH=10000) - Add Gradio rate limiting (queue with max_size=20, concurrency=2) Code quality improvements: - Replace sys.exit() with FileNotFoundError in vectorstore.py - Fix lazy loading retry loop in qa_chain.py using sentinel pattern - Add error logging for silent failures in retrievers.py - Optimize O(n*m) to O(n) document matching in hybrid search - Make EMBEDDING_MODEL and RERANKER_MODEL configurable via env vars - Add proper exports to ui/__init__.py - Remove unused dependencies (streamlit, pandas, plotly) Test updates: - Update tests for new exception types and function signatures π€ Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>1521cd2 -
Add comprehensive tests for context formatting featuresβ
Julien Simon- Add 9 new tests for context formatting and top chunk emphasis - Fix 3 failing tests by using proper Document objects instead of Mock objects - Test coverage for: top chunk emphasis (similarity/distance scores), source name extraction, context headers, document matching edge cases - All 162 tests passing with 97.85% coveragee059064 -
feat: emphasize top chunk and add contextual headers in RAG contextβ
Julien SimonImprove RAG context formatting to follow best practices by explicitly highlighting the most relevant chunk and adding contextual metadata. Changes: - Identify top chunk based on similarity/distance scores - Wrap top chunk with [MOST RELEVANT CONTEXT] tags to guide model focus - Add document name and page number headers to each chunk for better traceability and context understanding - Use clear delimiters (---) between chunks for improved readability This follows RAG best practices by: - Explicitly emphasizing the most relevant information for the model - Providing contextual headers that help the model understand source information - Maintaining clear structure that improves model comprehension The model now receives structured context with clear emphasis on the top-ranked chunk while still considering supporting context from other chunks.b7afa04 -
Update sample prompts to reflect energy-related IEA documentsβ
Julien SimonReplace research paper example questions with energy-focused prompts that align with the new World Energy Agency document collection. The new examples include: - General exploratory questions about energy transitions, policies, and trends - Specific data-focused questions about renewable capacity, emissions targets, and investment projections Topics covered: net zero pathways, renewables, EVs, energy investment, critical minerals, energy efficiency, and developing country transitions.08980d3 -
Fix: Wrap Gradio event handlers in Blocks context (#1)β
Julien Simon- Wrap all event handler attachments in 'with demo:' block - Fixes AttributeError: Cannot call submit outside of a gradio.Blocks context - Application now starts successfullya82f331
-
Add .gitignore for test artifacts and coverage reports
Julien Simone1bc002 -
Add comprehensive test suite with 98.28% coverageβ
Julien Simon- Add 34 new high-priority tests covering critical workflows: * Multi-turn conversations with chat history (4 tests) * Mode switching between RAG and Vanilla LLM (4 tests) * Network and API failure scenarios (9 tests) * Empty vectorstore and initial state handling (8 tests) * Input validation and edge cases (8 tests) - Add test review document (TEST_REVIEW.md) with critical analysis - Add coverage configuration (.coveragerc) to exclude test files - Update pytest.ini with coverage configuration Test Results: - 153 tests passing (up from 119) - 98.28% code coverage (maintained) - All modules at 100% except qa_chain (98%) and retrievers (93%) Covers all critical user workflows and production edge cases.7ab7df1 -
Refactor codebase for improved maintainability and readabilityβ
Julien Simon- Split monolithic files into logical modules: * config.py: Centralized configuration constants * models.py: LLM and embedding model creation * vectorstore.py: Vectorstore management * retrievers.py: Retrieval strategies (MMR, similarity, hybrid) * qa_chain.py: QA chain wrapper with streaming support * utils.py: Utility functions (formatting, chat history) * ui/: UI components separated into app.py, components.py, handlers.py * cli.py: CLI entry point (replaces demo.py) - Improvements: * Removed dead code (format_sources function) * Fixed bug in format_context_with_highlight * Added error handling for empty collections * Fixed missing imports * Improved code organization and separation of concerns - All functionality preserved and testedc319b15 -
feat: enhance RAG UI/UX and fix ChromaDB filter syntaxβ
Julien SimonMajor improvements to the RAG-powered document chat interface: UI/UX Enhancements: - Set default to "no RAG" mode for cleaner initial experience - Hide all RAG controls (search type, doc filter, context panel) when RAG is disabled - Convert context panel to Markdown component for proper rendering - Add context header that toggles visibility with RAG state - Remove sources from chatbot output; display only in dedicated context panel - Add "β TOP MATCH" highlighting for similarity search results Search & Retrieval: - Add UI toggle for MMR vs Similarity search strategies - Fix ChromaDB filter syntax: replace unsupported $contains with $eq - Pass similarity scores through pipeline for context highlighting - Improve source relevance filtering based on question keywords Prompting Improvements: - Refine RAG prompt for more natural, conversational responses - Add system message to vanilla LLM to prevent "Sources:" hallucinations - Update example questions to pointy, fact-based queries that β¦e2f4c8c -
feat: Add MMR retrieval, metadata filtering, and document filter UIβ
Julien Simon +1: Claude Opus 4.5- Upgrade ChromaDB from 1.0.20 to 1.4.0 - Implement MMR (Maximal Marginal Relevance) for diverse retrieval results - Fetches 10 candidates, returns top 3 diverse matches - Configurable via RETRIEVER_FETCH_K and MMR_LAMBDA constants - Add metadata filtering support to QAChainWrapper - Filter by source document, page range, or custom criteria - Add document filter dropdown to Gradio UI - Dynamically populated from indexed documents - Disabled when RAG mode is off - Migrate Gradio Chatbot from deprecated tuples to messages format - Uses OpenAI-style {"role": "user/assistant", "content": ...} - Add messages_to_tuples() converter for QA chain compatibility π€ Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>285d6fb -
feat: Migrate to local llama-server with streaming supportβ
Julien Simon +1: Claude Opus 4.5- Replace Arcee Conductor with local llama-server (OpenAI-compatible API) - Add token-by-token streaming in Gradio chat interface - Remove unused LangGraph complexity, simplify to retriever + prompt - Extract configuration to environment variables (OPENAI_BASE_URL, etc.) - Add error handling for LLM connection failures - Extract format_chat_history() helper to eliminate code duplication - Add named constants for RETRIEVER_K and CHAT_HISTORY_LIMIT - Remove langgraph dependency from requirements.txt - Add version constraints to requirements.txt π€ Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>72d06f4
-
- Clean upβ
Julien Simon- Add READMEs410c49a
-
Linting
Julien Simoneeca514 -
Move to top folder
Julien Simonf19810a -
Initial version
Julien Simon476265b -
Initial version
Julien Simonca0697e
-
Add example
Julien Simon70dbba9 -
quote> - More commentsβ
Julien Simonquote> - Fix multi-turn conversation for vanilla queries6143408 -
Add streaming for vanilla answer
Julien Simon6ef1bb3 -
Formatting
Julien Simon7efc364 -
Initial version
Julien Simonab96bbb