* refactor: Unify examples interface with BaseRAGExample - Create BaseRAGExample base class for all RAG examples - Refactor 4 examples to use unified interface: - document_rag.py (replaces main_cli_example.py) - email_rag.py (replaces mail_reader_leann.py) - browser_rag.py (replaces google_history_reader_leann.py) - wechat_rag.py (replaces wechat_history_reader_leann.py) - Maintain 100% parameter compatibility with original files - Add interactive mode support for all examples - Unify parameter names (--max-items replaces --max-emails/--max-entries) - Update README.md with new examples usage - Add PARAMETER_CONSISTENCY.md documenting all parameter mappings - Keep main_cli_example.py for backward compatibility with migration notice All default values, LeannBuilder parameters, and chunking settings remain identical to ensure full compatibility with existing indexes. * fix: Update CI tests for new unified examples interface - Rename test_main_cli.py to test_document_rag.py - Update all references from main_cli_example.py to document_rag.py - Update tests/README.md documentation The tests now properly test the new unified interface while maintaining the same test coverage and functionality. * fix: Fix pre-commit issues and update tests - Fix import sorting and unused imports - Update type annotations to use built-in types (list, dict) instead of typing.List/Dict - Fix trailing whitespace and end-of-file issues - Fix Chinese fullwidth comma to regular comma - Update test_main_cli.py to test_document_rag.py - Add backward compatibility test for main_cli_example.py - Pass all pre-commit hooks (ruff, ruff-format, etc.) * refactor: Remove old example scripts and migration references - Delete old example scripts (mail_reader_leann.py, google_history_reader_leann.py, etc.) - Remove migration hints and backward compatibility - Update tests to use new unified examples directly - Clean up all references to old script names - Users now only see the new unified interface * fix: Restore embedding-mode parameter to all examples - All examples now have --embedding-mode parameter (unified interface benefit) - Default is 'sentence-transformers' (consistent with original behavior) - Users can now use OpenAI or MLX embeddings with any data source - Maintains functional equivalence with original scripts * docs: Improve parameter categorization in README - Clearly separate core (shared) vs specific parameters - Move LLM and embedding examples to 'Example Commands' section - Add descriptive comments for all specific parameters - Keep only truly data-source-specific parameters in specific sections * docs: Make example commands more representative - Add default values to parameter descriptions - Replace generic examples with real-world use cases - Focus on data-source-specific features in examples - Remove redundant demonstrations of common parameters * docs: Reorganize parameter documentation structure - Move common parameters to a dedicated section before all examples - Rename sections to 'X-Specific Arguments' for clarity - Remove duplicate common parameters from individual examples - Better information architecture for users * docs: polish applications * docs: Add CLI installation instructions - Add two installation options: venv and global uv tool - Clearly explain when to use each option - Make CLI more accessible for daily use * docs: Clarify CLI global installation process - Explain the transition from venv to global installation - Add upgrade command for global installation - Make it clear that global install allows usage without venv activation * docs: Add collapsible section for CLI installation - Wrap CLI installation instructions in details/summary tags - Keep consistent with other collapsible sections in README - Improve document readability and navigation * style: format * docs: Fix collapsible sections - Make Common Parameters collapsible (as it's lengthy reference material) - Keep CLI Installation visible (important for users to see immediately) - Better information hierarchy * docs: Add introduction for Common Parameters section - Add 'Flexible Configuration' heading with descriptive sentence - Create parallel structure with 'Generation Model Setup' section - Improve document flow and readability * docs: nit * fix: Fix issues in unified examples - Add smart path detection for data directory - Fix add_texts -> add_text method call - Handle both running from project root and examples directory * fix: Fix async/await and add_text issues in unified examples - Remove incorrect await from chat.ask() calls (not async) - Fix add_texts -> add_text method calls - Verify search-complexity correctly maps to efSearch parameter - All examples now run successfully * feat: Address review comments - Add complexity parameter to LeannChat initialization (default: search_complexity) - Fix chunk-size default in README documentation (256, not 2048) - Add more index building parameters as CLI arguments: - --backend-name (hnsw/diskann) - --graph-degree (default: 32) - --build-complexity (default: 64) - --no-compact (disable compact storage) - --no-recompute (disable embedding recomputation) - Update README to document all new parameters * feat: Add chunk-size parameters and improve file type filtering - Add --chunk-size and --chunk-overlap parameters to all RAG examples - Preserve original default values for each data source: - Document: 256/128 (optimized for general documents) - Email: 256/25 (smaller overlap for email threads) - Browser: 256/128 (standard for web content) - WeChat: 192/64 (smaller chunks for chat messages) - Make --file-types optional filter instead of restriction in document_rag - Update README to clarify interactive mode and parameter usage - Fix LLM default model documentation (gpt-4o, not gpt-4o-mini) * feat: Update documentation based on review feedback - Add MLX embedding example to README - Clarify examples/data content description (two papers, Pride and Prejudice, Chinese README) - Move chunk parameters to common parameters section - Remove duplicate chunk parameters from document-specific section * docs: Emphasize diverse data sources in examples/data description * fix: update default embedding models for better performance - Change WeChat, Browser, and Email RAG examples to use all-MiniLM-L6-v2 - Previous Qwen/Qwen3-Embedding-0.6B was too slow for these use cases - all-MiniLM-L6-v2 is a fast 384-dim model, ideal for large-scale personal data * add response highlight * change rebuild logic * fix some example * feat: check if k is larger than #docs * fix: WeChat history reader bugs and refactor wechat_rag to use unified architecture * fix email wrong -1 to process all file * refactor: reorgnize all examples/ and test/ * refactor: reorganize examples and add link checker * fix: add init.py * fix: handle certificate errors in link checker * fix wechat * merge * docs: update README to use proper module imports for apps - Change from 'python apps/xxx.py' to 'python -m apps.xxx' - More professional and pythonic module calling - Ensures proper module resolution and imports - Better separation between apps/ (production tools) and examples/ (demos) --------- Co-authored-by: yichuan520030910320 <yichuan_wang@berkeley.edu>
165 lines
4.1 KiB
TOML
165 lines
4.1 KiB
TOML
[build-system]
|
|
requires = ["setuptools>=61.0", "cmake>=3.24"]
|
|
build-backend = "setuptools.build_meta"
|
|
|
|
[project]
|
|
name = "leann-workspace"
|
|
version = "0.1.0"
|
|
requires-python = ">=3.9"
|
|
|
|
dependencies = [
|
|
"leann-core",
|
|
"leann-backend-hnsw",
|
|
"numpy>=1.26.0",
|
|
"torch",
|
|
"tqdm",
|
|
"flask",
|
|
"flask_compress",
|
|
"datasets>=2.15.0",
|
|
"evaluate",
|
|
"colorama",
|
|
"boto3",
|
|
"protobuf==4.25.3",
|
|
"sglang",
|
|
"ollama",
|
|
"requests>=2.25.0",
|
|
"sentence-transformers>=2.2.0",
|
|
"openai>=1.0.0",
|
|
# PDF parsing dependencies - essential for document processing
|
|
"PyPDF2>=3.0.0",
|
|
"pdfplumber>=0.11.0",
|
|
"pymupdf>=1.26.0",
|
|
"pypdfium2>=4.30.0",
|
|
# LlamaIndex core and readers - updated versions
|
|
"llama-index>=0.12.44",
|
|
"llama-index-readers-file>=0.4.0", # Essential for PDF parsing
|
|
# "llama-index-readers-docling", # Requires Python >= 3.10
|
|
# "llama-index-node-parser-docling", # Requires Python >= 3.10
|
|
"llama-index-vector-stores-faiss>=0.4.0",
|
|
"llama-index-embeddings-huggingface>=0.5.5",
|
|
# Other dependencies
|
|
"ipykernel==6.29.5",
|
|
"msgpack>=1.1.1",
|
|
"mlx>=0.26.3; sys_platform == 'darwin'",
|
|
"mlx-lm>=0.26.0; sys_platform == 'darwin'",
|
|
"psutil>=5.8.0",
|
|
]
|
|
|
|
[project.optional-dependencies]
|
|
dev = [
|
|
"pytest>=7.0",
|
|
"pytest-cov>=4.0",
|
|
"pytest-xdist>=3.0", # For parallel test execution
|
|
"black>=23.0",
|
|
"ruff>=0.1.0",
|
|
"matplotlib",
|
|
"huggingface-hub>=0.20.0",
|
|
"pre-commit>=3.5.0",
|
|
]
|
|
|
|
test = [
|
|
"pytest>=7.0",
|
|
"pytest-timeout>=2.0",
|
|
"llama-index-core>=0.12.0",
|
|
"llama-index-readers-file>=0.4.0",
|
|
"python-dotenv>=1.0.0",
|
|
"sentence-transformers>=2.2.0",
|
|
]
|
|
|
|
diskann = [
|
|
"leann-backend-diskann",
|
|
]
|
|
|
|
# Add a new optional dependency group for document processing
|
|
documents = [
|
|
"beautifulsoup4>=4.13.0", # For HTML parsing
|
|
"python-docx>=0.8.11", # For Word documents
|
|
"openpyxl>=3.1.0", # For Excel files
|
|
"pandas>=2.2.0", # For data processing
|
|
]
|
|
|
|
[tool.setuptools]
|
|
py-modules = []
|
|
|
|
|
|
[tool.uv.sources]
|
|
leann-core = { path = "packages/leann-core", editable = true }
|
|
leann-backend-diskann = { path = "packages/leann-backend-diskann", editable = true }
|
|
leann-backend-hnsw = { path = "packages/leann-backend-hnsw", editable = true }
|
|
|
|
[tool.ruff]
|
|
target-version = "py310"
|
|
line-length = 100
|
|
extend-exclude = [
|
|
"third_party",
|
|
"*.egg-info",
|
|
"__pycache__",
|
|
".git",
|
|
".venv",
|
|
]
|
|
|
|
[tool.ruff.lint]
|
|
select = [
|
|
"E", # pycodestyle errors
|
|
"W", # pycodestyle warnings
|
|
"F", # pyflakes
|
|
"I", # isort
|
|
"B", # flake8-bugbear
|
|
"C4", # flake8-comprehensions
|
|
"UP", # pyupgrade
|
|
"N", # pep8-naming
|
|
"RUF", # ruff-specific rules
|
|
]
|
|
ignore = [
|
|
"E501", # line too long (handled by formatter)
|
|
"B008", # do not perform function calls in argument defaults
|
|
"B904", # raise without from
|
|
"N812", # lowercase imported as non-lowercase
|
|
"N806", # variable in function should be lowercase
|
|
"RUF012", # mutable class attributes should be annotated with typing.ClassVar
|
|
]
|
|
|
|
[tool.ruff.lint.per-file-ignores]
|
|
"test/**/*.py" = ["E402"] # module level import not at top of file (common in tests)
|
|
"examples/**/*.py" = ["E402"] # module level import not at top of file (common in examples)
|
|
|
|
[tool.ruff.format]
|
|
quote-style = "double"
|
|
indent-style = "space"
|
|
skip-magic-trailing-comma = false
|
|
line-ending = "auto"
|
|
|
|
[dependency-groups]
|
|
dev = [
|
|
"ruff>=0.12.4",
|
|
]
|
|
|
|
[tool.lychee]
|
|
accept = ["200", "403", "429", "503"]
|
|
timeout = 20
|
|
max_retries = 2
|
|
exclude = ["localhost", "127.0.0.1", "example.com"]
|
|
exclude_path = [".git/", ".venv/", "__pycache__/", "third_party/"]
|
|
scheme = ["https", "http"]
|
|
|
|
[tool.pytest.ini_options]
|
|
testpaths = ["tests"]
|
|
python_files = ["test_*.py"]
|
|
python_classes = ["Test*"]
|
|
python_functions = ["test_*"]
|
|
markers = [
|
|
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
|
|
"openai: marks tests that require OpenAI API key",
|
|
]
|
|
timeout = 600
|
|
addopts = [
|
|
"-v",
|
|
"--tb=short",
|
|
"--strict-markers",
|
|
"--disable-warnings",
|
|
]
|
|
env = [
|
|
"HF_HUB_DISABLE_SYMLINKS=1",
|
|
"TOKENIZERS_PARALLELISM=false",
|
|
]
|