Skip to content

Commit

Permalink
[CLEANUP]
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Nov 11, 2024
1 parent a022401 commit 5f0425d
Showing 1 changed file with 58 additions and 2 deletions.
60 changes: 58 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ pip install -r requirements.txt

3. **Configure Environment Variables**
```bash
# Copy example env file
cp .env.example .env
# Create .env file

# Edit .env file with your credentials
GROQ_API_KEY="your-api-key-here"
WORKSPACE_DIR="agent_workspace"
OPENAI_API_KEY="your-openai-api-key-here"
```

4. **Run the Example**
Expand Down Expand Up @@ -97,6 +97,62 @@ In `main.py`, update the `flow` parameter in the `AgentRearrange` initialization
flow=f"{agent1.agent_name} -> {agent2.agent_name} -> {new_agent.agent_name}"
```

## Integrating RAG

- The `memory_system` parameter in the `AgentRearrange` initialization is used to configure the RAG system.
- The `memory_system` parameter is an instance of `LlamaIndexDB`, which is a database class for storing and retrieving medical documents.
- The `memory_system` class must have a `query(query: str)` method that returns a string for the agent to use it.

```python

# Import the AgentRearrange class for coordinating multiple agents
from swarms import AgentRearrange

# Import specialized medical agents for different aspects of patient care
from multi_agent_rag.agents import (
diagnostic_specialist, # Agent for diagnostic analysis
medical_data_extractor, # Agent for extracting medical data
patient_care_coordinator, # Agent for coordinating patient care
specialist_consultant, # Agent for specialist consultation
treatment_planner, # Agent for treatment planning
)

# Import database class for storing and retrieving medical documents
from multi_agent_rag.memory import LlamaIndexDB

# Initialize the SwarmRouter to coordinate the medical agents
router = AgentRearrange(
name="medical-diagnosis-treatment-swarm",
description="Collaborative medical team for comprehensive patient diagnosis and treatment planning",
max_loops=1, # Limit to one iteration through the agent flow
agents=[
medical_data_extractor, # First agent to extract medical data
diagnostic_specialist, # Second agent to analyze and diagnose
treatment_planner, # Third agent to plan treatment
specialist_consultant, # Fourth agent to provide specialist input
patient_care_coordinator, # Final agent to coordinate care plan
],
# Configure the document storage and retrieval system
memory_system=LlamaIndexDB(
data_dir="docs", # Directory containing medical documents
filename_as_id=True, # Use filenames as document identifiers
recursive=True, # Search subdirectories
# required_exts=[".txt", ".pdf", ".docx"], # Supported file types
similarity_top_k=10, # Return top 10 most relevant documents
),
# Define the sequential flow of information between agents
flow=f"{medical_data_extractor.agent_name} -> {diagnostic_specialist.agent_name} -> {treatment_planner.agent_name} -> {specialist_consultant.agent_name} -> {patient_care_coordinator.agent_name}",
)

# Example usage
if __name__ == "__main__":
# Run a comprehensive medical analysis task for patient Lucas Brown
router.run(
"Analyze this Lucas Brown's medical data to provide a diagnosis and treatment plan"
)

```



## 📚 Documentation
Expand Down

0 comments on commit 5f0425d

Please sign in to comment.