How doncamilom/bollama works
Project type and purpose
• BOLLaMa is a Python-based AI‐powered chatbot for Bayesian optimization of chemical reactions.
• It bundles a command‐line + web UI (via Gradio), an LLM interface (OpenAI API), a Bayesian optimization engine, domain tools, and optional graph‐based chemistry libraries.
File structure
Top-level
• app.py – main entrypoint; launches Gradio app and wires user input → backend.
• data/ – CSV of example reaction data used by tools or demos.
• pyproject.toml, setup.cfg, setup.py – packaging, dependencies, version.
• docs/ – Sphinx documentation with conf.py, makefile, rst pages.
• .github/workflows/ci.yml, tox.ini – CI/CD and testing configuration.
src/bollama/
• __init__.py – package initializer
• LLMInterface.py – abstraction over OpenAI (or other) calls
• agents.py – high‐level agents that orchestrate LLM prompts + tool calls
• bopt.py – Bayesian optimization engine that selects next experiment
• tools.py – domain‐specific utilities (e.g., graph construction via Graphein, data parsing)
tests/
• conftest.py – pytest fixtures for unit/integration tests
Key architectural insights from README
• UI: Gradio-based web interface launched by app.py
• External services: OpenAI API (requires API key)
• Optional libraries: graphein (molecular graphs), gradio (UI)
• Data: example CSV, but real usage is interactive, no persistent DB
Main components and interactions
a. User Interface layer
– Gradio Web App (app.py)
– Assets: logos, images, static CSS (if any)
b. Application layer
– Input preprocessor (clean user text)
– LLM Interface → sends prompts to OpenAI → receives completions
– Agents orchestrator → decides when to call optimization or tools
– Tools library → data loaders, graph constructors, helper functions
c. Optimization layer
– Bayesian Optimization module (bopt.py) → proposes new reaction conditions
d. Data layer
– Local CSV (data/additives_reactions.csv) used for demos or benchmarking
e. External services
– OpenAI API
– (Optional) Graphein for graph embeddings
f. CI/CD
– GitHub Actions (ci.yml) runs tests, linting
Architectural patterns and design principles
• Modular layering: clear separation of UI, orchestration (agents), business logic (optimization), utility tools.
• Dependency injection: app.py wires together LLMInterface, agents, bopt, tools.
• Stateless service: each user session is ephemeral; no persistent database.
• Plugin-style extensibility: you could swap out LLM backend or optimization algorithm by replacing interfaces.