This project is powered by CrewAI and is designed to automate the analysis of blood test reports to provide personalized health recommendations.
Leveraging the powerful CrewAI framework, this multi-agent system performs the following tasks:
-
Input: The system accepts a sample blood test report for analysis.
-
Analysis: Using the Blood Test Analyst agent, the system analyzes the blood test report and summarizes the key health indicators in an easy-to-understand manner.
-
Find Articles: The Health Article Researcher agent then searches the web for relevant health articles tailored to the individual’s health needs based on the blood test results.
-
Recommendations: Finally, the Health Advisor agent provides personalized health recommendations and includes links to the relevant articles for further reading.
This template is designed to help you set up a multi-agent AI system, leveraging CrewAI’s framework to enable effective collaboration among agents. The aim is to maximize the collective intelligence and capabilities of the agents, ensuring comprehensive and actionable health insights.
CrewAI is a flexible and powerful framework designed to create, manage, and deploy multi-agent AI systems for real-world use cases. It allows you to define and configure AI agents that can work together on complex tasks, streamlining processes and providing intelligent solutions.
CrewAI uses a structured approach where agents are defined with specific roles and tasks. The framework allows you to customize agents, configure their tasks, and integrate various tools to achieve your objectives. Agents can be configured through agents.yaml
, and their tasks are defined in tasks.yaml
.
In this project, we used AI agents to analyze blood test reports, search for health-related articles, and provide health recommendations. The key agents and their tasks are:
- Health Report Analyzer: This agent reads and analyzes the blood test report, summarizing the findings in an easy-to-understand manner.
- Article Researcher: This agent searches the web for articles tailored to the person's health needs based on the blood test results. We used the Google Serper Search API for this, but Gemini API or OpenAI API could have been used as alternatives.
- Health Advisor: Based on the analysis and articles found, this agent provides health recommendations and links to relevant resources.
- Input: The system takes a sample blood test report.
- Analysis: The Health Report Analyzer agent examines the report, highlighting key results and any deviations from the normal range.
- Research: The Article Researcher agent searches the web for relevant health articles using the
Google Serper Search API
. - Recommendations: The Health Advisor agent provides personalized health recommendations based on the blood test analysis and the articles found.
Ensure you have Python >=3.10 <=3.13 installed on your system. This project uses Poetry for dependency management.
To install CrewAI, you can use the following commands:
# Install the main CrewAI package
pip install crewai
# Install the main CrewAI package and the tools package
# that includes a series of helpful tools for your agents
pip install 'crewai[tools]'
# Alternatively, you can also use:
pip install crewai crewai-tools
To create a new CrewAI project, use the following command:
crewai create crew <project_name>
This will create a new project folder with the following structure:
my_project/
├── .gitignore
├── pyproject.toml
├── README.md
└── src/
└── my_project/
├── __init__.py
├── main.py
├── crew.py
├── tools/
│ ├── custom_tool.py
│ └── __init__.py
└── config/
├── agents.yaml
└── tasks.yaml
To customize your project, you can:
- Modify src/my_project/config/agents.yaml to define your agents.
- Modify src/my_project/config/tasks.yaml to define your tasks.
- Modify src/my_project/crew.py to add your own logic, tools, and specific arguments.
- Modify src/my_project/main.py to add custom inputs for your agents and tasks.
- Add your environment variables into the .env file.
Here’s an example of how you might define agents
and their tasks
:
- blood_test_analyst
# src/my_project/config/agents.yaml
blood_test_analyst:
role: >
Blood Test Analyst
goal: >
Analyze the given blood test report and summarize the key health indicators.
backstory: >
You are a skilled medical analyst specializing in interpreting blood test results. Your focus is on identifying critical health metrics and abnormalities to provide a clear summary of the individual's health status.
tasks:
- analyze_blood_test
- health_article_researcher
health_article_researcher:
role: >
Health Article Researcher
goal: >
Search the internet for health articles that are relevant to the individual's needs based on the blood test analysis.
backstory: >
You are an expert in finding reliable health information online. Your ability to sift through vast amounts of data ensures that you can find the most relevant and accurate articles to guide health decisions.
tasks:
- search_health_articles
- health_advisor
health_advisor:
role: >
Health Advisor
goal: >
Provide personalized health recommendations based on the blood test analysis and the articles found.
backstory: >
You are a health advisor with a deep understanding of nutrition, lifestyle changes, and medical advice. Your recommendations are based on a combination of data analysis and expert knowledge to help individuals improve their health.
tasks:
- provide_health_recommendations
- analyze_blood_test
analyze_blood_test:
description: >
Analyze the blood test report to extract relevant health information.
expected_output: >
Summary of the blood test report.
agent: researcher
context:
- researcher
- search_health_articles
search_health_articles:
description: >
Search for health-related articles based on the provided summary.
expected_output: >
List of relevant articles.
agent: researcher
context:
- researcher
- provide_health_recommendations
provide_health_recommendations:
description: >
Provide health recommendations based on the retrieved articles.
expected_output: >
Health recommendations.
agent: researcher
context:
- researcher
Use the annotations to properly reference the agent and task in the crew.py file.
Annotations include:
@agent
@task
@crew
@llm
@tool
@callback
@output_json
@output_pydantic
@cache_handler
To install the dependencies for your project, navigate to your project directory:
cd my_project
crewai install
poetry lock
poetry install
This will install the dependencies specified in the pyproject.toml
file.
To kickstart your crew of AI agents and begin task execution, run this from the root folder of your project:
cd my_project
PYTHONPATH=./src python -m my_project.main
This command initializes the MyProject Crew, assembling the agents and assigning them tasks as defined in your configuration.
If you need to reset the memory of your crew before running it again, you can do so by calling the reset memory feature:
crewai reset-memory
This will clear the crew's memory, allowing for a fresh start.
The easiest way to deploy your crew is through CrewAI+ (still in Beta but you can apply for early access), where you can deploy your crew in a few clicks.
For support, questions, or feedback regarding the MyProject Crew or CrewAI:
- Visit CrewAI's website
- Check out their documentation
- Chat with CrewAI's docs
- Join thier Discord community
- Read thier blog
https://drive.google.com/drive/folders/1Ob-wz4dOU6uWbLTx3It_AMzbAayFaHLG?usp=sharing
Analyzing report:
+-----------------------------------+-----------+----------+----------------------+
| Test Name | Results | Units | Bio. Ref. Interval |
+===================================+===========+==========+======================+
| Hemoglobin | 15 | g/dL | 13.00 - 17.00 |
+-----------------------------------+-----------+----------+----------------------+
| Packed Cell Volume (PCV) | 45 | % | 40.00 - 50.00 |
+-----------------------------------+-----------+----------+----------------------+
| RBC Count | 4.5 | mill/mm3 | 4.50 - 5.50 |
+-----------------------------------+-----------+----------+----------------------+
| MCV | 90 | fL | 83.00 - 101.00 |
+-----------------------------------+-----------+----------+----------------------+
| MCH | 32 | pg | 27.00 - 32.00 |
+-----------------------------------+-----------+----------+----------------------+
| MCHC | 33 | g/dL | 31.50 - 34.50 |
+-----------------------------------+-----------+----------+----------------------+
| Red Cell Distribution Width (RDW) | 14 | % | 11.60 - 14.00 |
+-----------------------------------+-----------+----------+----------------------+
Searching articles based on: Hemoglobin is within the normal range. Packed Cell Volume (PCV) is within the normal range. RBC Count...
Providing recommendations based on: ['https://www.ncbi.nlm.nih.gov/books/NBK260/', 'https://www.ncbi.nlm.nih.gov/books/NBK545275/', 'https://emedicine.medscape.com/article/2054497-overview', 'https://my.clevelandclinic.org/health/diagnostics/24641-mcv-blood-test', 'https://medlineplus.gov/lab-tests/red-blood-cell-rbc-indices/', 'https://www.sciencedirect.com/topics/biochemistry-genetics-and-molecular-biology/mean-corpuscular-hemoglobin-concentration', 'https://www.verywellhealth.com/mean-corpuscular-hemoglobin-concentration-797200', 'https://www.testing.com/tests/mch-test/', 'https://www.sciencedirect.com/topics/medicine-and-dentistry/mean-corpuscular-hemoglobin', 'https://www.medicalnewstoday.com/articles/mcv-levels']
Health Summary:
-
Hemoglobin is within the normal range.
-
Packed Cell Volume (PCV) is within the normal range.
-
RBC Count is within the normal range.
-
MCV is within the normal range.
-
MCH is within the normal range.
-
MCHC is within the normal range.
-
Red Cell Distribution Width (RDW) is within the normal range.
Recommended Articles: ['https://www.ncbi.nlm.nih.gov/books/NBK260/', 'https://www.ncbi.nlm.nih.gov/books/NBK545275/', 'https://emedicine.medscape.com/article/2054497-overview', 'https://my.clevelandclinic.org/health/diagnostics/24641-mcv-blood-test', 'https://medlineplus.gov/lab-tests/red-blood-cell-rbc-indices/', 'https://www.sciencedirect.com/topics/biochemistry-genetics-and-molecular-biology/mean-corpuscular-hemoglobin-concentration', 'https://www.verywellhealth.com/mean-corpuscular-hemoglobin-concentration-797200', 'https://www.testing.com/tests/mch-test/', 'https://www.sciencedirect.com/topics/medicine-and-dentistry/mean-corpuscular-hemoglobin', 'https://www.medicalnewstoday.com/articles/mcv-levels']
Health Recommendations: Check out these articles for more information on blood test results:
- https://www.ncbi.nlm.nih.gov/books/NBK260/
- https://www.ncbi.nlm.nih.gov/books/NBK545275/
- https://emedicine.medscape.com/article/2054497-overview
- https://my.clevelandclinic.org/health/diagnostics/24641-mcv-blood-test
- https://medlineplus.gov/lab-tests/red-blood-cell-rbc-indices/
- https://www.sciencedirect.com/topics/biochemistry-genetics-and-molecular-biology/mean-corpuscular-hemoglobin-concentration
- https://www.verywellhealth.com/mean-corpuscular-hemoglobin-concentration-797200
- https://www.testing.com/tests/mch-test/
- https://www.sciencedirect.com/topics/medicine-and-dentistry/mean-corpuscular-hemoglobin
- https://www.medicalnewstoday.com/articles/mcv-levels
Additionally, here are some general health recommendations:
- Drink plenty of water.
- Avoid alcohol and smoking.
- Ensure adequate vitamin D exposure.
- Maintain a balanced diet and exercise regularly.