massgen 0.0.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of massgen might be problematic. Click here for more details.
- massgen/__init__.py +94 -0
- massgen/agent_config.py +507 -0
- massgen/backend/CLAUDE_API_RESEARCH.md +266 -0
- massgen/backend/Function calling openai responses.md +1161 -0
- massgen/backend/GEMINI_API_DOCUMENTATION.md +410 -0
- massgen/backend/OPENAI_RESPONSES_API_FORMAT.md +65 -0
- massgen/backend/__init__.py +25 -0
- massgen/backend/base.py +180 -0
- massgen/backend/chat_completions.py +228 -0
- massgen/backend/claude.py +661 -0
- massgen/backend/gemini.py +652 -0
- massgen/backend/grok.py +187 -0
- massgen/backend/response.py +397 -0
- massgen/chat_agent.py +440 -0
- massgen/cli.py +686 -0
- massgen/configs/README.md +293 -0
- massgen/configs/creative_team.yaml +53 -0
- massgen/configs/gemini_4o_claude.yaml +31 -0
- massgen/configs/news_analysis.yaml +51 -0
- massgen/configs/research_team.yaml +51 -0
- massgen/configs/single_agent.yaml +18 -0
- massgen/configs/single_flash2.5.yaml +44 -0
- massgen/configs/technical_analysis.yaml +51 -0
- massgen/configs/three_agents_default.yaml +31 -0
- massgen/configs/travel_planning.yaml +51 -0
- massgen/configs/two_agents.yaml +39 -0
- massgen/frontend/__init__.py +20 -0
- massgen/frontend/coordination_ui.py +945 -0
- massgen/frontend/displays/__init__.py +24 -0
- massgen/frontend/displays/base_display.py +83 -0
- massgen/frontend/displays/rich_terminal_display.py +3497 -0
- massgen/frontend/displays/simple_display.py +93 -0
- massgen/frontend/displays/terminal_display.py +381 -0
- massgen/frontend/logging/__init__.py +9 -0
- massgen/frontend/logging/realtime_logger.py +197 -0
- massgen/message_templates.py +431 -0
- massgen/orchestrator.py +1222 -0
- massgen/tests/__init__.py +10 -0
- massgen/tests/multi_turn_conversation_design.md +214 -0
- massgen/tests/multiturn_llm_input_analysis.md +189 -0
- massgen/tests/test_case_studies.md +113 -0
- massgen/tests/test_claude_backend.py +310 -0
- massgen/tests/test_grok_backend.py +160 -0
- massgen/tests/test_message_context_building.py +293 -0
- massgen/tests/test_rich_terminal_display.py +378 -0
- massgen/tests/test_v3_3agents.py +117 -0
- massgen/tests/test_v3_simple.py +216 -0
- massgen/tests/test_v3_three_agents.py +272 -0
- massgen/tests/test_v3_two_agents.py +176 -0
- massgen/utils.py +79 -0
- massgen/v1/README.md +330 -0
- massgen/v1/__init__.py +91 -0
- massgen/v1/agent.py +605 -0
- massgen/v1/agents.py +330 -0
- massgen/v1/backends/gemini.py +584 -0
- massgen/v1/backends/grok.py +410 -0
- massgen/v1/backends/oai.py +571 -0
- massgen/v1/cli.py +351 -0
- massgen/v1/config.py +169 -0
- massgen/v1/examples/fast-4o-mini-config.yaml +44 -0
- massgen/v1/examples/fast_config.yaml +44 -0
- massgen/v1/examples/production.yaml +70 -0
- massgen/v1/examples/single_agent.yaml +39 -0
- massgen/v1/logging.py +974 -0
- massgen/v1/main.py +368 -0
- massgen/v1/orchestrator.py +1138 -0
- massgen/v1/streaming_display.py +1190 -0
- massgen/v1/tools.py +160 -0
- massgen/v1/types.py +245 -0
- massgen/v1/utils.py +199 -0
- massgen-0.0.3.dist-info/METADATA +568 -0
- massgen-0.0.3.dist-info/RECORD +76 -0
- massgen-0.0.3.dist-info/WHEEL +5 -0
- massgen-0.0.3.dist-info/entry_points.txt +2 -0
- massgen-0.0.3.dist-info/licenses/LICENSE +204 -0
- massgen-0.0.3.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Test script for MassGen two-agent coordination with terminal display.
|
|
4
|
+
Tests orchestrator coordination between two agents with different expertise.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import asyncio
|
|
8
|
+
import os
|
|
9
|
+
import sys
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
# Add project root to path
|
|
13
|
+
project_root = Path(__file__).parent.parent.parent.parent
|
|
14
|
+
sys.path.insert(0, str(project_root))
|
|
15
|
+
|
|
16
|
+
from massgen.backend.response import ResponseBackend
|
|
17
|
+
from massgen.chat_agent import SingleAgent
|
|
18
|
+
from massgen.orchestrator import Orchestrator
|
|
19
|
+
from massgen.frontend.coordination_ui import CoordinationUI
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
async def test_two_agents_coordination():
|
|
23
|
+
"""Test two-agent coordination with different expertise areas."""
|
|
24
|
+
print("π MassGen - Two Agents Coordination Test")
|
|
25
|
+
print("=" * 60)
|
|
26
|
+
|
|
27
|
+
# Check if API key is available
|
|
28
|
+
api_key = os.getenv("OPENAI_API_KEY")
|
|
29
|
+
if not api_key:
|
|
30
|
+
print("β OPENAI_API_KEY not found in environment variables")
|
|
31
|
+
print("β οΈ Set OPENAI_API_KEY to test two-agent coordination")
|
|
32
|
+
return False
|
|
33
|
+
|
|
34
|
+
try:
|
|
35
|
+
# Create backend
|
|
36
|
+
backend = ResponseBackend(api_key=api_key)
|
|
37
|
+
|
|
38
|
+
# Create two agents with different expertise
|
|
39
|
+
scientist = SingleAgent(
|
|
40
|
+
backend=backend,
|
|
41
|
+
agent_id="scientist",
|
|
42
|
+
system_message="You are a brilliant scientist who excels at explaining complex scientific concepts clearly and accurately. Focus on scientific accuracy and clear explanations.",
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
educator = SingleAgent(
|
|
46
|
+
backend=backend,
|
|
47
|
+
agent_id="educator",
|
|
48
|
+
system_message="You are an experienced educator who specializes in making complex topics accessible to students. Focus on pedagogical clarity and engaging explanations.",
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
# Create orchestrator with two agents
|
|
52
|
+
agents = {"scientist": scientist, "educator": educator}
|
|
53
|
+
|
|
54
|
+
orchestrator = Orchestrator(agents=agents)
|
|
55
|
+
|
|
56
|
+
# Create UI for coordination display
|
|
57
|
+
ui = CoordinationUI(display_type="terminal", logging_enabled=True)
|
|
58
|
+
|
|
59
|
+
print("π₯ Created two-agent system:")
|
|
60
|
+
print(" π¬ Scientist - Scientific accuracy and explanations")
|
|
61
|
+
print(" π Educator - Pedagogical clarity and accessibility")
|
|
62
|
+
print()
|
|
63
|
+
|
|
64
|
+
# Test question that benefits from both perspectives
|
|
65
|
+
test_question = (
|
|
66
|
+
"How does photosynthesis work and why is it important for life on Earth?"
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
print(f"π Question: {test_question}")
|
|
70
|
+
print("\nπ Starting two-agent coordination...")
|
|
71
|
+
print("=" * 60)
|
|
72
|
+
|
|
73
|
+
# Coordinate with UI (returns final response)
|
|
74
|
+
final_response = await ui.coordinate(orchestrator, test_question)
|
|
75
|
+
|
|
76
|
+
print("\n" + "=" * 60)
|
|
77
|
+
print("β
Two-agent coordination completed successfully!")
|
|
78
|
+
print(f"π Final response length: {len(final_response)} characters")
|
|
79
|
+
|
|
80
|
+
return True
|
|
81
|
+
|
|
82
|
+
except Exception as e:
|
|
83
|
+
print(f"β Two-agent coordination test failed: {e}")
|
|
84
|
+
import traceback
|
|
85
|
+
|
|
86
|
+
traceback.print_exc()
|
|
87
|
+
return False
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
async def test_two_agents_simple():
|
|
91
|
+
"""Simple two-agent test without UI for basic functionality verification."""
|
|
92
|
+
print("\nπ§ͺ Simple Two-Agent Test (No UI)")
|
|
93
|
+
print("-" * 40)
|
|
94
|
+
|
|
95
|
+
api_key = os.getenv("OPENAI_API_KEY")
|
|
96
|
+
if not api_key:
|
|
97
|
+
print("β OPENAI_API_KEY not found - skipping simple test")
|
|
98
|
+
return False
|
|
99
|
+
|
|
100
|
+
try:
|
|
101
|
+
backend = ResponseBackend(api_key=api_key)
|
|
102
|
+
|
|
103
|
+
# Create minimal agents
|
|
104
|
+
agent1 = SingleAgent(
|
|
105
|
+
backend=backend,
|
|
106
|
+
agent_id="analyst",
|
|
107
|
+
system_message="You are a data analyst. Provide analytical insights.",
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
agent2 = SingleAgent(
|
|
111
|
+
backend=backend,
|
|
112
|
+
agent_id="reviewer",
|
|
113
|
+
system_message="You are a reviewer. Provide critical evaluation.",
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
orchestrator = Orchestrator(agents={"analyst": agent1, "reviewer": agent2})
|
|
117
|
+
|
|
118
|
+
print("π€ Testing simple coordination...")
|
|
119
|
+
|
|
120
|
+
messages = [
|
|
121
|
+
{"role": "user", "content": "What are the benefits of renewable energy?"}
|
|
122
|
+
]
|
|
123
|
+
|
|
124
|
+
response_content = ""
|
|
125
|
+
async for chunk in orchestrator.chat(messages):
|
|
126
|
+
if chunk.type == "content" and chunk.content:
|
|
127
|
+
response_content += chunk.content
|
|
128
|
+
print(chunk.content, end="", flush=True)
|
|
129
|
+
elif chunk.type == "error":
|
|
130
|
+
print(f"\nβ Error: {chunk.error}")
|
|
131
|
+
return False
|
|
132
|
+
elif chunk.type == "done":
|
|
133
|
+
break
|
|
134
|
+
|
|
135
|
+
print(
|
|
136
|
+
f"\nβ
Simple test completed. Response length: {len(response_content)} characters"
|
|
137
|
+
)
|
|
138
|
+
return True
|
|
139
|
+
|
|
140
|
+
except Exception as e:
|
|
141
|
+
print(f"β Simple two-agent test failed: {e}")
|
|
142
|
+
return False
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
async def main():
|
|
146
|
+
"""Run two-agent coordination tests."""
|
|
147
|
+
print("π MassGen - Two Agents Test Suite")
|
|
148
|
+
print("=" * 60)
|
|
149
|
+
|
|
150
|
+
results = []
|
|
151
|
+
|
|
152
|
+
# Run simple test first
|
|
153
|
+
results.append(await test_two_agents_simple())
|
|
154
|
+
|
|
155
|
+
# Run full coordination test
|
|
156
|
+
if results[0]: # Only run if simple test passes
|
|
157
|
+
results.append(await test_two_agents_coordination())
|
|
158
|
+
else:
|
|
159
|
+
print("β οΈ Skipping full coordination test due to simple test failure")
|
|
160
|
+
results.append(False)
|
|
161
|
+
|
|
162
|
+
# Summary
|
|
163
|
+
print("\n" + "=" * 60)
|
|
164
|
+
print("π Test Results:")
|
|
165
|
+
print(f"β
Passed: {sum(results)}")
|
|
166
|
+
print(f"β Failed: {len(results) - sum(results)}")
|
|
167
|
+
|
|
168
|
+
if all(results):
|
|
169
|
+
print("π All two-agent tests passed!")
|
|
170
|
+
print("β
Two-agent coordination is working correctly")
|
|
171
|
+
else:
|
|
172
|
+
print("β οΈ Some tests failed - check API key and network connection")
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
if __name__ == "__main__":
|
|
176
|
+
asyncio.run(main())
|
massgen/utils.py
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from datetime import datetime
|
|
3
|
+
from typing import Any, Union, Optional, Dict, List
|
|
4
|
+
|
|
5
|
+
MODEL_MAPPINGS = {
|
|
6
|
+
"openai": [
|
|
7
|
+
# GPT-4.1 variants
|
|
8
|
+
"gpt-4.1",
|
|
9
|
+
"gpt-4.1-mini",
|
|
10
|
+
# GPT-4o variants
|
|
11
|
+
"gpt-4o-mini",
|
|
12
|
+
"gpt-4o",
|
|
13
|
+
# o1
|
|
14
|
+
"o1", # -> o1-2024-12-17
|
|
15
|
+
# o3
|
|
16
|
+
"o3",
|
|
17
|
+
"o3-low",
|
|
18
|
+
"o3-medium",
|
|
19
|
+
"o3-high",
|
|
20
|
+
# o3 mini
|
|
21
|
+
"o3-mini",
|
|
22
|
+
"o3-mini-low",
|
|
23
|
+
"o3-mini-medium",
|
|
24
|
+
"o3-mini-high",
|
|
25
|
+
# o4 mini
|
|
26
|
+
"o4-mini",
|
|
27
|
+
"o4-mini-low",
|
|
28
|
+
"o4-mini-medium",
|
|
29
|
+
"o4-mini-high",
|
|
30
|
+
],
|
|
31
|
+
"claude": [
|
|
32
|
+
# Claude 3.5 variants
|
|
33
|
+
"claude-3-5-sonnet-latest",
|
|
34
|
+
"claude-3-5-haiku-latest",
|
|
35
|
+
"claude-3-5-sonnet-20241022",
|
|
36
|
+
"claude-3-5-haiku-20241022",
|
|
37
|
+
# Claude 3 variants
|
|
38
|
+
"claude-3-sonnet-20240229",
|
|
39
|
+
"claude-3-opus-20240229",
|
|
40
|
+
"claude-3-haiku-20240307",
|
|
41
|
+
# Claude 2 variants
|
|
42
|
+
"claude-2.1",
|
|
43
|
+
"claude-2.0",
|
|
44
|
+
# Claude instant
|
|
45
|
+
"claude-instant-1.2",
|
|
46
|
+
# Sonnet 4
|
|
47
|
+
"claude-sonnet-4-20250514",
|
|
48
|
+
],
|
|
49
|
+
"gemini": [
|
|
50
|
+
"gemini-2.5-flash",
|
|
51
|
+
"gemini-2.5-pro",
|
|
52
|
+
],
|
|
53
|
+
"grok": [
|
|
54
|
+
"grok-3-mini",
|
|
55
|
+
"grok-3",
|
|
56
|
+
"grok-4",
|
|
57
|
+
],
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def get_backend_type_from_model(model: str) -> str:
|
|
62
|
+
"""
|
|
63
|
+
Determine the agent type based on the model name.
|
|
64
|
+
|
|
65
|
+
Args:
|
|
66
|
+
model: The model name (e.g., "gpt-4", "gemini-pro", "grok-1")
|
|
67
|
+
|
|
68
|
+
Returns:
|
|
69
|
+
Agent type string ("openai", "gemini", "grok")
|
|
70
|
+
"""
|
|
71
|
+
if not model:
|
|
72
|
+
return "openai" # Default to OpenAI
|
|
73
|
+
|
|
74
|
+
model_lower = model.lower()
|
|
75
|
+
|
|
76
|
+
for key, models in MODEL_MAPPINGS.items():
|
|
77
|
+
if model_lower in models:
|
|
78
|
+
return key
|
|
79
|
+
raise ValueError(f"Unknown model: {model}")
|
massgen/v1/README.md
ADDED
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="assets/logo.png" alt="MassGen Logo" width="360" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="https://www.python.org/downloads/">
|
|
7
|
+
<img src="https://img.shields.io/badge/python-3.10+-blue.svg" alt="Python 3.10+" style="margin-right: 5px;">
|
|
8
|
+
</a>
|
|
9
|
+
<a href="LICENSE">
|
|
10
|
+
<img src="https://img.shields.io/badge/license-Apache%202.0-blue.svg" alt="License" style="margin-right: 5px;">
|
|
11
|
+
</a>
|
|
12
|
+
<a href="https://discord.gg/VVrT2rQaz5">
|
|
13
|
+
<img src="https://img.shields.io/discord/1153072414184452236?color=7289da&label=chat&logo=discord&style=flat-square" alt="Join our Discord">
|
|
14
|
+
</a>
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
<h1 align="center">π MassGen: Multi-Agent Scaling System for GenAI</h1>
|
|
18
|
+
|
|
19
|
+
<p align="center">
|
|
20
|
+
<i>MassGen is a cutting-edge multi-agent system that leverages the power of collaborative AI to solve complex tasks.</i>
|
|
21
|
+
</p>
|
|
22
|
+
|
|
23
|
+
<p align="center">
|
|
24
|
+
<a href="https://youtu.be/eMBdoAYeujw">
|
|
25
|
+
<img src="assets/thumbnail.png" alt="MassGen Demo Video" width="600">
|
|
26
|
+
</a>
|
|
27
|
+
</p>
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
<!-- <div align="center">
|
|
31
|
+
<img src="assets/MassGen-v1.gif" alt="MassGen Demo" width="800">
|
|
32
|
+
</div> -->
|
|
33
|
+
|
|
34
|
+
> π§ **Multi-agent scaling through intelligent collaboration in Grok Heavy style**
|
|
35
|
+
|
|
36
|
+
MassGen is a cutting-edge multi-agent system that leverages the power of collaborative AI to solve complex tasks. It assigns a task to multiple AI agents who work in parallel, observe each other's progress, and refine their approaches to converge on the best solution to deliver a comprehensive and high-quality result. The power of this "parallel study group" approach is exemplified by advanced systems like xAI's Grok Heavy and Google DeepMind's Gemini Deep Think.
|
|
37
|
+
This project started with the "threads of thought" and "iterative refinement" ideas presented in [The Myth of Reasoning](https://docs.ag2.ai/latest/docs/blog/2025/04/16/Reasoning/), and extends the classic "multi-agent conversation" idea in [AG2](https://github.com/ag2ai/ag2).
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## π Table of Contents
|
|
42
|
+
|
|
43
|
+
- [β¨ Key Features](#-key-features)
|
|
44
|
+
- [ποΈ System Design](#οΈ-system-design)
|
|
45
|
+
- [π Quick Start](#-quick-start)
|
|
46
|
+
- [π‘ Examples](#-examples)
|
|
47
|
+
- [π€ Contributing](#-contributing)
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## β¨ Key Features
|
|
52
|
+
|
|
53
|
+
| Feature | Description |
|
|
54
|
+
|---------|-------------|
|
|
55
|
+
| **π€ Cross-Model/Agent Synergy** | Harness strengths from diverse frontier model-powered agents |
|
|
56
|
+
| **β‘ Parallel Processing** | Multiple agents tackle problems simultaneously |
|
|
57
|
+
| **π₯ Intelligence Sharing** | Agents share and learn from each other's work |
|
|
58
|
+
| **π Consensus Building** | Natural convergence through collaborative refinement |
|
|
59
|
+
| **π Live Visualization** | See agents' working processes in real-time |
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## ποΈ System Design
|
|
64
|
+
|
|
65
|
+
MassGen operates through a sophisticated architecture designed for **seamless multi-agent collaboration**:
|
|
66
|
+
|
|
67
|
+
```mermaid
|
|
68
|
+
graph TB
|
|
69
|
+
O[π MassGen Orchestrator<br/>π Task Distribution & Coordination]
|
|
70
|
+
|
|
71
|
+
subgraph Collaborative Agents
|
|
72
|
+
A1[Agent 1<br/>ποΈ Anthropic/Claude + Tools]
|
|
73
|
+
A2[Agent 2<br/>π Google/Gemini + Tools]
|
|
74
|
+
A3[Agent 3<br/>π€ OpenAI/GPT/O + Tools]
|
|
75
|
+
A4[Agent 4<br/>β‘ xAI/Grok + Tools]
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
H[π Shared Collaboration Hub<br/>π‘ Real-time Notification & Consensus]
|
|
79
|
+
|
|
80
|
+
O --> A1 & A2 & A3 & A4
|
|
81
|
+
A1 & A2 & A3 & A4 <--> H
|
|
82
|
+
|
|
83
|
+
classDef orchestrator fill:#e1f5fe,stroke:#0288d1,stroke-width:3px
|
|
84
|
+
classDef agent fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
|
|
85
|
+
classDef hub fill:#e8f5e8,stroke:#388e3c,stroke-width:2px
|
|
86
|
+
|
|
87
|
+
class O orchestrator
|
|
88
|
+
class A1,A2,A3,A4 agent
|
|
89
|
+
class H hub
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
The system's workflow is defined by the following key principles:
|
|
93
|
+
|
|
94
|
+
**Parallel Processing** - Multiple agents tackle the same task simultaneously, each leveraging their unique capabilities (different models, tools, and specialized approaches).
|
|
95
|
+
|
|
96
|
+
**Real-time Collaboration** - Agents continuously share their working summaries and insights through a notification system, allowing them to learn from each other's approaches and build upon collective knowledge.
|
|
97
|
+
|
|
98
|
+
**Convergence Detection** - The system intelligently monitors when agents have reached stability in their solutions and achieved consensus through natural collaboration rather than forced agreement.
|
|
99
|
+
|
|
100
|
+
**Adaptive Coordination** - Agents can restart and refine their work when they receive new insights from others, creating a dynamic and responsive problem-solving environment.
|
|
101
|
+
|
|
102
|
+
This collaborative approach ensures that the final output leverages collective intelligence from multiple AI systems, leading to more robust and well-rounded results than any single agent could achieve alone.
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## π Quick Start
|
|
107
|
+
|
|
108
|
+
### 1. π₯ Installation
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
git clone https://github.com/Leezekun/MassGen.git
|
|
112
|
+
cd MassGen
|
|
113
|
+
pip install uv
|
|
114
|
+
uv venv
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### 2. π API Configuration
|
|
118
|
+
|
|
119
|
+
Create a `.env` file in the `massgen/v1/backends/` directory with your API keys:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
# Copy example configuration
|
|
123
|
+
cp massgen/v1/backends/.env.example massgen/v1/backends/.env
|
|
124
|
+
|
|
125
|
+
# Edit with your API keys
|
|
126
|
+
OPENAI_API_KEY=sk-your-openai-key-here
|
|
127
|
+
XAI_API_KEY=xai-your-xai-key-here
|
|
128
|
+
GEMINI_API_KEY=your-gemini-key-here
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Make sure you set up the API key for the model you want to use.
|
|
132
|
+
|
|
133
|
+
**Useful links to get API keys:**
|
|
134
|
+
- [Gemini](https://ai.google.dev/gemini-api/docs)
|
|
135
|
+
- [OpenAI](https://platform.openai.com/api-keys)
|
|
136
|
+
- [Grok](https://docs.x.ai/docs/overview)
|
|
137
|
+
|
|
138
|
+
### 3. π§© Supported Models and Tools
|
|
139
|
+
|
|
140
|
+
<!-- What does the following mean? If it can be clarified, then we can uncomment -->
|
|
141
|
+
<!-- Configure the models you wish to use by updating the model registry in `massgen/utils.py`. -->
|
|
142
|
+
|
|
143
|
+
#### Models
|
|
144
|
+
|
|
145
|
+
The system currently supports three model providers with advanced reasoning capabilities: **Google Gemini**, **OpenAI**, and **xAI Grok**. The specific models tested can be found in `massgen/v1/utils.py`. Additional models can be registered in that file.
|
|
146
|
+
More providers and local inference of open-sourced models (using vllm or sglang) will be added (help wanted!) and the extension will be made easier.
|
|
147
|
+
|
|
148
|
+
#### Tools
|
|
149
|
+
|
|
150
|
+
MassGen agents can leverage various tools to enhance their problem-solving capabilities. The Gemini, OpenAI, and Grok models can use their own built-in search and code execution. You can easily extend functionality by registering custom tools in `massgen/v1/tools.py`.
|
|
151
|
+
|
|
152
|
+
**Supported Built-in Tools by Models:**
|
|
153
|
+
|
|
154
|
+
| Backend | Live Search | Code Execution |
|
|
155
|
+
|---------|:-----------:|:--------------:|
|
|
156
|
+
| **Gemini** | β
| β
|
|
|
157
|
+
| **OpenAI** | β
| β
|
|
|
158
|
+
| **Grok** | β
| β |
|
|
159
|
+
|
|
160
|
+
> π§ **Custom Tools**: More tools are coming soon! Check `massgen/v1/tools.py` to add your own custom tools and expand agent capabilities.
|
|
161
|
+
|
|
162
|
+
### 4. π Run MassGen
|
|
163
|
+
|
|
164
|
+
#### Simple Usage
|
|
165
|
+
```bash
|
|
166
|
+
# Multi-agent mode with specific models
|
|
167
|
+
uv run python -m massgen.v1.cli "Which AI won IMO in 2025?" --models gemini-2.5-flash gpt-4o
|
|
168
|
+
|
|
169
|
+
# Single agent mode
|
|
170
|
+
uv run python -m massgen.v1.cli "What is greatest common divisor of 238, 756, and 1512" --models gemini-2.5-flash
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
#### Configuration File Usage
|
|
174
|
+
```bash
|
|
175
|
+
# Use configuration file
|
|
176
|
+
uv run python -m massgen.v1.cli --config examples/fast_config.yaml "find big AI news this week"
|
|
177
|
+
|
|
178
|
+
# Override specific parameters
|
|
179
|
+
uv run python -m massgen.v1.cli --config examples/fast_config.yaml "who will win World Cup 2026" --max-duration 120 --consensus 0.5
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
#### Configuration Parameters
|
|
183
|
+
|
|
184
|
+
| Parameter | Description |
|
|
185
|
+
|-----------|-------------|
|
|
186
|
+
| `--config` | Path to YAML configuration file with agent setup, model parameters, and orchestrator settings |
|
|
187
|
+
| `--models` | Space-separated model names. Single model enables single-agent mode; multiple models enable collaborative multi-agent mode |
|
|
188
|
+
| `--consensus` | Consensus threshold (0.0-1.0) for multi-agent agreement. Unmet thresholds trigger continued debate and refinement |
|
|
189
|
+
| `--max-duration` | Maximum session execution time in seconds before automatic termination |
|
|
190
|
+
| `--max-debates` | Maximum number of debate rounds allowed when agents fail to reach consensus |
|
|
191
|
+
| `--no-display` | Disable real-time streaming display of agent progress |
|
|
192
|
+
| `--no-logs` | Disable automatic session logging to files |
|
|
193
|
+
|
|
194
|
+
**Note**: `--config` and `--models` are mutually exclusive - use one or the other.
|
|
195
|
+
|
|
196
|
+
#### Interactive Multi-turn Mode
|
|
197
|
+
|
|
198
|
+
MassGen supports an interactive mode where you can have ongoing conversations with the system:
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
# Start interactive mode with multiple agents
|
|
202
|
+
uv run python -m massgen.v1.cli --models gpt-4o gemini-2.5-flash grok-3-mini
|
|
203
|
+
|
|
204
|
+
# Start interactive mode with configuration file
|
|
205
|
+
uv run python -m massgen.v1.cli --config examples/fast_config.yaml
|
|
206
|
+
|
|
207
|
+
# Interactive mode with custom parameters
|
|
208
|
+
uv run python -m massgen.v1.cli --models gpt-4o grok-3-mini --consensus 0.7 --max-duration 600
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
**Interactive Mode Features:**
|
|
212
|
+
- **Multi-turn conversations**: Multiple agents collaborate to chat with you in an ongoing conversation
|
|
213
|
+
- **Real-time feedback**: Displays real-time agent and system status
|
|
214
|
+
- **Easy exit**: Type `quit`, `exit`, or press `Ctrl+C` to stop
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
### 5. π View Results
|
|
218
|
+
|
|
219
|
+
The system provides multiple ways to view and analyze results:
|
|
220
|
+
|
|
221
|
+
#### Real-time Display
|
|
222
|
+
- **Live Collaboration View**: See agents working in parallel through a multi-region terminal display
|
|
223
|
+
- **Status Updates**: Real-time phase transitions, voting progress, and consensus building
|
|
224
|
+
- **Streaming Output**: Watch agents' reasoning and responses as they develop
|
|
225
|
+
|
|
226
|
+
#### Comprehensive Logging
|
|
227
|
+
All sessions are automatically logged with detailed information. The file locations are also displayed and clickable in the UI.
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
logs/
|
|
231
|
+
βββ 20250123_142530/ # Session timestamp (YYYYMMDD_HHMMSS)
|
|
232
|
+
βββ answers/
|
|
233
|
+
β βββ agent_1.txt # The proposed answers by agent 1
|
|
234
|
+
β βββ agent_2.txt # The proposed answers by agent 2
|
|
235
|
+
β βββ agent_3.txt # The proposed answers by agent 3
|
|
236
|
+
βββ votes/
|
|
237
|
+
β βββ agent_1.txt # The votes cast by agent 1
|
|
238
|
+
β βββ agent_2.txt # The votes cast by agent 2
|
|
239
|
+
β βββ agent_3.txt # The votes cast by agent 3
|
|
240
|
+
βββ display/
|
|
241
|
+
β βββ agent_1.txt # The full log in the streaming display of agent 1
|
|
242
|
+
β βββ agent_2.txt # The full log in the streaming display of agent 2
|
|
243
|
+
β βββ agent_3.txt # The full log in the streaming display of agent 3
|
|
244
|
+
β βββ system.txt # The full log of system events and phase changes
|
|
245
|
+
βββ console.log # Console output and system messages
|
|
246
|
+
βββ events.jsonl # Orchestrator events and phase changes (JSONL format)
|
|
247
|
+
βββ result.json # Final results and session summary
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
#### Log File Contents
|
|
251
|
+
- **Session Summary**: Final answer, consensus score, voting results, execution time
|
|
252
|
+
- **Agent History**: Complete action and chat history for each agent
|
|
253
|
+
- **System Events**: Phase transitions, restarts, consensus detection of the whole system
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
## π‘ Examples
|
|
258
|
+
|
|
259
|
+
Here are a few examples of how you can use MassGen for different tasks:
|
|
260
|
+
|
|
261
|
+
### Case Studies
|
|
262
|
+
|
|
263
|
+
To see how MassGen works in practice, check out these detailed case studies based on real session logs:
|
|
264
|
+
|
|
265
|
+
- [**MassGen Case Studies**](docs/case_studies/index.md)
|
|
266
|
+
|
|
267
|
+
<!-- Uncomment when we add coding agent support -->
|
|
268
|
+
<!-- ### 1. π Code Generation
|
|
269
|
+
|
|
270
|
+
```bash
|
|
271
|
+
uv run python -m massgen.v1.cli --config examples/fast_config.yaml "Design a logo for MassGen (multi-agent scaling system for GenAI) GitHub README"
|
|
272
|
+
``` -->
|
|
273
|
+
|
|
274
|
+
### 1. β Question Answering
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
# Ask a question about a complex topic
|
|
278
|
+
uv run python -m massgen.v1.cli --config examples/fast_config.yaml "Explain the theory of relativity in simple terms."
|
|
279
|
+
uv run python -m massgen.v1.cli "what's best to do in Stockholm in October 2025" --models gemini-2.5-flash gpt-4o
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
### 2. π§ Creative Writing
|
|
283
|
+
|
|
284
|
+
```bash
|
|
285
|
+
# Generate a short story
|
|
286
|
+
uv run python -m massgen.v1.cli --config examples/fast_config.yaml "Write a short story about a robot who discovers music."
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
### 3. Research
|
|
290
|
+
```bash
|
|
291
|
+
uv run python -m massgen.v1.cli --config examples/fast_config.yaml "How much does it cost to run HLE benchmark with Grok-4"
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
## πΊοΈ Roadmap
|
|
297
|
+
|
|
298
|
+
MassGen is currently in its foundational stage, with a focus on parallel, asynchronous multi-agent collaboration and orchestration. Our roadmap is centered on transforming this foundation into a highly robust, intelligent, and user-friendly system, while enabling frontier research and exploration.
|
|
299
|
+
|
|
300
|
+
### Key Future Enhancements:
|
|
301
|
+
|
|
302
|
+
- **Advanced Agent Collaboration:** Exploring improved communication patterns and consensus-building protocols to improve agent synergy.
|
|
303
|
+
- **Expanded Model, Tool & Agent Integration:** Adding support for more models/tools/agents, including Claude, a wider range of tools like MCP Servers, and coding agents.
|
|
304
|
+
- **Improved Performance & Scalability:** Optimizing the streaming and logging mechanisms for better performance and resource management.
|
|
305
|
+
- **Enhanced Developer Experience:** Introducing a more modular agent design and a comprehensive benchmarking framework for easier extension and evaluation.
|
|
306
|
+
- **Web Interface:** Developing a web-based UI for better visualization and interaction with the agent ecosystem.
|
|
307
|
+
|
|
308
|
+
We welcome community contributions to help us achieve these goals.
|
|
309
|
+
|
|
310
|
+
---
|
|
311
|
+
|
|
312
|
+
## π€ Contributing
|
|
313
|
+
|
|
314
|
+
We welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for details.
|
|
315
|
+
|
|
316
|
+
---
|
|
317
|
+
|
|
318
|
+
## π License
|
|
319
|
+
|
|
320
|
+
This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.
|
|
321
|
+
|
|
322
|
+
---
|
|
323
|
+
|
|
324
|
+
<div align="center">
|
|
325
|
+
|
|
326
|
+
**β Star this repo if you find it useful! β**
|
|
327
|
+
|
|
328
|
+
Made with β€οΈ by the MassGen team
|
|
329
|
+
|
|
330
|
+
</div>
|
massgen/v1/__init__.py
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"""
|
|
2
|
+
MassGen - Multi-Agent Scaling System
|
|
3
|
+
|
|
4
|
+
A powerful multi-agent collaboration framework that enables multiple AI agents
|
|
5
|
+
to work together on complex tasks, share insights, vote on solutions, and reach
|
|
6
|
+
consensus through structured collaboration and debate.
|
|
7
|
+
|
|
8
|
+
The system also supports single-agent mode for simpler tasks that don't require
|
|
9
|
+
multi-agent collaboration.
|
|
10
|
+
|
|
11
|
+
Key Features:
|
|
12
|
+
- Single-agent mode for simple, direct processing
|
|
13
|
+
- Multi-agent collaboration with dynamic restart logic
|
|
14
|
+
- Comprehensive YAML configuration system
|
|
15
|
+
- Real-time streaming display with multi-region layout
|
|
16
|
+
- Robust consensus mechanisms with debate phases
|
|
17
|
+
- Support for multiple LLM backends (OpenAI, Gemini, Grok)
|
|
18
|
+
- Comprehensive logging and monitoring
|
|
19
|
+
|
|
20
|
+
Command-Line Usage:
|
|
21
|
+
# Use massgen.v1.cli for all command-line operations
|
|
22
|
+
|
|
23
|
+
# Single agent mode
|
|
24
|
+
uv run python -m massgen.v1.cli "What is 2+2?" --models gpt-4o
|
|
25
|
+
|
|
26
|
+
# Multi-agent mode
|
|
27
|
+
uv run python -m massgen.v1.cli "What is 2+2?" --models gpt-4o gemini-2.5-flash
|
|
28
|
+
uv run python -m massgen.v1.cli "Complex question" --config examples/production.yaml
|
|
29
|
+
|
|
30
|
+
Programmatic Usage:
|
|
31
|
+
# Using YAML configuration
|
|
32
|
+
from massgen import run_mass_with_config, load_config_from_yaml
|
|
33
|
+
config = load_config_from_yaml("config.yaml")
|
|
34
|
+
result = run_mass_with_config("Your question here", config)
|
|
35
|
+
|
|
36
|
+
# Using simple model list (single agent)
|
|
37
|
+
from massgen import run_mass_agents
|
|
38
|
+
result = run_mass_agents("What is 2+2?", ["gpt-4o"])
|
|
39
|
+
|
|
40
|
+
# Using simple model list (multi-agent)
|
|
41
|
+
from massgen import run_mass_agents
|
|
42
|
+
result = run_mass_agents("What is 2+2?", ["gpt-4o", "gemini-2.5-flash"])
|
|
43
|
+
|
|
44
|
+
"""
|
|
45
|
+
|
|
46
|
+
# Core system components
|
|
47
|
+
from .main import MassSystem, run_mass_agents, run_mass_with_config
|
|
48
|
+
|
|
49
|
+
# Configuration system
|
|
50
|
+
from .config import load_config_from_yaml, create_config_from_models, ConfigurationError
|
|
51
|
+
|
|
52
|
+
# Configuration classes
|
|
53
|
+
from .types import (
|
|
54
|
+
MassConfig,
|
|
55
|
+
OrchestratorConfig,
|
|
56
|
+
AgentConfig,
|
|
57
|
+
ModelConfig,
|
|
58
|
+
StreamingDisplayConfig,
|
|
59
|
+
LoggingConfig,
|
|
60
|
+
TaskInput,
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
# Advanced components (for custom usage)
|
|
64
|
+
from .orchestrator import MassOrchestrator
|
|
65
|
+
from .streaming_display import create_streaming_display
|
|
66
|
+
from .logging import MassLogManager
|
|
67
|
+
|
|
68
|
+
__version__ = "0.0.1"
|
|
69
|
+
|
|
70
|
+
__all__ = [
|
|
71
|
+
# Main interfaces
|
|
72
|
+
"MassSystem",
|
|
73
|
+
"run_mass_agents",
|
|
74
|
+
"run_mass_with_config",
|
|
75
|
+
# Configuration system
|
|
76
|
+
"load_config_from_yaml",
|
|
77
|
+
"create_config_from_models",
|
|
78
|
+
"ConfigurationError",
|
|
79
|
+
# Configuration classes
|
|
80
|
+
"MassConfig",
|
|
81
|
+
"OrchestratorConfig",
|
|
82
|
+
"AgentConfig",
|
|
83
|
+
"ModelConfig",
|
|
84
|
+
"StreamingDisplayConfig",
|
|
85
|
+
"LoggingConfig",
|
|
86
|
+
"TaskInput",
|
|
87
|
+
# Advanced components
|
|
88
|
+
"MassOrchestrator",
|
|
89
|
+
"create_streaming_display",
|
|
90
|
+
"MassLogManager",
|
|
91
|
+
]
|