pip install git+https://github.com/openai/swarm.git
Welcome to the Knowledge Management Swarm, a sophisticated system designed to manage and organize your Zettelkasten markdown notes using AI-driven agents. This project leverages the power of OpenAI's Swarm library to create a swarm of specialized agents that collaboratively handle various aspects of knowledge management, ensuring efficient organization, retrieval, and learning from your notes.
- Project Overview
- Directory Structure
- Core Components
- Functionality
- Setup and Installation
- Usage
- Contributing
- License
The Knowledge Management Swarm is built around the Zettelkasten method, a system for organizing and interlinking notes to enhance creativity and learning. The project utilizes a swarm of agents, each with distinct responsibilities, to automate the management of notes across various stages—from collection and organization to facilitating learning.
├── agents
│ ├── __init__.py
│ ├── collector.py
│ ├── delegator.py
│ ├── organizer.py
│ ├── teacher.py
│ └── functions
│ └── universal_functions.py
├── utils
│ ├── __init__.py
│ ├── agent_utils.py
│ ├── file_operations.py
│ └── swarm_utils.py
├── Notes
│ ├── 1 - Rough Notes
│ ├── 2 - Source Material
│ ├── 3 - Tags
│ ├── 4 - Indexes
│ ├── 5 - Templates
│ ├── 6 - Full Notes
│ └── 7 - Planning
├── run.py
├── README.md
└── .gitignore
The project defines a set of agents, each responsible for specific tasks within the knowledge management workflow. All agents inherit from the Agent class provided by the swarm library and operate collaboratively to ensure seamless note management.
- File:
agents/delegator.py - Role: Acts as the central coordinator of the swarm.
- Responsibilities:
- Receives all user inputs and queries.
- Determines the nature of each request.
- Assigns tasks to the appropriate agents (Teacher, Organizer, Collector).
- Communicates exclusively with other agents, not performing tasks directly.
Key Features:
- Utilizes functions to transfer tasks to other agents (
transfer_to_teacher,transfer_to_organizer,transfer_to_collector). - Maintains awareness of the directory structure for effective task delegation.
- File:
agents/organizer.py - Role: Structures and categorizes the user's Zettelkasten markdown notes.
- Responsibilities:
- Manages unique IDs for notes.
- Links related notes.
- Handles tags from the "3 - Tags" directory.
- Assigns notes to appropriate folders based on content.
Key Features:
- Accesses and creates note files using functions like
read_note_fileandcreate_note_file. - Familiar with all directories within the
Notesfolder to ensure proper categorization.
- File:
agents/collector.py - Role: Ingests and collects user information into Zettelkasten markdown notes.
- Responsibilities:
- Handles data entry from "1 - Rough Notes" and "2 - Source Material".
- Performs metadata tagging.
- Parses content from various inputs (text, PDFs, media).
- Converts inputs into structured markdown in "6 - Full Notes".
- Assigns unique IDs to new notes and links them to existing ones.
Key Features:
- Utilizes functions like
read_note_fileandlist_notesto manage note files effectively.
- File:
agents/teacher.py - Role: Assists the user in internalizing and learning from their markdown notes.
- Responsibilities:
- Creates learning plans based on content from "6 - Full Notes".
- Generates quizzes and flashcards for key concepts.
- Extracts key concepts from "Main Notes" and relevant tags.
Key Features:
- Leverages functions like
read_note_fileandlist_notesto access and utilize note content for educational purposes.
- File:
utils/file_operations.py - Purpose: Handles all file-related operations within the
Notesdirectory. - Key Functions:
read_note_file(folder, filename): Reads the contents of a specific note.create_note_file(folder, filename, content): Creates a new note file in the specified folder.list_notes(folder): Lists all markdown files in the specified folder.
- File:
utils/swarm_utils.py - Purpose: Provides helper functions for interacting with the swarm and processing responses.
- Key Functions:
pretty_print_messages(messages): Formats and displays messages from agents.process_and_print_streaming_response(response): Handles and displays streaming responses from the swarm.
- File:
utils/agent_utils.py - Purpose: Converts function definitions to schemas compatible with the swarm framework.
- Key Functions:
function_to_schema(func): Transforms a Python function into a schema dictionary, mapping parameter types appropriately.
- Agent Communication: Agents communicate through defined transfer functions, ensuring tasks are delegated without overlap or redundancy.
- Note Management: The system categorizes notes into predefined directories, maintaining a structured and easily navigable knowledge base.
- Learning Assistance: The Teacher agent facilitates learning by generating study materials like quizzes and flashcards based on the user's notes.
- User Interaction: Users interact with the system via a command-line interface provided by
run.py, where they can input queries and receive responses from the swarm.
-
Clone the Repository:
git clone https://github.com/yourusername/knowledge-management-swarm.git cd knowledge-management-swarm -
Install Dependencies: Ensure you have Python installed. Then, install the necessary packages:
pip install -r requirements.txt
Note: If
requirements.txtis not present, install the Swarm library directly:pip install git+https://github.com/openai/swarm.git
-
Configure Environment:
- Create a
.envfile in the root directory to store environment variables like API keys. - Ensure the
Notesdirectory structure is intact as per the project requirements.
- Create a
-
Initialize Swarm: The
run.pyscript initializes the swarm with the Delegator agent and sets up the interaction loop.
Run the main script to start interacting with the Knowledge Management Swarm:
python run.py- Commands:
- Interact: Type your queries or inputs when prompted.
- Exit: Type
exitto terminate the chat session.
Example Interaction:
Welcome to the Knowledge Management Swarm Chat!
You can interact with various agents to manage your Zettelkasten notes.
Type 'exit' to end the chat.
==================================================
User: Add a new note about machine learning fundamentals.
[Delegator]: Task delegated to Organizer.
==================================================
Contributions are welcome! Please follow these steps:
- Fork the Repository
- Create a Feature Branch
git checkout -b feature/YourFeature
- Commit Your Changes
git commit -m "Add your feature" - Push to the Branch
git push origin feature/YourFeature
- Open a Pull Request
Please ensure that your code follows the project's coding standards and that all tests pass.
This project is licensed under the MIT License.