{"id":50288655,"url":"https://github.com/hherb/bmlib","last_synced_at":"2026-05-28T04:04:19.223Z","repository":{"id":338135189,"uuid":"1156690606","full_name":"hherb/bmlib","owner":"hherb","description":"Shared Python library for biomedical literature tools — LLM abstraction, quality assessment, transparency analysis, full-text retrieval, publication ingestion, and database utilities.","archived":false,"fork":false,"pushed_at":"2026-04-05T12:20:50.000Z","size":331,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-05T14:21:28.774Z","etag":null,"topics":["biomedical","europepmc","fulltext","library","medical","medrxiv","pubmed","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hherb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-12T23:57:57.000Z","updated_at":"2026-04-05T12:20:53.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/hherb/bmlib","commit_stats":null,"previous_names":["hherb/bmlib"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hherb/bmlib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hherb%2Fbmlib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hherb%2Fbmlib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hherb%2Fbmlib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hherb%2Fbmlib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hherb","download_url":"https://codeload.github.com/hherb/bmlib/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hherb%2Fbmlib/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33593419,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-28T02:00:06.440Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["biomedical","europepmc","fulltext","library","medical","medrxiv","pubmed","python"],"created_at":"2026-05-28T04:04:12.926Z","updated_at":"2026-05-28T04:04:19.209Z","avatar_url":"https://github.com/hherb.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bmlib\n\nShared Python library for biomedical literature tools — LLM abstraction, quality assessment, transparency analysis, full-text retrieval, publication ingestion, and database utilities.\n\n**Version:** 0.2.1 | **License:** AGPL-3.0-or-later | **Python:** \u003e=3.11\n\n## Installation\n\n```bash\n# Core (only jinja2 dependency)\npip install bmlib\n\n# Editable install with all extras\nuv pip install -e \".[all]\"\n```\n\n### Optional dependency groups\n\n| Group | Install command | Provides |\n|-------|----------------|----------|\n| `anthropic` | `pip install bmlib[anthropic]` | Anthropic Claude LLM provider |\n| `ollama` | `pip install bmlib[ollama]` | Ollama local LLM provider |\n| `openai` | `pip install bmlib[openai]` | OpenAI, DeepSeek, Mistral, Gemini, and OpenAI-compatible providers |\n| `postgresql` | `pip install bmlib[postgresql]` | PostgreSQL database backend |\n| `transparency` | `pip install bmlib[transparency]` | Transparency analysis (httpx) |\n| `publications` | `pip install bmlib[publications]` | Publication ingestion and sync (httpx) |\n| `dev` | `pip install bmlib[dev]` | pytest, pytest-cov, ruff |\n| `all` | `pip install bmlib[all]` | All of the above |\n\n## Modules\n\n| Module | Description |\n|--------|-------------|\n| **bmlib.db** | Thin database abstraction (SQLite + PostgreSQL) with pure functions over DB-API connections |\n| **bmlib.llm** | Unified LLM client with pluggable providers (Anthropic, OpenAI, Ollama, DeepSeek, Mistral, Gemini) |\n| **bmlib.templates** | Jinja2-based prompt template engine with user-override directory fallback |\n| **bmlib.agents** | Base agent class for LLM-driven tasks with template rendering and JSON parsing |\n| **bmlib.quality** | 3-tier quality assessment pipeline for biomedical publications (metadata → LLM classifier → deep assessment) |\n| **bmlib.transparency** | Multi-API transparency and bias analysis (PubMed, CrossRef, EuropePMC, OpenAlex, ClinicalTrials.gov) |\n| **bmlib.publications** | Publication ingestion from PubMed, bioRxiv, medRxiv, and OpenAlex with deduplication and sync |\n| **bmlib.fulltext** | Full-text retrieval (Europe PMC → Unpaywall → DOI), JATS XML parsing, and disk-based caching |\n\n## Quick Start\n\n### Database\n\n```python\nfrom bmlib.db import connect_sqlite, execute, fetch_all, transaction\n\nconn = connect_sqlite(\"~/.myapp/data.db\")\nwith transaction(conn):\n    execute(conn, \"INSERT INTO papers (doi, title) VALUES (?, ?)\", (\"10.1101/x\", \"A paper\"))\nrows = fetch_all(conn, \"SELECT * FROM papers\")\n```\n\n### LLM\n\n```python\nfrom bmlib.llm import LLMClient, LLMMessage\n\nclient = LLMClient(default_provider=\"ollama\")\nresponse = client.chat(\n    messages=[LLMMessage(role=\"user\", content=\"Summarise this paper.\")],\n    model=\"ollama:medgemma4B_it_q8\",\n)\nprint(response.content)\n```\n\nModel strings use the format `\"provider:model_name\"`:\n\n```\n\"anthropic:claude-sonnet-4-20250514\"\n\"openai:gpt-4o\"\n\"ollama:medgemma4B_it_q8\"\n\"deepseek:deepseek-chat\"\n\"mistral:mistral-large-latest\"\n\"gemini:gemini-2.0-flash\"\n```\n\n### Publication Sync\n\n```python\nfrom datetime import date\nfrom bmlib.db import connect_sqlite\nfrom bmlib.publications import sync\n\nconn = connect_sqlite(\"publications.db\")\nreport = sync(\n    conn,\n    sources=[\"pubmed\", \"biorxiv\"],\n    date_from=date(2025, 1, 1),\n    date_to=date(2025, 1, 7),\n    email=\"researcher@example.com\",\n)\nprint(f\"Added: {report.records_added}, Merged: {report.records_merged}\")\n```\n\n### Full-Text Retrieval\n\n```python\nfrom bmlib.fulltext import FullTextService, FullTextCache\n\nservice = FullTextService(email=\"researcher@example.com\")\nresult = service.fetch_fulltext(pmc_id=\"PMC7614751\", doi=\"10.1234/example\")\n\nif result.source == \"europepmc\" and result.html:\n    cache = FullTextCache()  # uses platform default directory\n    cache.save_html(result.html, \"PMC7614751\")\n```\n\n### Quality Assessment\n\n```python\nfrom bmlib.llm import LLMClient\nfrom bmlib.quality import QualityManager\n\nllm = LLMClient()\nmanager = QualityManager(\n    llm=llm,\n    classifier_model=\"anthropic:claude-3-haiku-20240307\",\n    assessor_model=\"anthropic:claude-sonnet-4-20250514\",\n)\n\nassessment = manager.assess(\n    title=\"A Randomized Controlled Trial of ...\",\n    abstract=\"We conducted a double-blind RCT ...\",\n    publication_types=[\"Randomized Controlled Trial\"],\n)\nprint(assessment.study_design, assessment.quality_tier)\n```\n\n### Transparency Analysis\n\n```python\nfrom bmlib.transparency import TransparencyAnalyzer\n\nanalyzer = TransparencyAnalyzer(email=\"researcher@example.com\")\nresult = analyzer.analyze(\"doc-001\", doi=\"10.1038/s41586-024-00001-0\")\nprint(result.transparency_score, result.risk_level)\n```\n\n## Development\n\n```bash\n# Install with dev dependencies\nuv pip install -e \".[all]\"\n\n# Run tests\npytest tests/ -v\n\n# Lint and format\nruff check .\nruff format --check .\n```\n\n## Documentation\n\nFull API documentation is available in [docs/manual/](docs/manual/index.md).\n\n## License\n\nAGPL-3.0-or-later\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhherb%2Fbmlib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhherb%2Fbmlib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhherb%2Fbmlib/lists"}