How biocypher/biochatter works
Project Type and Purpose
• BioChatter is an open-source, full-stack Python library (with optional UIs) designed to connect biomedical applications to conversational AI.
• It provides a generic backend (core “biochatter” package), pluggable LLM connectors, knowledge-graph/RAG support, and a living benchmark suite under “benchmark/”.
File Structure Analysis
• Top-level:
• configuration files (.gitignore, pyproject.toml, Docker Compose)
• benchmark/ – data, notebooks, test harness, results pipelines
• biochatter/ – the core library, subdivided into:
– api_agent/ (web + Python wrappers for external bio-tools)
– llm_connect/ (adapters for OpenAI, Anthropic, Gemini, etc.)
– rag_agent.py, vectorstore_agent.py, query_interaction.py, prompts.py, etc.
• docs/ – MkDocs source for user/developer guides and API reference
• scripts/, test/, .github/workflows – CI, publishing, and utility scripts
• Patterns:
• Modular plugin architecture (each LLM provider in its own module)
• Agent-based services (api_agent, rag_agent, selector_agent)
• Benchmark harness orchestrates loading datasets → calling core API → gathering/processing results
README Insights
• Core features: LLM integration, BioCypher KG connectivity, benchmarking framework, optional extras (xinference, podcast, streamlit).
• Mentions Ecosystem: separate frontends (“BioChatter Light”, “Next.js”), REST API server in other repos.
1. Client Layer
• CLI/scripts (scripts/)
• Optional UIs: Streamlit / BioChatter Light / Next.js
2. Core Library (“biochatter” package)
• QueryInteraction & SelectorAgent
• PromptManager (prompts.py)
• Agents:
• API Agents (biochatter/api_agent)
• RAG Agent (rag_agent.py) → uses VectorstoreAgent
• LLM Connectors (biochatter/llm_connect)
• Database Agent (database_agent.py)
3. Data & Storage
• BioCypher Knowledge Graph (external service)
• Vector Store (e.g., Milvus)
• Benchmark Data + Results (benchmark/data, benchmark/results)
4. External Services
• LLM Providers: OpenAI, Anthropic, Gemini, Ollama, Xinference, etc.
• Web APIs: BLAST, ONCOKB, other bio-tools
5. CI/CD & Docs
• GitHub Actions (ci.yaml, docs.yaml, publish.yaml)
• MkDocs
• Client → Core Library: “submit query / run benchmark”
• Core Library → PromptManager: “construct prompt”
• Core Library → LLM Connectors → LLM Providers: “LLM API call / response”
• Core Library → API Agents → Bio-tools / KG: “data retrieval”
• RAG Agent → VectorstoreAgent → Vector Store: “embedding search”
• Benchmark Harness → Core Library → Results → benchmark/results/processed
• CI/CD → Tests (test/) & Docs → Deployment
c. Architectural Patterns & Principles
• Plugin pattern for LLM/connectors (loose coupling)
• Agent pattern for chaining behaviors (api_agent, rag_agent, selector_agent)
• Layered architecture: Client → Service Layer → Data Layer → External
• Separation of concerns between core logic and benchmarking/visualization
d. Key Technologies / Frameworks
• Python modules & setuptools/poetry (pyproject.toml)
• pytest (tests, conftest.py)
• MkDocs + Material theme (docs/)
• Docker / Docker-Compose for optional deployment (docker-compose.yml, milvus-docker-compose.yml)
• GitHub Actions for CI/CD