mrtrixagentns.-.Trim.mp4
This project serves as a simple implemention of Agentic AI knowledge base generation and retrieval. This foundation can be built on to implement custom workflows or transfer the framework to other documented software. The general structure of this repo is as follows:
- Official MRtrix3 documentation (latest version) is stored in a PostgreSQL database (Supabase)
- Users install a chromaDB locally which fetches documents from Supabase and stores them locally
- Upon every app startup, chromaDB checks itself against Supabase (ground truth) to determine if sync for up-to-date documentation is needed
- User chats with AI Agent (Gemini-2.5-flash)
- To provide accurate answers, AI Agent is equipped with a search tool to reference relevant and up-to-date documentation
- Monitoring and log collection is available and updated in real-time to view Agent queries and retrievals in real-time
From this basic structure, additional tools or extensions to the AI Agent's capabilities can be easily added. As an example, the current version of the repo comes with 3 sample slash commands, one of which ("/sharefile") allows the user to share their file metadata with the Agent using MRtrix's 'mrinfo' for personalized guidance.
- Python 3.10 or higher
- API keys for your Gemini (Google)
- The code currently only supports Gemini as Google offers a generous free tier for API calls.
- Google API key can be generated from Google AI Studio, docs here: https://ai.google.dev/gemini-api/docs/api-key
- Currently only tested on Linux systems
- Install with pip
pip install mrtrix3-agent- Setup your API key (you will be prompted to enter)
setup-mrtrixbot- Run the agent and chat!
mrtrixbotgit clone https://github.com/yourusername/mrtrix3-agent.git
cd mrtrix3-agentpython -m venv .venv
source .venv/bin/activatepip install -e . # For standard usage
# or
pip install -e ".[dev]" # If you want to run test scripts with pytest'.env.example' contains configurable environment variables used in this project. The project was built with Supabase and Gemini. If wanting to replicate this project, a Supabase account is required and all the tools to populate your own database can be found in the src/knowledge_base folder. Great for anyone curious about how a knowledge base gets created, or for those trying to maybe create a "smarter" knowledge base for the AI agent!
Populate the Supabase vector database with MRtrix3 documentation:
python knowledgeBase/populate_database.pyThis will:
- Clone MRtrix3 repository (sparse checkout)
- Process documentation and source files
- Generate embeddings and populate the database
- Takes approximately 1-5 minutes
Start the interactive CLI:
mrtrix3-agentOr use the Python script directly:
python src/agent/cli.py
# or
python -m src.agent.cliThe agent includes built-in monitoring:
- Set environment variable 'COLLECT_LOGS=true'
- Session logs in
monitoring/logs/ - Performance metrics in
monitoring/metrics/ - Error tracking with detailed stack traces
Logs within monitoring/logs/ get updated in real-time, good to look at if you are curious where the AI agent is searching for info
to answer queries!
This project is licensed under the MIT License - see the LICENSE file for details.