┌─────────────────────────────────────────────────────────────┐
│ SwarmCore Engine │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
│ │ Agent 1 │ │ Agent 2 │ │ Agent 3 │ │ Agent N │ │
│ │ Analyst │ │ Critic │ │ Expert │ │ Synth. │ │
│ └────┬─────┘ └────┬─────┘ └────┬─────┘ └────┬─────┘ │
│ └──────────────┴──────┬───────┴──────────────┘ │
│ │ │
│ ┌──────────┐ ┌─────────▼─────────┐ ┌──────────┐ │
│ │ RAG │◄───│ Swarm Engine │───►│ Stream │ │
│ │ Pipeline │ │ (Round Manager) │ │ (SSE) │ │
│ └──────────┘ └─────────┬─────────┘ └──────────┘ │
│ │ │
│ ┌─────────────┼─────────────┐ │
│ │ │ │ │
│ ┌───────────▼──┐ ┌──────▼───────┐ ┌─▼────────────┐ │
│ │ AI Judge │ │ Autoresearch │ │ HITL │ │
│ │ (Swarm Score)│ │ (OPRO + │ │ Controller │ │
│ │ 0-100 │ │ ProTeGi) │ │ │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
│ │
│ ┌──────────────────────────────────────────────────┐ │
│ │ Synthesis Report Generator │ │
│ │ (Markdown + Mermaid Diagrams + Score Tracking) │ │
│ └──────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
1!pip install -q openai faiss-cpu sentence-transformers numpy
2
3# Clone the repo
4!git clone https://huggingface.co/theuveskhan/swarmcore
5%cd swarmcore
6
7import os
8os.environ['HF_TOKEN'] = 'your-token-here'
9
10from swarmcore import Swarm, Agent, AgentPersona, SwarmConfig
11from swarmcore.llm import LLMClient, LLMConfig
12from swarmcore.judge import SwarmJudge
13from swarmcore.streaming import SwarmStream
14
15# Setup LLM (no GPU needed — uses HF Inference API)
16llm = LLMClient(LLMConfig(model='Qwen/Qwen2.5-72B-Instruct', provider='novita'))
17
18# Define agents with different personas
19agents = [
20 Agent(AgentPersona(name='Analyst', role='Strategic Analyst',
21 system_prompt='You analyze through economic and systems-thinking lenses.',
22 contentious_level=0.4), llm),
23 Agent(AgentPersona(name='Critic', role="Devil's Advocate",
24 system_prompt='You stress-test every assumption and find counter-evidence.',
25 contentious_level=0.9), llm),
26 Agent(AgentPersona(name='Synthesizer', role='Synthesis Lead',
27 system_prompt='You weave perspectives into actionable conclusions.',
28 contentious_level=0.2), llm),
29]
30
31# Run the swarm with AI judge and streaming
32judge = SwarmJudge(llm=llm)
33stream = SwarmStream(mode='terminal')
34
35swarm = Swarm(agents=agents, llm=llm, judge=judge,
36 config=SwarmConfig(max_rounds=3))
37swarm.add_callback(stream.callback)
38
39results = swarm.run("What are the implications of AI agents for software engineering?")
openai>=1.0
faiss-cpu
sentence-transformers
numpy