konsul-ai 0.2.4
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.
- package/LICENSE +21 -0
- package/README.md +99 -0
- package/dist/abort.d.ts +3 -0
- package/dist/abort.js +20 -0
- package/dist/config.d.ts +182 -0
- package/dist/config.js +218 -0
- package/dist/council.d.ts +31 -0
- package/dist/council.js +395 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +616 -0
- package/dist/router.d.ts +61 -0
- package/dist/router.js +268 -0
- package/dist/server.d.ts +6 -0
- package/dist/server.js +233 -0
- package/dist/types.d.ts +52 -0
- package/dist/types.js +1 -0
- package/dist/web/app.js +760 -0
- package/dist/web/index.html +13 -0
- package/dist/web/style.css +554 -0
- package/package.json +48 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Yigit Yargili
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<br/>
|
|
3
|
+
<img src="assets/logo.png" alt="Konsul" width="600"/>
|
|
4
|
+
<br/><br/>
|
|
5
|
+
<p><strong>Ask multiple AI models, have them blind-review each other, get one synthesized answer.</strong></p>
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+

|
|
9
|
+

|
|
10
|
+

|
|
11
|
+

|
|
12
|
+

|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## How It Works
|
|
18
|
+
|
|
19
|
+
Your question goes through a three-stage pipeline:
|
|
20
|
+
|
|
21
|
+
1. **Gather** — all council members answer your question in parallel
|
|
22
|
+
2. **Review** — each model blind-reviews the others (anonymized as A, B, C...) and ranks them
|
|
23
|
+
3. **Synthesize** — the chair model reads all opinions + scores and streams a final answer
|
|
24
|
+
|
|
25
|
+
Models can't see who wrote what, preventing brand-name bias.
|
|
26
|
+
|
|
27
|
+
## Quick Start
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npx konsul-ai "What causes inflation?" # run directly, no install
|
|
31
|
+
# or install globally
|
|
32
|
+
npm install -g konsul-ai
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Set your API key ([openrouter.ai](https://openrouter.ai) — $5 in credits is plenty):
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
export OPENROUTER_API_KEY=sk-or-v1-...
|
|
39
|
+
# or create a .env file in the working directory
|
|
40
|
+
echo "OPENROUTER_API_KEY=sk-or-v1-..." > .env
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
<details><summary>Install from source</summary>
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
git clone https://github.com/yigityargili991/konsul.git
|
|
47
|
+
cd konsul
|
|
48
|
+
npm install && npm run build && npm link
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
</details>
|
|
52
|
+
|
|
53
|
+
## Usage
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
konsul "What causes inflation?" # balanced preset (default)
|
|
57
|
+
konsul --budget "Explain quantum entanglement"
|
|
58
|
+
konsul --premium "Compare Rust vs Go"
|
|
59
|
+
konsul --serve # web UI at localhost:3000
|
|
60
|
+
konsul # interactive REPL
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Presets
|
|
64
|
+
|
|
65
|
+
| Flag | Members | Chair | ~Cost |
|
|
66
|
+
|------|---------|-------|-------|
|
|
67
|
+
| `--free` | Hermes 405B, GPT-OSS 120B, Nemotron 120B, Llama 3.3 70B | Trinity Large | $0 |
|
|
68
|
+
| `--budget` | DeepSeek V3.2, Gemini Flash Lite, Llama 4 Scout, Mistral Small 4 | DeepSeek V3.2 | $0.002 |
|
|
69
|
+
| `--balanced` | DeepSeek V3.2, Gemini Flash, Llama 4 Maverick, GPT-5.4 Mini | Gemini 2.5 Pro | $0.05 |
|
|
70
|
+
| `--premium` | Sonnet 4.6, GPT-5.4, Gemini Pro, DeepSeek R1 | Claude Opus 4.6 | $0.30+ |
|
|
71
|
+
|
|
72
|
+
### Custom Councils
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
konsul --chair opus "Best neuroscience books?"
|
|
76
|
+
konsul --members deepseekV3,sonnet,gpt4o --chair opus "Compare React vs Svelte"
|
|
77
|
+
konsul --chair xiaomi/mimo-v2-pro "Hello" # any OpenRouter model ID works
|
|
78
|
+
konsul --premium --rounds 3 "Is consciousness computable?"
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Interactive Mode
|
|
82
|
+
|
|
83
|
+
Start with `konsul` (no arguments). Commands: `/tier <name>`, `/new-team`, `/web`, `/verbose`, `/clear`, `/quit`.
|
|
84
|
+
|
|
85
|
+
### Other Flags
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
konsul --output result.json "question" # save full results as JSON
|
|
89
|
+
konsul --verbose "question" # show individual opinions
|
|
90
|
+
konsul --models # list available models
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Development
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
npm run dev # run with tsx (no build step)
|
|
97
|
+
npm test # build + run tests
|
|
98
|
+
npm run build # compile TypeScript → dist/
|
|
99
|
+
```
|
package/dist/abort.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function isAbortError(reason: unknown): reason is Error;
|
|
2
|
+
export declare function normalizeAbortReason(reason: unknown, fallbackMessage?: string): DOMException;
|
|
3
|
+
export declare function combineSignals(...signals: (AbortSignal | undefined)[]): AbortSignal | undefined;
|
package/dist/abort.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export function isAbortError(reason) {
|
|
2
|
+
return reason instanceof Error && reason.name === "AbortError";
|
|
3
|
+
}
|
|
4
|
+
export function normalizeAbortReason(reason, fallbackMessage = "Aborted") {
|
|
5
|
+
if (reason instanceof DOMException && reason.name === "AbortError") {
|
|
6
|
+
return reason;
|
|
7
|
+
}
|
|
8
|
+
const message = reason instanceof Error ? (reason.message || fallbackMessage) :
|
|
9
|
+
reason == null ? fallbackMessage :
|
|
10
|
+
String(reason) || fallbackMessage;
|
|
11
|
+
return new DOMException(message, "AbortError");
|
|
12
|
+
}
|
|
13
|
+
export function combineSignals(...signals) {
|
|
14
|
+
const active = signals.filter((signal) => !!signal);
|
|
15
|
+
if (active.length === 0)
|
|
16
|
+
return undefined;
|
|
17
|
+
if (active.length === 1)
|
|
18
|
+
return active[0];
|
|
19
|
+
return AbortSignal.any(active);
|
|
20
|
+
}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import type { CouncilConfig } from "./types.js";
|
|
2
|
+
export declare const MODELS: {
|
|
3
|
+
deepseekV3: {
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
role: "member";
|
|
7
|
+
};
|
|
8
|
+
geminiFlash: {
|
|
9
|
+
id: string;
|
|
10
|
+
label: string;
|
|
11
|
+
role: "member";
|
|
12
|
+
};
|
|
13
|
+
qwen35_27b: {
|
|
14
|
+
id: string;
|
|
15
|
+
label: string;
|
|
16
|
+
role: "member";
|
|
17
|
+
};
|
|
18
|
+
llamaScout: {
|
|
19
|
+
id: string;
|
|
20
|
+
label: string;
|
|
21
|
+
role: "member";
|
|
22
|
+
};
|
|
23
|
+
mistralSmall: {
|
|
24
|
+
id: string;
|
|
25
|
+
label: string;
|
|
26
|
+
role: "member";
|
|
27
|
+
};
|
|
28
|
+
gpt54Nano: {
|
|
29
|
+
id: string;
|
|
30
|
+
label: string;
|
|
31
|
+
role: "member";
|
|
32
|
+
};
|
|
33
|
+
geminiFlashLite: {
|
|
34
|
+
id: string;
|
|
35
|
+
label: string;
|
|
36
|
+
role: "member";
|
|
37
|
+
};
|
|
38
|
+
deepseekR1: {
|
|
39
|
+
id: string;
|
|
40
|
+
label: string;
|
|
41
|
+
role: "member";
|
|
42
|
+
};
|
|
43
|
+
gpt54Mini: {
|
|
44
|
+
id: string;
|
|
45
|
+
label: string;
|
|
46
|
+
role: "member";
|
|
47
|
+
};
|
|
48
|
+
qwen3Max: {
|
|
49
|
+
id: string;
|
|
50
|
+
label: string;
|
|
51
|
+
role: "member";
|
|
52
|
+
};
|
|
53
|
+
llamaMaverick: {
|
|
54
|
+
id: string;
|
|
55
|
+
label: string;
|
|
56
|
+
role: "member";
|
|
57
|
+
};
|
|
58
|
+
gpt4o: {
|
|
59
|
+
id: string;
|
|
60
|
+
label: string;
|
|
61
|
+
role: "member";
|
|
62
|
+
};
|
|
63
|
+
sonnet4: {
|
|
64
|
+
id: string;
|
|
65
|
+
label: string;
|
|
66
|
+
role: "member";
|
|
67
|
+
};
|
|
68
|
+
sonnet46: {
|
|
69
|
+
id: string;
|
|
70
|
+
label: string;
|
|
71
|
+
role: "member";
|
|
72
|
+
};
|
|
73
|
+
geminiPro: {
|
|
74
|
+
id: string;
|
|
75
|
+
label: string;
|
|
76
|
+
role: "chair";
|
|
77
|
+
};
|
|
78
|
+
gpt54: {
|
|
79
|
+
id: string;
|
|
80
|
+
label: string;
|
|
81
|
+
role: "chair";
|
|
82
|
+
};
|
|
83
|
+
gemini31Pro: {
|
|
84
|
+
id: string;
|
|
85
|
+
label: string;
|
|
86
|
+
role: "chair";
|
|
87
|
+
};
|
|
88
|
+
opus: {
|
|
89
|
+
id: string;
|
|
90
|
+
label: string;
|
|
91
|
+
role: "chair";
|
|
92
|
+
};
|
|
93
|
+
gpt52: {
|
|
94
|
+
id: string;
|
|
95
|
+
label: string;
|
|
96
|
+
role: "chair";
|
|
97
|
+
};
|
|
98
|
+
hermes405b: {
|
|
99
|
+
id: string;
|
|
100
|
+
label: string;
|
|
101
|
+
role: "member";
|
|
102
|
+
};
|
|
103
|
+
gptOss120b: {
|
|
104
|
+
id: string;
|
|
105
|
+
label: string;
|
|
106
|
+
role: "member";
|
|
107
|
+
};
|
|
108
|
+
nemotron120b: {
|
|
109
|
+
id: string;
|
|
110
|
+
label: string;
|
|
111
|
+
role: "member";
|
|
112
|
+
};
|
|
113
|
+
llama70b: {
|
|
114
|
+
id: string;
|
|
115
|
+
label: string;
|
|
116
|
+
role: "member";
|
|
117
|
+
};
|
|
118
|
+
trinityLarge: {
|
|
119
|
+
id: string;
|
|
120
|
+
label: string;
|
|
121
|
+
role: "chair";
|
|
122
|
+
};
|
|
123
|
+
gemma27b: {
|
|
124
|
+
id: string;
|
|
125
|
+
label: string;
|
|
126
|
+
role: "member";
|
|
127
|
+
};
|
|
128
|
+
mistralSmall31: {
|
|
129
|
+
id: string;
|
|
130
|
+
label: string;
|
|
131
|
+
role: "member";
|
|
132
|
+
};
|
|
133
|
+
stepFlash: {
|
|
134
|
+
id: string;
|
|
135
|
+
label: string;
|
|
136
|
+
role: "member";
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
export declare const FALLBACKS: Record<string, string>;
|
|
140
|
+
/** Look up a human-readable label for a model ID. */
|
|
141
|
+
export declare function labelFor(modelId: string): string;
|
|
142
|
+
/**
|
|
143
|
+
* ~$0.002 per council run. All ultra-cheap models.
|
|
144
|
+
* Members: DeepSeek V3.2, Gemini 2.5 Flash Lite, Llama 4 Scout, Mistral Small 4
|
|
145
|
+
* Chair: DeepSeek V3.2 (best reasoning at this price point)
|
|
146
|
+
*
|
|
147
|
+
* Academic strengths: DeepSeek V3.2 has IMO gold-medal reasoning; Llama 4 Scout
|
|
148
|
+
* provides massive context for long papers; diversity across 4 different providers.
|
|
149
|
+
*/
|
|
150
|
+
export declare const PRESET_BUDGET: CouncilConfig;
|
|
151
|
+
/**
|
|
152
|
+
* ~$0.05 per run. Cheap members with a strong frontier chair.
|
|
153
|
+
* Members: DeepSeek V3.2, Gemini 2.5 Flash, Llama 4 Maverick, GPT-5.4 Mini
|
|
154
|
+
* Chair: Gemini 2.5 Pro (#1 LMArena, $1.25/$10)
|
|
155
|
+
*
|
|
156
|
+
* Academic strengths: Four diverse reasoning engines feed into Gemini 2.5 Pro,
|
|
157
|
+
* which excels at scientific reasoning and synthesis. Best bang for buck.
|
|
158
|
+
*/
|
|
159
|
+
export declare const PRESET_BALANCED: CouncilConfig;
|
|
160
|
+
/**
|
|
161
|
+
* ~$0.30+ per run. Frontier models everywhere.
|
|
162
|
+
* Members: Claude Sonnet 4.6, GPT-5.4, Gemini 2.5 Pro, DeepSeek R1
|
|
163
|
+
* Chair: Claude Opus 4.6 (#1 Chatbot Arena Elo 1505, best synthesis)
|
|
164
|
+
*
|
|
165
|
+
* Academic strengths: Every member is a top-10 reasoning model. DeepSeek R1
|
|
166
|
+
* provides explicit chain-of-thought reasoning. Claude Opus 4.6 as chair
|
|
167
|
+
* produces the most polished, well-structured academic prose. 2 review rounds
|
|
168
|
+
* for maximum quality.
|
|
169
|
+
*/
|
|
170
|
+
export declare const PRESET_PREMIUM: CouncilConfig;
|
|
171
|
+
/**
|
|
172
|
+
* $0 per run. All free OpenRouter models.
|
|
173
|
+
* Members: Hermes 405B, GPT-OSS 120B, Nemotron 120B, Llama 3.3 70B
|
|
174
|
+
* Chair: Trinity Large (400B MoE)
|
|
175
|
+
*
|
|
176
|
+
* Academic strengths: Hermes 405B is the largest free model; GPT-OSS 120B
|
|
177
|
+
* and Nemotron 120B provide diversity; Trinity Large chairs with frontier-scale
|
|
178
|
+
* MoE reasoning. Rate-limited but zero cost.
|
|
179
|
+
*/
|
|
180
|
+
export declare const PRESET_FREE: CouncilConfig;
|
|
181
|
+
export declare const PRESETS: Record<string, CouncilConfig>;
|
|
182
|
+
export declare const DEFAULT_PRESET = "balanced";
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
// ── Model catalog ──────────────────────────────────────────────
|
|
2
|
+
// Verified against OpenRouter API — March 2026.
|
|
3
|
+
// Prices are per million tokens (input/output).
|
|
4
|
+
// The `id` is the exact OpenRouter model string.
|
|
5
|
+
//
|
|
6
|
+
// Selection criteria for academic research:
|
|
7
|
+
// - Reasoning benchmarks (GPQA, AIME, MATH-500, MMLU-Pro)
|
|
8
|
+
// - Factual accuracy & citation awareness
|
|
9
|
+
// - Clear, structured academic writing
|
|
10
|
+
// - LMSYS Chatbot Arena rankings (March 2026)
|
|
11
|
+
export const MODELS = {
|
|
12
|
+
// ── Budget tier ──────────────────────────────────────────────
|
|
13
|
+
// Ultra-cheap models that still score well on reasoning benchmarks.
|
|
14
|
+
// DeepSeek V3.2 — $0.26/$0.38 — 164K ctx — IMO/IOI gold medal reasoning,
|
|
15
|
+
// GPT-5-class benchmarks. Best value reasoning model available.
|
|
16
|
+
deepseekV3: { id: "deepseek/deepseek-v3.2", label: "DeepSeek V3.2", role: "member" },
|
|
17
|
+
// Gemini 2.5 Flash — $0.30/$2.50 — 1M ctx — Google's fast reasoning model
|
|
18
|
+
// with thinking capabilities. Strong on GPQA and MATH-500.
|
|
19
|
+
geminiFlash: { id: "google/gemini-2.5-flash", label: "Gemini 2.5 Flash", role: "member" },
|
|
20
|
+
// Qwen3.5 27B — $0.195/$1.56 — 262K ctx — Dense vision-language model
|
|
21
|
+
// with reasoning support. Strong multilingual academic coverage.
|
|
22
|
+
qwen35_27b: { id: "qwen/qwen3.5-27b", label: "Qwen3.5 27B", role: "member" },
|
|
23
|
+
// Llama 4 Scout — $0.08/$0.30 — 328K ctx — Meta's MoE model (17B active /
|
|
24
|
+
// 109B total). Strong general knowledge, massive context window.
|
|
25
|
+
llamaScout: { id: "meta-llama/llama-4-scout", label: "Llama 4 Scout", role: "member" },
|
|
26
|
+
// Mistral Small 4 — $0.15/$0.60 — 262K ctx — Combines Magistral reasoning
|
|
27
|
+
// + Pixtral multimodal. Great cheap all-rounder (March 2026 release).
|
|
28
|
+
mistralSmall: { id: "mistralai/mistral-small-2603", label: "Mistral Small 4", role: "member" },
|
|
29
|
+
// GPT-5.4 Nano — $0.20/$1.25 — 400K ctx — OpenAI's cheapest 5-series model.
|
|
30
|
+
// Configurable reasoning effort. Good for high-volume member role.
|
|
31
|
+
gpt54Nano: { id: "openai/gpt-5.4-nano", label: "GPT-5.4 Nano", role: "member" },
|
|
32
|
+
// Gemini 2.5 Flash Lite — $0.10/$0.40 — 1M ctx — Cheapest Google model
|
|
33
|
+
// with optional reasoning. Ultra-fast, decent quality.
|
|
34
|
+
geminiFlashLite: { id: "google/gemini-2.5-flash-lite", label: "Gemini 2.5 Flash Lite", role: "member" },
|
|
35
|
+
// ── Mid tier ─────────────────────────────────────────────────
|
|
36
|
+
// Strong models at moderate cost — good as members or budget chairs.
|
|
37
|
+
// DeepSeek R1 0528 — $0.45/$2.15 — 164K ctx — Dedicated reasoning model
|
|
38
|
+
// with open chain-of-thought. On par with OpenAI o1 on math/science.
|
|
39
|
+
deepseekR1: { id: "deepseek/deepseek-r1-0528", label: "DeepSeek R1", role: "member" },
|
|
40
|
+
// GPT-5.4 Mini — $0.75/$4.50 — 400K ctx — Core GPT-5.4 capabilities at
|
|
41
|
+
// half the price. Strong reasoning with configurable effort levels.
|
|
42
|
+
gpt54Mini: { id: "openai/gpt-5.4-mini", label: "GPT-5.4 Mini", role: "member" },
|
|
43
|
+
// Qwen3 Max Thinking — $0.78/$3.90 — 262K ctx — Flagship Qwen reasoning
|
|
44
|
+
// model. Deep multi-step reasoning via reinforcement learning.
|
|
45
|
+
qwen3Max: { id: "qwen/qwen3-max-thinking", label: "Qwen3 Max", role: "member" },
|
|
46
|
+
// Llama 4 Maverick — $0.15/$0.60 — 1M ctx — Meta's large MoE (17B active /
|
|
47
|
+
// 400B total, 128 experts). Excellent multilingual + multimodal.
|
|
48
|
+
llamaMaverick: { id: "meta-llama/llama-4-maverick", label: "Llama 4 Maverick", role: "member" },
|
|
49
|
+
// ── Strong tier ──────────────────────────────────────────────
|
|
50
|
+
// Frontier models — best as chair or premium members.
|
|
51
|
+
// GPT-4o — $2.50/$10 — 128K ctx — Still a solid frontier model, now
|
|
52
|
+
// cheaper than newer GPT-5 variants. Good mid-price chair.
|
|
53
|
+
gpt4o: { id: "openai/gpt-4o", label: "GPT-4o", role: "member" },
|
|
54
|
+
// Claude Sonnet 4 — $3/$15 — 200K ctx — Anthropic's workhorse.
|
|
55
|
+
// Top-tier instruction following and structured academic writing.
|
|
56
|
+
sonnet4: { id: "anthropic/claude-sonnet-4", label: "Claude Sonnet 4", role: "member" },
|
|
57
|
+
// Claude Sonnet 4.6 — $3/$15 — 1M ctx — Latest Sonnet with 1M context.
|
|
58
|
+
// Frontier coding + reasoning. Excellent for academic synthesis.
|
|
59
|
+
sonnet46: { id: "anthropic/claude-sonnet-4.6", label: "Claude Sonnet 4.6", role: "member" },
|
|
60
|
+
// Gemini 2.5 Pro — $1.25/$10 — 1M ctx — #1 on LMArena leaderboard.
|
|
61
|
+
// Top-tier reasoning across math, science, and coding benchmarks.
|
|
62
|
+
geminiPro: { id: "google/gemini-2.5-pro", label: "Gemini 2.5 Pro", role: "chair" },
|
|
63
|
+
// GPT-5.4 — $2.50/$15 — 400K ctx — OpenAI's latest unified frontier model
|
|
64
|
+
// (March 2026). Strong across all academic reasoning benchmarks.
|
|
65
|
+
gpt54: { id: "openai/gpt-5.4", label: "GPT-5.4", role: "chair" },
|
|
66
|
+
// Gemini 3.1 Pro — $2/$12 — 1M ctx — Google's frontier reasoning model
|
|
67
|
+
// (March 2026). #1 high-Elo on Chatbot Arena. Enhanced agentic reliability.
|
|
68
|
+
gemini31Pro: { id: "google/gemini-3.1-pro-preview", label: "Gemini 3.1 Pro", role: "chair" },
|
|
69
|
+
// Claude Opus 4.6 — $5/$25 — 200K ctx — Anthropic's most capable model.
|
|
70
|
+
// #1 on Chatbot Arena (Elo 1505). Best for complex academic synthesis.
|
|
71
|
+
opus: { id: "anthropic/claude-opus-4.6", label: "Claude Opus 4.6", role: "chair" },
|
|
72
|
+
// GPT-5.2 — $1.75/$14 — 400K ctx — Strong frontier model, statistical
|
|
73
|
+
// dead heat with Claude 4.6 for #1 on general Arena rankings.
|
|
74
|
+
gpt52: { id: "openai/gpt-5.2", label: "GPT-5.2", role: "chair" },
|
|
75
|
+
// ── Free tier ───────────────────────────────────────────────
|
|
76
|
+
// OpenRouter free models ($0/$0). Rate-limited but zero cost.
|
|
77
|
+
// Best picks for academic research from the free pool.
|
|
78
|
+
// Hermes 3 Llama 3.1 405B — 405B params, 131K ctx — Largest free model.
|
|
79
|
+
// Strong general knowledge and reasoning via enhanced agentic tuning.
|
|
80
|
+
hermes405b: { id: "nousresearch/hermes-3-llama-3.1-405b:free", label: "Hermes 405B", role: "member" },
|
|
81
|
+
// GPT-OSS 120B — 117B MoE, 131K ctx — OpenAI open-weight model.
|
|
82
|
+
// High reasoning benchmarks, good structured output.
|
|
83
|
+
gptOss120b: { id: "openai/gpt-oss-120b:free", label: "GPT-OSS 120B", role: "member" },
|
|
84
|
+
// Nemotron 120B — 120B MoE (12B active), 262K ctx — Large context,
|
|
85
|
+
// compute-efficient. Strong accuracy on academic benchmarks.
|
|
86
|
+
nemotron120b: { id: "nvidia/nemotron-3-super-120b-a12b:free", label: "Nemotron 120B", role: "member" },
|
|
87
|
+
// Llama 3.3 70B — 70B params, 65K ctx — Solid reasoning,
|
|
88
|
+
// well-tested, strong multilingual coverage.
|
|
89
|
+
llama70b: { id: "meta-llama/llama-3.3-70b-instruct:free", label: "Llama 3.3 70B", role: "member" },
|
|
90
|
+
// Trinity Large — 400B MoE, 131K ctx — Frontier-scale sparse MoE.
|
|
91
|
+
// Strong general reasoning, good as a free chair.
|
|
92
|
+
trinityLarge: { id: "arcee-ai/trinity-large-preview:free", label: "Trinity Large", role: "chair" },
|
|
93
|
+
// ── Free fallback-only models ──────────────────────────────
|
|
94
|
+
// Not in presets, but available as fallback targets from different providers.
|
|
95
|
+
// Gemma 3 27B — Google, 27B params, 131K ctx — Best Google free model.
|
|
96
|
+
gemma27b: { id: "google/gemma-3-27b-it:free", label: "Gemma 3 27B", role: "member" },
|
|
97
|
+
// Mistral Small 3.1 — Mistral, 24B params, 128K ctx — Solid all-rounder.
|
|
98
|
+
mistralSmall31: { id: "mistralai/mistral-small-3.1-24b-instruct:free", label: "Mistral Small 3.1", role: "member" },
|
|
99
|
+
// Step 3.5 Flash — StepFun, MoE, 256K ctx — Large context, strong reasoning.
|
|
100
|
+
stepFlash: { id: "stepfun/step-3.5-flash:free", label: "Step 3.5 Flash", role: "member" },
|
|
101
|
+
};
|
|
102
|
+
// ── Fallback models ───────────────────────────────────────────────
|
|
103
|
+
// When a model fails or times out, retry with a different-provider alternative.
|
|
104
|
+
// Each mapping targets a model at a similar tier from another provider.
|
|
105
|
+
export const FALLBACKS = {
|
|
106
|
+
// Budget → cross-provider fallbacks
|
|
107
|
+
"deepseek/deepseek-v3.2": "meta-llama/llama-4-maverick",
|
|
108
|
+
"google/gemini-2.5-flash": "openai/gpt-5.4-nano",
|
|
109
|
+
"qwen/qwen3.5-27b": "mistralai/mistral-small-2603",
|
|
110
|
+
"meta-llama/llama-4-scout": "mistralai/mistral-small-2603",
|
|
111
|
+
"mistralai/mistral-small-2603": "meta-llama/llama-4-scout",
|
|
112
|
+
"openai/gpt-5.4-nano": "google/gemini-2.5-flash",
|
|
113
|
+
"google/gemini-2.5-flash-lite": "meta-llama/llama-4-scout",
|
|
114
|
+
// Mid → cross-provider fallbacks
|
|
115
|
+
"deepseek/deepseek-r1-0528": "qwen/qwen3-max-thinking",
|
|
116
|
+
"openai/gpt-5.4-mini": "google/gemini-2.5-flash",
|
|
117
|
+
"qwen/qwen3-max-thinking": "deepseek/deepseek-r1-0528",
|
|
118
|
+
"meta-llama/llama-4-maverick": "deepseek/deepseek-v3.2",
|
|
119
|
+
// Strong → cross-provider fallbacks
|
|
120
|
+
"openai/gpt-4o": "openai/gpt-5.4-mini",
|
|
121
|
+
"anthropic/claude-sonnet-4": "openai/gpt-5.4",
|
|
122
|
+
"anthropic/claude-sonnet-4.6": "openai/gpt-5.4",
|
|
123
|
+
"google/gemini-2.5-pro": "google/gemini-3.1-pro-preview",
|
|
124
|
+
"openai/gpt-5.4": "google/gemini-2.5-pro",
|
|
125
|
+
"google/gemini-3.1-pro-preview": "google/gemini-2.5-pro",
|
|
126
|
+
"anthropic/claude-opus-4.6": "openai/gpt-5.4",
|
|
127
|
+
"openai/gpt-5.2": "google/gemini-2.5-pro",
|
|
128
|
+
// Free → free fallbacks (no circular chains, always cross-provider)
|
|
129
|
+
// Venice-hosted models (Hermes, Llama 3.3) fall back to Google/Mistral/Qwen
|
|
130
|
+
"nousresearch/hermes-3-llama-3.1-405b:free": "google/gemma-3-27b-it:free",
|
|
131
|
+
"meta-llama/llama-3.3-70b-instruct:free": "mistralai/mistral-small-3.1-24b-instruct:free",
|
|
132
|
+
// NVIDIA/OpenAI free models fall back to Qwen/Google
|
|
133
|
+
"openai/gpt-oss-120b:free": "stepfun/step-3.5-flash:free",
|
|
134
|
+
"nvidia/nemotron-3-super-120b-a12b:free": "google/gemma-3-27b-it:free",
|
|
135
|
+
// Chair & fallback-only models → different providers
|
|
136
|
+
"arcee-ai/trinity-large-preview:free": "stepfun/step-3.5-flash:free",
|
|
137
|
+
"google/gemma-3-27b-it:free": "mistralai/mistral-small-3.1-24b-instruct:free",
|
|
138
|
+
"mistralai/mistral-small-3.1-24b-instruct:free": "stepfun/step-3.5-flash:free",
|
|
139
|
+
"stepfun/step-3.5-flash:free": "nvidia/nemotron-3-super-120b-a12b:free",
|
|
140
|
+
};
|
|
141
|
+
/** Look up a human-readable label for a model ID. */
|
|
142
|
+
export function labelFor(modelId) {
|
|
143
|
+
const entry = Object.values(MODELS).find((m) => m.id === modelId);
|
|
144
|
+
if (entry)
|
|
145
|
+
return entry.label;
|
|
146
|
+
const name = modelId.split("/").pop() ?? modelId;
|
|
147
|
+
return name.replace(/:free$/, "").replace(/-/g, " ").replace(/\b\w/g, (ch) => ch.toUpperCase());
|
|
148
|
+
}
|
|
149
|
+
// ── Presets ─────────────────────────────────────────────────────
|
|
150
|
+
// Cost estimates assume ~1500 input + ~800 output tokens per member call,
|
|
151
|
+
// ~3000 input + ~500 output per review call, and ~5000 input + ~2000 output
|
|
152
|
+
// for the chair synthesis. Total ≈ 4 member + 4 review + 1 synthesis calls.
|
|
153
|
+
/**
|
|
154
|
+
* ~$0.002 per council run. All ultra-cheap models.
|
|
155
|
+
* Members: DeepSeek V3.2, Gemini 2.5 Flash Lite, Llama 4 Scout, Mistral Small 4
|
|
156
|
+
* Chair: DeepSeek V3.2 (best reasoning at this price point)
|
|
157
|
+
*
|
|
158
|
+
* Academic strengths: DeepSeek V3.2 has IMO gold-medal reasoning; Llama 4 Scout
|
|
159
|
+
* provides massive context for long papers; diversity across 4 different providers.
|
|
160
|
+
*/
|
|
161
|
+
export const PRESET_BUDGET = {
|
|
162
|
+
members: [MODELS.deepseekV3, MODELS.geminiFlashLite, MODELS.llamaScout, MODELS.mistralSmall],
|
|
163
|
+
chair: MODELS.deepseekV3,
|
|
164
|
+
rounds: 1,
|
|
165
|
+
temperature: 0.7,
|
|
166
|
+
};
|
|
167
|
+
/**
|
|
168
|
+
* ~$0.05 per run. Cheap members with a strong frontier chair.
|
|
169
|
+
* Members: DeepSeek V3.2, Gemini 2.5 Flash, Llama 4 Maverick, GPT-5.4 Mini
|
|
170
|
+
* Chair: Gemini 2.5 Pro (#1 LMArena, $1.25/$10)
|
|
171
|
+
*
|
|
172
|
+
* Academic strengths: Four diverse reasoning engines feed into Gemini 2.5 Pro,
|
|
173
|
+
* which excels at scientific reasoning and synthesis. Best bang for buck.
|
|
174
|
+
*/
|
|
175
|
+
export const PRESET_BALANCED = {
|
|
176
|
+
members: [MODELS.deepseekV3, MODELS.geminiFlash, MODELS.llamaMaverick, MODELS.gpt54Mini],
|
|
177
|
+
chair: MODELS.geminiPro,
|
|
178
|
+
rounds: 1,
|
|
179
|
+
temperature: 0.7,
|
|
180
|
+
};
|
|
181
|
+
/**
|
|
182
|
+
* ~$0.30+ per run. Frontier models everywhere.
|
|
183
|
+
* Members: Claude Sonnet 4.6, GPT-5.4, Gemini 2.5 Pro, DeepSeek R1
|
|
184
|
+
* Chair: Claude Opus 4.6 (#1 Chatbot Arena Elo 1505, best synthesis)
|
|
185
|
+
*
|
|
186
|
+
* Academic strengths: Every member is a top-10 reasoning model. DeepSeek R1
|
|
187
|
+
* provides explicit chain-of-thought reasoning. Claude Opus 4.6 as chair
|
|
188
|
+
* produces the most polished, well-structured academic prose. 2 review rounds
|
|
189
|
+
* for maximum quality.
|
|
190
|
+
*/
|
|
191
|
+
export const PRESET_PREMIUM = {
|
|
192
|
+
members: [MODELS.sonnet46, MODELS.gpt54, MODELS.geminiPro, MODELS.deepseekR1],
|
|
193
|
+
chair: MODELS.opus,
|
|
194
|
+
rounds: 2,
|
|
195
|
+
temperature: 0.5,
|
|
196
|
+
};
|
|
197
|
+
/**
|
|
198
|
+
* $0 per run. All free OpenRouter models.
|
|
199
|
+
* Members: Hermes 405B, GPT-OSS 120B, Nemotron 120B, Llama 3.3 70B
|
|
200
|
+
* Chair: Trinity Large (400B MoE)
|
|
201
|
+
*
|
|
202
|
+
* Academic strengths: Hermes 405B is the largest free model; GPT-OSS 120B
|
|
203
|
+
* and Nemotron 120B provide diversity; Trinity Large chairs with frontier-scale
|
|
204
|
+
* MoE reasoning. Rate-limited but zero cost.
|
|
205
|
+
*/
|
|
206
|
+
export const PRESET_FREE = {
|
|
207
|
+
members: [MODELS.hermes405b, MODELS.gptOss120b, MODELS.nemotron120b, MODELS.llama70b],
|
|
208
|
+
chair: MODELS.trinityLarge,
|
|
209
|
+
rounds: 1,
|
|
210
|
+
temperature: 0.7,
|
|
211
|
+
};
|
|
212
|
+
export const PRESETS = {
|
|
213
|
+
free: PRESET_FREE,
|
|
214
|
+
budget: PRESET_BUDGET,
|
|
215
|
+
balanced: PRESET_BALANCED,
|
|
216
|
+
premium: PRESET_PREMIUM,
|
|
217
|
+
};
|
|
218
|
+
export const DEFAULT_PRESET = "balanced";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { CouncilConfig, CouncilResult, Opinion, Review, RouterMessage } from "./types.js";
|
|
2
|
+
import { Router } from "./router.js";
|
|
3
|
+
export declare class Council {
|
|
4
|
+
private router;
|
|
5
|
+
private config;
|
|
6
|
+
private log;
|
|
7
|
+
private onStream?;
|
|
8
|
+
private history;
|
|
9
|
+
constructor(router: Router, config: CouncilConfig, log?: (msg: string) => void, onStream?: (chunk: string) => void);
|
|
10
|
+
get streaming(): boolean;
|
|
11
|
+
private get webPlugins();
|
|
12
|
+
/** Auto-stagger free models to avoid rate-limit storms. */
|
|
13
|
+
private get staggerMs();
|
|
14
|
+
toggleWeb(): boolean;
|
|
15
|
+
clearHistory(): void;
|
|
16
|
+
getHistory(): RouterMessage[];
|
|
17
|
+
setHistory(history: RouterMessage[]): void;
|
|
18
|
+
/** Drop oldest user/assistant pairs until history fits within the token budget. */
|
|
19
|
+
private trimHistory;
|
|
20
|
+
/** Try fn with model; on failure, retry once with the configured fallback. */
|
|
21
|
+
private withFallback;
|
|
22
|
+
run(query: string, signal?: AbortSignal): Promise<CouncilResult>;
|
|
23
|
+
private gatherOpinions;
|
|
24
|
+
private peerReview;
|
|
25
|
+
private synthesize;
|
|
26
|
+
}
|
|
27
|
+
export declare function aggregateScores(opinions: Opinion[], reviews: Review[]): {
|
|
28
|
+
modelId: string;
|
|
29
|
+
label: string;
|
|
30
|
+
avgRank: number;
|
|
31
|
+
}[];
|