Loading repository data…
Loading repository data…
AdieLaine / repository
The Multi-Agent Reasoning framework creates an interactive chatbot where AI agents collaborate via structured reasoning and Swarm Integration for optimal answers. Simulating a team that discusses, debates, and refines responses, it enables complex problem-solving and precise results. Now with Prompt Caching to reduce latency and costs.
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
The Multi-Agent Reasoning with Memory and Swarm Framework framework creates an interactive chatbot experience where multiple AI agents collaborate through a structured reasoning process to provide optimal answers. Each agent brings unique perspectives and expertise, and through iterative steps of discussion, verification, critique, and refinement, they converge on a high-quality, accurate response.
Additionally, the system integrates the Swarm Framework for Intelligence to enhance collaboration among agents. Swarm allows agents to coordinate efficiently, leveraging collective intelligence to solve complex tasks.
Users can also chat with individual agents. Agents are aware of each other, including their personalities and quirks, and can answer questions about one another, providing a rich and interactive experience.
Clone the Repository
git clone https://github.com/AdieLaine/multi-agent-reasoning.git
Navigate to the Project Directory
cd multi-agent-reasoning
Create a Virtual Environment (Optional but Recommended)
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
Install Required Packages
pip install -r requirements.txt
Alternatively, install packages individually:
pip install openai colorama tiktoken
Install Swarm
pip install git+https://github.com/openai/swarm.git
Refer to Swarm's GitHub repository for detailed installation instructions.
Set Your OpenAI API Key
Set your API key as an environment variable:
export OPENAI_API_KEY='your-api-key-here'
On Windows:
set OPENAI_API_KEY=your-api-key-here
Alternatively, use a .env file or set it directly in your script.
Execute the main script to start the Multi-Agent Reasoning chatbot:
python reasoning.py
Upon running, you'll see the main menu:
═════════════════════════════════════════════════════════════════════════════════════════════
╔════════════════════════════════════════════════════════════════════════════════════╗
║ Multi-Agent Reasoning Chatbot ║
╚════════════════════════════════════════════════════════════════════════════════════╝
Please select an option:
1. Chat with an agent
2. Use reasoning logic
3. Use Swarm-based reasoning
4. Exit
Enter your choice (1/2/3/4):
Chat with an Agent
Use Reasoning Logic
Use Swarm-Based Reasoning
Exit
The system utilizes specific OpenAI models tailored to different functionalities:
o1 for advanced reasoning tasks is optimal, you can also use gpt-4o.
o1 is compatible with this current code version, other models may be added in lieu of o1.gpt-4o for interactive agent conversations.gpt-4o.These models support detailed token usage reporting, aiding in monitoring and optimizing performance.
Objective: Engage in direct, personalized conversations with a chosen agent.
Example:
Objective: Facilitate a comprehensive reasoning process through multi-agent collaboration.
Steps:
Initial Discussion
Verification
Critiquing
Refinement
Response Blending
blend_responses function for optimal synthesis.User Feedback Loop
Context Retention
Swarm Integration enhances the Multi-Agent Reasoning system by enabling dynamic agent coordination and task delegation. Swarm allows agents to collaborate efficiently, leveraging collective intelligence to solve complex tasks and improve responsiveness.
Swarm focuses on making agent coordination and execution lightweight, highly controllable, and easily testable. It achieves this through two primitive abstractions: Agents and Handoffs. An Agent encompasses instructions and tools and can, at any point, choose to hand off a conversation to another Agent.
Swarm Client Initialization
from swarm import Agent, Swarm
client = Swarm()
Agent Initialization
agents.json.Conversation Handling
Objective: Utilize the Swarm Framework for Intelligence to coordinate agents dynamically for efficient collaboration and task delegation.
Steps:
Initialization
agents.json.Discussion
Verification
Critiquing
Refinement
Blending Responses
Example:
Objective: Provide a seamless chat interface leveraging Swarm's capabilities for agent interactions.
Swarm Agent for Chat
def swarm_chat_interface(conversation_history):
# Load Swarm agent's configuration
swarm_agent = ... # Initialize Swarm agent
messages = [{"role": "system", "content": swarm_agent.instructions}]
messages.extend(conversation_history)
response = client.run(agent=swarm_agent, messages=messages)
swarm_reply = response.messages[-1]['content'].strip()
return swarm_reply
Dynamic Responses
Example: