bmlibrarian-lite 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bmlibrarian_lite-0.1.0/.gitignore +89 -0
- bmlibrarian_lite-0.1.0/CLAUDE.md +175 -0
- bmlibrarian_lite-0.1.0/LICENSE +21 -0
- bmlibrarian_lite-0.1.0/PKG-INFO +288 -0
- bmlibrarian_lite-0.1.0/README.md +245 -0
- bmlibrarian_lite-0.1.0/bmll.py +352 -0
- bmlibrarian_lite-0.1.0/doc/developer/guide.md +502 -0
- bmlibrarian_lite-0.1.0/doc/llm/context.md +305 -0
- bmlibrarian_lite-0.1.0/doc/llm/database-schema.md +298 -0
- bmlibrarian_lite-0.1.0/doc/llm/golden_rules.md +19 -0
- bmlibrarian_lite-0.1.0/doc/planning/multi-provider-models/PLAN_MULTI_PROVIDER_MODELS.md +861 -0
- bmlibrarian_lite-0.1.0/doc/planning/provider-abstraction/PLAN_PROVIDER_ABSTRACTION.md +867 -0
- bmlibrarian_lite-0.1.0/doc/user/guide.md +277 -0
- bmlibrarian_lite-0.1.0/pyproject.toml +121 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/__init__.py +83 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/__main__.py +8 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/agents/__init__.py +57 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/agents/base.py +183 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/agents/citation_agent.py +247 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/agents/interrogation_agent.py +428 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/agents/reporting_agent.py +292 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/agents/scoring_agent.py +223 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/agents/search_agent.py +353 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/chroma_embeddings.py +169 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/chunking.py +306 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/cli.py +346 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/config.py +754 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/constants.py +590 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/conversation_export.py +200 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/data_models.py +353 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/embeddings.py +231 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/europepmc.py +545 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/exceptions.py +208 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/fulltext_discovery.py +412 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/gui/__init__.py +68 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/gui/app.py +391 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/gui/audit_citations_tab.py +340 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/gui/audit_literature_tab.py +340 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/gui/audit_queries_tab.py +333 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/gui/audit_trail_tab.py +322 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/gui/card_utils.py +283 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/gui/chat_widgets.py +299 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/gui/citation_loader.py +123 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/gui/dialogs.py +492 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/gui/document_card.py +592 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/gui/document_interrogation_tab.py +963 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/gui/document_viewer.py +395 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/gui/quality_badge.py +260 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/gui/quality_filter_panel.py +525 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/gui/quality_summary.py +278 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/gui/report_tab.py +690 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/gui/settings_dialog.py +967 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/gui/systematic_review_tab.py +611 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/gui/text_highlighting.py +255 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/gui/workers.py +452 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/llm/__init__.py +31 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/llm/client.py +321 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/llm/data_types.py +130 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/llm/providers/__init__.py +159 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/llm/providers/anthropic.py +352 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/llm/providers/base.py +284 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/llm/providers/ollama.py +359 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/llm/token_tracker.py +200 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/pdf_discovery.py +1052 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/pdf_utils.py +532 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/pubmed/__init__.py +57 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/pubmed/constants.py +100 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/pubmed/data_types.py +450 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/pubmed/search_client.py +767 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/quality/__init__.py +105 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/quality/data_models.py +593 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/quality/evidence_summary.py +323 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/quality/metadata_filter.py +310 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/quality/quality_agent.py +322 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/quality/quality_manager.py +281 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/quality/report_formatter.py +272 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/quality/study_classifier.py +703 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/query_converter.py +276 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/resources/__init__.py +5 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/resources/styles/__init__.py +85 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/resources/styles/dpi_scale.py +238 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/resources/styles/stylesheet_generator.py +515 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/resources/styles/theme_colors.py +219 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/resources/styles/theme_generator.py +598 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/storage.py +1085 -0
- bmlibrarian_lite-0.1.0/src/bmlibrarian_lite/utils.py +687 -0
- bmlibrarian_lite-0.1.0/tests/__init__.py +1 -0
- bmlibrarian_lite-0.1.0/tests/conftest.py +137 -0
- bmlibrarian_lite-0.1.0/tests/test_audit_trail_tab.py +374 -0
- bmlibrarian_lite-0.1.0/tests/test_card_utils.py +284 -0
- bmlibrarian_lite-0.1.0/tests/test_document_card.py +253 -0
- bmlibrarian_lite-0.1.0/tests/test_europepmc.py +382 -0
- bmlibrarian_lite-0.1.0/tests/test_fulltext_discovery.py +302 -0
- bmlibrarian_lite-0.1.0/tests/test_pdf_utils_fulltext.py +226 -0
- bmlibrarian_lite-0.1.0/uv.lock +2419 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
.Python
|
|
7
|
+
build/
|
|
8
|
+
develop-eggs/
|
|
9
|
+
dist/
|
|
10
|
+
downloads/
|
|
11
|
+
eggs/
|
|
12
|
+
.eggs/
|
|
13
|
+
lib/
|
|
14
|
+
lib64/
|
|
15
|
+
parts/
|
|
16
|
+
sdist/
|
|
17
|
+
var/
|
|
18
|
+
wheels/
|
|
19
|
+
*.egg-info/
|
|
20
|
+
.installed.cfg
|
|
21
|
+
*.egg
|
|
22
|
+
|
|
23
|
+
# Virtual environments
|
|
24
|
+
.venv/
|
|
25
|
+
venv/
|
|
26
|
+
ENV/
|
|
27
|
+
env/
|
|
28
|
+
|
|
29
|
+
# IDE
|
|
30
|
+
.idea/
|
|
31
|
+
.vscode/
|
|
32
|
+
*.swp
|
|
33
|
+
*.swo
|
|
34
|
+
*~
|
|
35
|
+
.project
|
|
36
|
+
.pydevproject
|
|
37
|
+
.settings/
|
|
38
|
+
|
|
39
|
+
# Testing
|
|
40
|
+
.tox/
|
|
41
|
+
.coverage
|
|
42
|
+
.coverage.*
|
|
43
|
+
htmlcov/
|
|
44
|
+
.pytest_cache/
|
|
45
|
+
.mypy_cache/
|
|
46
|
+
|
|
47
|
+
# Jupyter
|
|
48
|
+
.ipynb_checkpoints/
|
|
49
|
+
|
|
50
|
+
# Data directories
|
|
51
|
+
data/
|
|
52
|
+
*.db
|
|
53
|
+
*.sqlite
|
|
54
|
+
*.sqlite3
|
|
55
|
+
|
|
56
|
+
# ChromaDB
|
|
57
|
+
chroma/
|
|
58
|
+
.chroma/
|
|
59
|
+
|
|
60
|
+
# User data
|
|
61
|
+
~/.bmlibrarian_lite/
|
|
62
|
+
|
|
63
|
+
# Logs
|
|
64
|
+
*.log
|
|
65
|
+
logs/
|
|
66
|
+
|
|
67
|
+
# OS
|
|
68
|
+
.DS_Store
|
|
69
|
+
Thumbs.db
|
|
70
|
+
|
|
71
|
+
# Environment
|
|
72
|
+
.env
|
|
73
|
+
.env.local
|
|
74
|
+
*.env
|
|
75
|
+
|
|
76
|
+
# Secrets
|
|
77
|
+
secrets/
|
|
78
|
+
*.pem
|
|
79
|
+
*.key
|
|
80
|
+
|
|
81
|
+
# Temporary files
|
|
82
|
+
tmp/
|
|
83
|
+
temp/
|
|
84
|
+
*.tmp
|
|
85
|
+
*.temp
|
|
86
|
+
|
|
87
|
+
# Lock files (keep uv.lock if using uv)
|
|
88
|
+
# uv.lock
|
|
89
|
+
.claude/settings.local.json
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Project Overview
|
|
6
|
+
|
|
7
|
+
BMLibrarian Lite is a lightweight biomedical literature research tool that provides AI-powered systematic review and document interrogation capabilities. It uses ChromaDB + SQLite for storage (no PostgreSQL), FastEmbed for CPU-optimized embeddings, and supports Anthropic Claude or Ollama for LLM inference.
|
|
8
|
+
|
|
9
|
+
## Common Commands
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# Create virtual environment and install with uv
|
|
13
|
+
uv venv
|
|
14
|
+
source .venv/bin/activate
|
|
15
|
+
uv pip install -e ".[dev]"
|
|
16
|
+
|
|
17
|
+
# Run the GUI (default)
|
|
18
|
+
python bmlibrarian_lite.py
|
|
19
|
+
|
|
20
|
+
# Run tests
|
|
21
|
+
pytest
|
|
22
|
+
|
|
23
|
+
# Run a single test file
|
|
24
|
+
pytest tests/test_foo.py
|
|
25
|
+
|
|
26
|
+
# Run a specific test
|
|
27
|
+
pytest tests/test_foo.py::test_function_name
|
|
28
|
+
|
|
29
|
+
# Run linting
|
|
30
|
+
ruff check .
|
|
31
|
+
|
|
32
|
+
# Run type checking
|
|
33
|
+
mypy src/
|
|
34
|
+
|
|
35
|
+
# CLI commands
|
|
36
|
+
python bmlibrarian_lite.py stats # Storage statistics
|
|
37
|
+
python bmlibrarian_lite.py validate # Validate configuration
|
|
38
|
+
python bmlibrarian_lite.py config # Show configuration
|
|
39
|
+
python bmlibrarian_lite.py clear # Clear all data
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Code Style Requirements
|
|
43
|
+
|
|
44
|
+
- **Docstrings are mandatory**: Use Google-style docstrings on all public functions, classes, and methods
|
|
45
|
+
- **Type hints are mandatory**: All function parameters and return types must be annotated
|
|
46
|
+
- **No magic numbers**: Always use named constants or configuration values; never hardcode numbers
|
|
47
|
+
- **Prefer pure functions**: Write small, reusable pure functions in focused modules over complex long files
|
|
48
|
+
- **Constants go in `constants.py`**: Centralize numeric and string constants
|
|
49
|
+
- **No inline stylesheets**: All stylesheets via the centralised styling system
|
|
50
|
+
- **No hardcoded pixel values**: Use `scaled()` from `dpi_scale.py` for DPI-aware dimensions
|
|
51
|
+
|
|
52
|
+
## Architecture
|
|
53
|
+
|
|
54
|
+
### Entry Points
|
|
55
|
+
- `bmlibrarian_lite.py` - CLI entry point with subcommands (gui, stats, validate, config, clear)
|
|
56
|
+
- `src/bmlibrarian_lite/gui/app.py` - PySide6 main window with tabbed interface
|
|
57
|
+
|
|
58
|
+
### Core Layers
|
|
59
|
+
|
|
60
|
+
**Configuration & Storage** (`config.py`, `storage.py`)
|
|
61
|
+
- `LiteConfig` - Dataclass-based configuration with JSON persistence in `~/.bmlibrarian_lite/`
|
|
62
|
+
- `LiteStorage` - Manages ChromaDB collections and SQLite metadata
|
|
63
|
+
|
|
64
|
+
**LLM Integration** (`llm/`)
|
|
65
|
+
- `LLMClient` - Unified client supporting both Anthropic and Ollama providers
|
|
66
|
+
- Model strings use format: `provider:model` (e.g., `anthropic:claude-sonnet-4-20250514`, `ollama:llama3.2`)
|
|
67
|
+
|
|
68
|
+
**Agent System** (`agents/`)
|
|
69
|
+
- `LiteBaseAgent` - Base class providing LLM communication via `_chat()` method
|
|
70
|
+
- Specialized agents: `SearchAgent`, `ScoringAgent`, `CitationAgent`, `ReportingAgent`, `InterrogationAgent`
|
|
71
|
+
- Agents inherit config and share LLM client instance
|
|
72
|
+
|
|
73
|
+
**PubMed Integration** (`pubmed/`)
|
|
74
|
+
- `PubMedSearchClient` - Wrapper around NCBI E-utilities API
|
|
75
|
+
- Converts natural language to PubMed queries
|
|
76
|
+
- Europe PMC full-text XML retrieval support
|
|
77
|
+
|
|
78
|
+
**PDF Discovery** (`pdf_discovery.py`)
|
|
79
|
+
- `PDFDiscoverer` - Finds and downloads PDFs from PubMed Central, Unpaywall, and DOI resolution
|
|
80
|
+
|
|
81
|
+
**Quality Assessment** (`quality/`)
|
|
82
|
+
- Study classification, evidence grading, and quality scoring
|
|
83
|
+
- `QualityManager` orchestrates the assessment workflow
|
|
84
|
+
- `QualityAssessment` dataclass with study design, quality tier, and extraction details
|
|
85
|
+
|
|
86
|
+
### GUI Structure (`gui/`)
|
|
87
|
+
|
|
88
|
+
The PySide6 GUI uses a three-tab design:
|
|
89
|
+
- `SystematicReviewTab` - Search PubMed, score documents, extract citations, generate reports
|
|
90
|
+
- `DocumentInterrogationTab` - Load documents and perform Q&A
|
|
91
|
+
- `AuditTrailTab` - Real-time workflow visibility (NEW)
|
|
92
|
+
|
|
93
|
+
#### Audit Trail Tab (NEW)
|
|
94
|
+
|
|
95
|
+
The Audit Trail provides transparency into the systematic review workflow with three sub-tabs:
|
|
96
|
+
|
|
97
|
+
- **Queries Tab** (`audit_queries_tab.py`): Displays generated PubMed queries with statistics (docs found, scored, citations extracted)
|
|
98
|
+
- **Literature Tab** (`audit_literature_tab.py`): Scrollable document cards with relevance scores and quality badges
|
|
99
|
+
- **Citations Tab** (`audit_citations_tab.py`): Document cards with highlighted citation passages
|
|
100
|
+
|
|
101
|
+
**Document Cards** (`document_card.py`):
|
|
102
|
+
- Collapsible cards - click to expand and show abstract
|
|
103
|
+
- Quality badges (RCT, SR, etc.) with color-coded study design
|
|
104
|
+
- Score badges (1-5) with color gradients
|
|
105
|
+
- LLM rationale display for scoring and quality decisions
|
|
106
|
+
- Right-click context menu to send documents to interrogator
|
|
107
|
+
- Pale blue header background for visual distinction
|
|
108
|
+
|
|
109
|
+
**Key Audit Trail Signals:**
|
|
110
|
+
- `workflow_started` - Clears previous audit data
|
|
111
|
+
- `query_generated(str)` - New PubMed query generated
|
|
112
|
+
- `documents_found(list[LiteDocument])` - Documents retrieved
|
|
113
|
+
- `document_scored(ScoredDocument)` - Relevance score assigned
|
|
114
|
+
- `quality_assessed(str, QualityAssessment)` - Quality assessment complete
|
|
115
|
+
- `citation_extracted(Citation)` - Citation passage extracted
|
|
116
|
+
|
|
117
|
+
Background operations use `QThread` workers in `workers.py` to keep the UI responsive.
|
|
118
|
+
|
|
119
|
+
### Data Flow
|
|
120
|
+
|
|
121
|
+
1. User enters research question → `SearchAgent` converts to PubMed query
|
|
122
|
+
2. `PubMedSearchClient` fetches articles → stored in `LiteStorage`
|
|
123
|
+
3. `LiteEmbedder` (FastEmbed) creates embeddings → stored in ChromaDB
|
|
124
|
+
4. `QualityManager` assesses study quality (optional)
|
|
125
|
+
5. `ScoringAgent` scores relevance → `CitationAgent` extracts citations
|
|
126
|
+
6. `ReportingAgent` generates final report
|
|
127
|
+
7. Audit Trail tab displays real-time progress throughout
|
|
128
|
+
|
|
129
|
+
## Key Patterns
|
|
130
|
+
|
|
131
|
+
- **Lazy initialization**: LLM clients and embedders are created on first use
|
|
132
|
+
- **Qt signals/slots**: GUI components communicate via Qt signal system
|
|
133
|
+
- **Dataclasses throughout**: `LiteDocument`, `LiteChunk`, `SearchSession`, etc.
|
|
134
|
+
- **Thread-safe updates**: Use `threading.RLock()` for concurrent access
|
|
135
|
+
- **DPI scaling**: Use `scaled()` function for all pixel dimensions
|
|
136
|
+
|
|
137
|
+
## Constants (from `constants.py`)
|
|
138
|
+
|
|
139
|
+
Key audit trail constants:
|
|
140
|
+
- `AUDIT_CARD_PADDING`, `AUDIT_CARD_SPACING` - Card layout dimensions
|
|
141
|
+
- `AUDIT_CARD_BORDER_RADIUS`, `AUDIT_CARD_MIN_HEIGHT` - Card styling
|
|
142
|
+
- `AUDIT_CARD_HEADER_COLOR` - Pale light blue header (`#E3F2FD`)
|
|
143
|
+
- `AUDIT_RATIONALE_COLOR` - Muted text for LLM rationales (`#555555`)
|
|
144
|
+
- `AUDIT_ABSTRACT_MAX_LINES` - Maximum abstract lines before scroll (15)
|
|
145
|
+
- `MAX_AUTHORS_BEFORE_ET_AL` - Authors to show before "et al." (3)
|
|
146
|
+
|
|
147
|
+
## Environment Variables
|
|
148
|
+
|
|
149
|
+
- `ANTHROPIC_API_KEY` - Required for Claude API
|
|
150
|
+
- `OLLAMA_HOST` - Ollama server URL (default: http://localhost:11434)
|
|
151
|
+
- `NCBI_EMAIL` - Recommended for PubMed API
|
|
152
|
+
- `TOKENIZERS_PARALLELISM=false` - Set automatically to avoid HuggingFace warnings
|
|
153
|
+
|
|
154
|
+
## Documentation Structure
|
|
155
|
+
|
|
156
|
+
```
|
|
157
|
+
doc/
|
|
158
|
+
├── user/ # End-user documentation
|
|
159
|
+
│ └── guide.md # User guide
|
|
160
|
+
├── developer/ # Developer documentation
|
|
161
|
+
│ └── guide.md # Developer guide
|
|
162
|
+
├── llm/ # LLM assistant context
|
|
163
|
+
│ ├── context.md # General LLM context
|
|
164
|
+
│ ├── database-schema.md # Database schema reference
|
|
165
|
+
│ └── golden_rules.md # Coding standards
|
|
166
|
+
└── planning/ # Planning documents
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## Related Documentation
|
|
170
|
+
|
|
171
|
+
- `doc/llm/golden_rules.md` - MUST READ: Coding standards and rules
|
|
172
|
+
- `doc/llm/database-schema.md` - Database schema reference
|
|
173
|
+
- `doc/llm/context.md` - Extended LLM context
|
|
174
|
+
- `doc/developer/guide.md` - Developer guide
|
|
175
|
+
- `doc/user/guide.md` - User guide
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Horst Herb
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: bmlibrarian-lite
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Lightweight biomedical literature research tool - no PostgreSQL required
|
|
5
|
+
Project-URL: Homepage, https://github.com/hherb/bmlibrarian-lite
|
|
6
|
+
Project-URL: Documentation, https://github.com/hherb/bmlibrarian-lite#readme
|
|
7
|
+
Project-URL: Repository, https://github.com/hherb/bmlibrarian-lite.git
|
|
8
|
+
Project-URL: Issues, https://github.com/hherb/bmlibrarian-lite/issues
|
|
9
|
+
Author-email: Horst Herb <bmlibrarian@proton.me>
|
|
10
|
+
License: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: ai,biomedical,literature,llm,pubmed,research,systematic-review
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Healthcare Industry
|
|
15
|
+
Classifier: Intended Audience :: Science/Research
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
|
|
23
|
+
Requires-Python: >=3.12
|
|
24
|
+
Requires-Dist: anthropic>=0.34.0
|
|
25
|
+
Requires-Dist: backoff>=2.2.1
|
|
26
|
+
Requires-Dist: chromadb>=0.5.0
|
|
27
|
+
Requires-Dist: fastembed>=0.3.0
|
|
28
|
+
Requires-Dist: markdown>=3.5.0
|
|
29
|
+
Requires-Dist: ollama>=0.3.0
|
|
30
|
+
Requires-Dist: pygments>=2.17.0
|
|
31
|
+
Requires-Dist: pymupdf>=1.23.0
|
|
32
|
+
Requires-Dist: pysbd>=0.3.4
|
|
33
|
+
Requires-Dist: pyside6>=6.6.0
|
|
34
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
35
|
+
Requires-Dist: requests>=2.31.0
|
|
36
|
+
Requires-Dist: tokenizers>=0.19.0
|
|
37
|
+
Provides-Extra: dev
|
|
38
|
+
Requires-Dist: mypy>=1.9.0; extra == 'dev'
|
|
39
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == 'dev'
|
|
40
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
41
|
+
Requires-Dist: ruff>=0.4.0; extra == 'dev'
|
|
42
|
+
Description-Content-Type: text/markdown
|
|
43
|
+
|
|
44
|
+
# BMLibrarian Lite
|
|
45
|
+
|
|
46
|
+
A lightweight biomedical literature research tool - no PostgreSQL required.
|
|
47
|
+
|
|
48
|
+
BMLibrarian Lite is a simplified version of BMLibrarian that provides AI-powered literature search and analysis capabilities without requiring a PostgreSQL database. It uses only the PubMed E-utilities API for searching and fetching article metadata instead of a local database. It uses ChromaDB for vector storage and SQLite for metadata, making it easy to install and use on any machine. Also, in order to allow it to run on computers with limited resources, it uses FastEmbed for local embeddings and allows to use cloud LLM providers like Anthropic Claude instead of relying exclusively on local inference.
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
## Features
|
|
52
|
+
|
|
53
|
+
- **Systematic Literature Review**: Search PubMed, score documents, extract citations, and generate reports
|
|
54
|
+
- **Document Interrogation**: Interactive Q&A with loaded documents
|
|
55
|
+
- **PDF Discovery & Download**: Automatic PDF retrieval from PubMed Central, Unpaywall, and DOI resolution
|
|
56
|
+
- **Quality Assessment**: Automated study quality evaluation with evidence grading
|
|
57
|
+
- **Audit Trail**: Real-time visibility into the review workflow with LLM reasoning transparency
|
|
58
|
+
- **Multiple LLM Providers**: Support for both Anthropic Claude (online) and Ollama (local)
|
|
59
|
+
- **Embedded Storage**: ChromaDB + SQLite - no external database needed
|
|
60
|
+
- **Cross-Platform GUI**: PySide6-based desktop application
|
|
61
|
+
|
|
62
|
+
## Quick Start
|
|
63
|
+
|
|
64
|
+
### Installation
|
|
65
|
+
|
|
66
|
+
**From PyPI (recommended):**
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
pip install bmlibrarian-lite
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**From source:**
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
# Clone the repository
|
|
76
|
+
git clone https://github.com/hherb/bmlibrarian-lite.git
|
|
77
|
+
cd bmlibrarian-lite
|
|
78
|
+
|
|
79
|
+
# Create virtual environment and install
|
|
80
|
+
python -m venv .venv
|
|
81
|
+
source .venv/bin/activate # On Windows: .venv\Scripts\activate
|
|
82
|
+
pip install -e .
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Configuration
|
|
86
|
+
|
|
87
|
+
1. **Set your Anthropic API key** (for Claude):
|
|
88
|
+
```bash
|
|
89
|
+
export ANTHROPIC_API_KEY="your-api-key-here"
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
2. **Or configure Ollama** (for local models):
|
|
93
|
+
```bash
|
|
94
|
+
# Install Ollama: https://ollama.ai
|
|
95
|
+
ollama pull llama3.2
|
|
96
|
+
export OLLAMA_HOST="http://localhost:11434"
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
3. **Optional: Set your email for PubMed** (recommended):
|
|
100
|
+
```bash
|
|
101
|
+
export NCBI_EMAIL="your@email.com"
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
4. **Optional: Configure PDF Discovery** (for Unpaywall API):
|
|
105
|
+
- Go to Settings in the GUI
|
|
106
|
+
- Enter your email address for Unpaywall API access
|
|
107
|
+
- Configure OpenAthens if you have institutional access
|
|
108
|
+
|
|
109
|
+
### Running the Application
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
# Launch the GUI (short command)
|
|
113
|
+
bmll
|
|
114
|
+
|
|
115
|
+
# Or using the full name
|
|
116
|
+
bmlibrarian-lite
|
|
117
|
+
|
|
118
|
+
# Or using Python module
|
|
119
|
+
python -m bmlibrarian_lite
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### CLI Commands
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
# Show storage statistics
|
|
126
|
+
bmll stats
|
|
127
|
+
|
|
128
|
+
# Validate configuration
|
|
129
|
+
bmll validate --verbose
|
|
130
|
+
|
|
131
|
+
# Show current configuration
|
|
132
|
+
bmll config
|
|
133
|
+
|
|
134
|
+
# Clear all data
|
|
135
|
+
bmll clear
|
|
136
|
+
|
|
137
|
+
# Show version
|
|
138
|
+
bmll --version
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Usage
|
|
142
|
+
|
|
143
|
+
### Systematic Review Workflow
|
|
144
|
+
|
|
145
|
+
1. **Enter your research question** in the main text area
|
|
146
|
+
2. **Click "Search"** to query PubMed
|
|
147
|
+
3. **Review found articles** and adjust filters as needed
|
|
148
|
+
4. **Score documents** for relevance (1-5 scale)
|
|
149
|
+
5. **Extract citations** from high-scoring documents
|
|
150
|
+
6. **Generate a report** synthesizing the evidence
|
|
151
|
+
|
|
152
|
+
### Audit Trail
|
|
153
|
+
|
|
154
|
+
The Audit Trail tab provides real-time visibility into the systematic review workflow:
|
|
155
|
+
|
|
156
|
+
- **Queries Tab**: View generated PubMed queries and search statistics
|
|
157
|
+
- **Literature Tab**: Browse document cards with relevance scores and quality badges
|
|
158
|
+
- Click cards to expand and view abstracts
|
|
159
|
+
- See LLM rationales for scoring and quality decisions
|
|
160
|
+
- Quality badges show study design (RCT, Systematic Review, etc.)
|
|
161
|
+
- **Citations Tab**: View extracted citation passages with highlighting
|
|
162
|
+
|
|
163
|
+
Right-click any document card to send it to the Document Interrogator for deeper analysis.
|
|
164
|
+
|
|
165
|
+
### Document Interrogation
|
|
166
|
+
|
|
167
|
+
1. **Switch to the "Document Interrogation" tab**
|
|
168
|
+
2. **Load a document** (PDF, TXT, or MD file)
|
|
169
|
+
3. **Ask questions** about the document content
|
|
170
|
+
4. **Get AI-powered answers** with source references
|
|
171
|
+
|
|
172
|
+
## Configuration
|
|
173
|
+
|
|
174
|
+
Configuration is stored in `~/.bmlibrarian_lite/config.json`:
|
|
175
|
+
|
|
176
|
+
```json
|
|
177
|
+
{
|
|
178
|
+
"llm": {
|
|
179
|
+
"provider": "anthropic",
|
|
180
|
+
"model": "claude-sonnet-4-20250514",
|
|
181
|
+
"temperature": 0.7,
|
|
182
|
+
"max_tokens": 4096
|
|
183
|
+
},
|
|
184
|
+
"embeddings": {
|
|
185
|
+
"model": "BAAI/bge-small-en-v1.5"
|
|
186
|
+
},
|
|
187
|
+
"pubmed": {
|
|
188
|
+
"email": "your@email.com"
|
|
189
|
+
},
|
|
190
|
+
"search": {
|
|
191
|
+
"chunk_size": 512,
|
|
192
|
+
"chunk_overlap": 50,
|
|
193
|
+
"similarity_threshold": 0.7,
|
|
194
|
+
"max_results": 100
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### LLM Providers
|
|
200
|
+
|
|
201
|
+
**Anthropic Claude** (default):
|
|
202
|
+
```json
|
|
203
|
+
{
|
|
204
|
+
"llm": {
|
|
205
|
+
"provider": "anthropic",
|
|
206
|
+
"model": "claude-sonnet-4-20250514"
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
**Ollama** (local):
|
|
212
|
+
```json
|
|
213
|
+
{
|
|
214
|
+
"llm": {
|
|
215
|
+
"provider": "ollama",
|
|
216
|
+
"model": "llama3.2"
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
You can also use the model string format: `anthropic:claude-sonnet-4-20250514` or `ollama:llama3.2`
|
|
222
|
+
|
|
223
|
+
## Requirements
|
|
224
|
+
|
|
225
|
+
- Python 3.12+
|
|
226
|
+
- Internet connection (for PubMed search and Claude API)
|
|
227
|
+
- ~500MB disk space for embeddings cache
|
|
228
|
+
|
|
229
|
+
### Dependencies
|
|
230
|
+
|
|
231
|
+
- **chromadb**: Vector storage
|
|
232
|
+
- **fastembed**: CPU-optimized embeddings
|
|
233
|
+
- **anthropic**: Claude API client
|
|
234
|
+
- **ollama**: Ollama API client
|
|
235
|
+
- **PySide6**: GUI framework
|
|
236
|
+
- **PyMuPDF**: PDF processing
|
|
237
|
+
|
|
238
|
+
## Differences from Full BMLibrarian
|
|
239
|
+
|
|
240
|
+
BMLibrarian Lite is designed for ease of use and portability:
|
|
241
|
+
|
|
242
|
+
| Feature | BMLibrarian | BMLibrarian Lite |
|
|
243
|
+
|---------|-------------|------------------|
|
|
244
|
+
| Database | PostgreSQL + pgvector | ChromaDB + SQLite |
|
|
245
|
+
| Embeddings | Ollama (local) | FastEmbed (CPU) |
|
|
246
|
+
| PDF Discovery | Full (Unpaywall, PMC, OpenAthens) | Included (PMC, Unpaywall, DOI) |
|
|
247
|
+
| Multi-Agent Workflow | Full orchestration | Simplified workflow |
|
|
248
|
+
| Audit Trail | N/A | Real-time workflow visibility |
|
|
249
|
+
| Installation | Complex | Simple `pip install` |
|
|
250
|
+
|
|
251
|
+
## Documentation
|
|
252
|
+
|
|
253
|
+
Documentation is organized into three categories:
|
|
254
|
+
|
|
255
|
+
- **User Documentation** (`doc/user/`): End-user guides and tutorials
|
|
256
|
+
- **Developer Documentation** (`doc/developer/`): Architecture, API, and contribution guides
|
|
257
|
+
- **LLM Context** (`doc/llm/`): Context for AI assistants working with the codebase
|
|
258
|
+
- `golden_rules.md` - Coding standards
|
|
259
|
+
- `database-schema.md` - Database schema reference
|
|
260
|
+
|
|
261
|
+
## Development
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
# Install development dependencies
|
|
265
|
+
pip install -e ".[dev]"
|
|
266
|
+
|
|
267
|
+
# Run tests
|
|
268
|
+
pytest
|
|
269
|
+
|
|
270
|
+
# Run linting
|
|
271
|
+
ruff check .
|
|
272
|
+
|
|
273
|
+
# Run type checking
|
|
274
|
+
mypy src/
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
## License
|
|
278
|
+
|
|
279
|
+
MIT License - see LICENSE file for details.
|
|
280
|
+
|
|
281
|
+
## Acknowledgments
|
|
282
|
+
|
|
283
|
+
BMLibrarian Lite is derived from [BMLibrarian](https://github.com/hherb/bmlibrarian), a comprehensive biomedical literature research platform.
|
|
284
|
+
|
|
285
|
+
## Support
|
|
286
|
+
|
|
287
|
+
- **Issues**: [GitHub Issues](https://github.com/hherb/bmlibrarian-lite/issues)
|
|
288
|
+
- **Documentation**: See the `doc/` directory for detailed guides
|