How biagent-dev/bia works
Main Components
• CLI Entry Point: Represented by the file “biagent/entry_point.py” which is responsible for parsing user commands and dispatching tasks.
• Configurations: Include the “biagent/configs” module (e.g., metadata configuration) that provides runtime settings.
• Prompts & Templates: The “biagent/prompts” directory contains Jinja templates (metadata.jinja, mtx_reader.jinja, pipeline_extractor.jinja, etc.) used to generate instructions for LLMs.
• Tools: In “biagent/tools”, you have modules like geo_search.py, count_matrix_reader.py, metadata.py, and pipeline_extractor.py. These implement the core bioinformatics functionalities.
• Data Types & Models: “biagent/types” houses type definitions and Pydantic models which are central to data validation and structured data handling.
• Utilities: “biagent/utils” covers supporting functions such as code execution (code_runner), logging (logger), LLM interaction wrappers (llm_helpers), metadata and pipeline helpers, and other parsing logic.
• Data Resources: The “data” folder (e.g., sc_rna_seq_pipeline.json) may serve as a static resource providing pipeline configurations or sample workflows.
• External Dependencies: Mention the integration with external systems via environment variables (e.g., DASHSCOPE_API_KEY, OPENAI_API_KEY, OPENAI_API_BASE). These are critical for the LLM and API integrations.
Relationships and Interactions
• The CLI entry point receives commands and dispatches them to the respective “tools” (e.g., geo_search for sample queries, metadata extraction, count matrix reading, and pipeline extraction).
• Each “tool” component uses its corresponding prompt templates (from the “prompts” folder) to generate queries/instructions that are sent to the LLM services via the utilities (llm_helpers).
• Configuration settings from “configs” are loaded early in the process and are used by tools/utilities to ensure the correct meta settings and behaviors.
• Pydantic models and type aliases (from “types”) are employed throughout the system to ensure data integrity and validate inputs/outputs.
• Utility modules such as logging, output parsing, and helper functions support smooth data flow and error handling.
Architectural Patterns and Design Principles
• Modular Design: Notice how the project is split into clear functional modules (entry point, tools, prompts, types, utils) that encourage separation of concerns.
• Template-Driven LLM Communication: Use the prompts (Jinja templates) to dynamically format queries to LLMs.
• CLI-Based Workflow: All activities are initiated from a central command interface, which then channels operations to dedicated tools.
• Dependency Injection/Configuration Management: The configuration module (“configs”) ensures that environment-specific settings are managed systematically.
• Extensibility: The clear separation between prompt definitions and tool implementations allows for future expansion (e.g., adding frontend/backend as indicated in the roadmap).