fugusashi 0.3.0__tar.gz

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.
@@ -0,0 +1,402 @@
1
+ Metadata-Version: 2.4
2
+ Name: fugusashi
3
+ Version: 0.3.0
4
+ Summary: Open-source intelligent model router and multi-agent orchestrator. The open alternative to Sakana AI's Fugu.
5
+ Author-email: eulogik <gautam@eulogik.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://eulogik.com
8
+ Project-URL: Documentation, https://eulogik.github.io/fugusashi/
9
+ Project-URL: Repository, https://github.com/eulogik/fugusashi
10
+ Project-URL: Issues, https://github.com/eulogik/fugusashi/issues
11
+ Project-URL: Changelog, https://github.com/eulogik/fugusashi/blob/main/LIVING.md
12
+ Keywords: llm,model-router,ai,open-source,orchestrator,litellm,ollama
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
21
+ Requires-Python: >=3.12
22
+ Description-Content-Type: text/markdown
23
+ Requires-Dist: litellm<2.0,>=1.60
24
+ Requires-Dist: fastapi<1.0,>=0.115
25
+ Requires-Dist: uvicorn[standard]<1.0,>=0.34
26
+ Requires-Dist: pydantic<3.0,>=2.10
27
+ Requires-Dist: pydantic-settings<3.0,>=2.7
28
+ Requires-Dist: sentence-transformers<4.0,>=3.4
29
+ Requires-Dist: numpy<2.0,>=1.26
30
+ Requires-Dist: pyyaml<7.0,>=6.0
31
+ Requires-Dist: click<9.0,>=8.1
32
+ Requires-Dist: httpx<1.0,>=0.28
33
+ Requires-Dist: rich<14.0,>=13.9
34
+
35
+ <div align="center">
36
+
37
+ <!-- SHIELD.IO BADGES -->
38
+ [![PyPI version](https://img.shields.io/pypi/v/fugusashi?color=6366f1&label=pypi&logo=pypi&logoColor=white)](https://pypi.org/project/fugusashi/)
39
+ [![Python](https://img.shields.io/badge/python-3.12+-blue.svg?logo=python&logoColor=white)](https://python.org)
40
+ [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
41
+ [![GitHub stars](https://img.shields.io/github/stars/eulogik/fugusashi?style=social)](https://github.com/eulogik/fugusashi/stargazers)
42
+ [![Docs](https://img.shields.io/badge/docs-eulogik.github.io-fugusashi-blue.svg)](https://eulogik.github.io/fugusashi/)
43
+ [![Website](https://img.shields.io/badge/website-eulogik.com-6366f1.svg)](https://eulogik.com)
44
+
45
+ **By [eulogik](https://eulogik.com) — building AI infrastructure for everyone.**
46
+
47
+ ---
48
+
49
+ # Fugusashi
50
+
51
+ ### The Open-Source Alternative to Sakana AI's Fugu
52
+
53
+ *Fugusashi* (Japanese: 不縛 — "unbound, unrestrained") is an intelligent model router and multi-agent orchestrator. It automatically picks the best AI model for each prompt, learns from every request, and runs entirely on your infrastructure.
54
+
55
+ **[Live Demo](https://eulogik.github.io/fugusashi/) · [Docs](https://eulogik.github.io/fugusashi/) · [PyPI](https://pypi.org/project/fugusashi/) · [GitHub](https://github.com/eulogik/fugusashi)**
56
+
57
+ </div>
58
+
59
+ ---
60
+
61
+ ## Why Fugusashi?
62
+
63
+ Sakana AI's [Fugu](https://sakana.ai/fugu) is a proprietary model router. It works — but you can't see inside it, you can't train it on your own data, you can't self-host it, and you pay $5-30 per million tokens.
64
+
65
+ **Fugusashi does everything Fugu does, but open, transparent, and self-hosting.** It also adds a feedback loop that Fugu doesn't have — the router learns from every request and gets smarter over time.
66
+
67
+ ### Fugusashi vs Sakana AI Fugu
68
+
69
+ | Feature | Sakana Fugu | Fugusashi |
70
+ |---|---|---|
71
+ | **Model Routing** | ✅ Proprietary | ✅ Open, transparent |
72
+ | **Multi-Agent Orchestration** | ✅ Fugu Ultra | 🔄 Phase 2 |
73
+ | **Self-Hosting** | ❌ Cloud-only | ✅ Local-first, air-gapped |
74
+ | **Cost** | $5-30/M tokens | ✅ Free (pay only for model APIs) |
75
+ | **Transparency** | ❌ Black box | ✅ Every decision visible |
76
+ | **Feedback Loop** | ❌ Static | ✅ Learns from every request |
77
+ | **Model Pool** | ❌ Fixed by Sakana | ✅ You control |
78
+ | **Training Data** | ❌ Proprietary | ✅ Community + your traffic |
79
+ | **Customization** | ❌ None | ✅ Fine-tune on your data |
80
+ | **License** | Proprietary | ✅ MIT |
81
+ | **Dashboard** | ❌ | ✅ Open web dashboard |
82
+ | **API** | Limited | ✅ OpenAI-compatible |
83
+
84
+ ---
85
+
86
+ ## Quickstart
87
+
88
+ ### Install from PyPI
89
+
90
+ ```bash
91
+ pip install fugusashi
92
+ ```
93
+
94
+ ### Or install from source
95
+
96
+ ```bash
97
+ git clone https://github.com/eulogik/fugusashi.git
98
+ cd fugusashi
99
+ python3 -m venv .venv
100
+ source .venv/bin/activate
101
+ pip install -e .
102
+ ```
103
+
104
+ ### Configure
105
+
106
+ Edit `config.yaml` to add your models:
107
+
108
+ ```yaml
109
+ default_model: "llama3.2-local"
110
+
111
+ models:
112
+ - name: "llama3.2-local"
113
+ provider: "ollama"
114
+ model: "llama3.2:1b"
115
+ api_base: "http://localhost:11434"
116
+ cost_per_input_token: 0.0
117
+ cost_per_output_token: 0.0
118
+ capabilities: ["chat", "reasoning"]
119
+ description: "Llama 3.2 1B (local, free)"
120
+
121
+ - name: "gpt-4o-mini"
122
+ provider: "openai"
123
+ model: "gpt-4o-mini"
124
+ cost_per_input_token: 0.00000015
125
+ cost_per_output_token: 0.0000006
126
+ capabilities: ["chat", "reasoning", "code", "creative"]
127
+ description: "OpenAI GPT-4o-mini"
128
+ ```
129
+
130
+ ### Run
131
+
132
+ ```bash
133
+ fugusashi serve --config config.yaml
134
+ # → Fugusashi router listening on 0.0.0.0:6060
135
+ ```
136
+
137
+ ### Use
138
+
139
+ ```bash
140
+ # Auto-route — the router picks the best model
141
+ curl http://localhost:6060/v1/chat/completions \
142
+ -H "Content-Type: application/json" \
143
+ -d '{"model":"auto","messages":[{"role":"user","content":"Say hello"}]}'
144
+
145
+ # Force a specific model
146
+ curl http://localhost:6060/v1/chat/completions \
147
+ -H "Content-Type: application/json" \
148
+ -d '{"model":"llama3.2-local","messages":[{"role":"user","content":"Say hello"}]}'
149
+ ```
150
+
151
+ Every response includes a `routing_decision` showing which model was picked, why, and with what confidence.
152
+
153
+ ---
154
+
155
+ ## Architecture
156
+
157
+ ```
158
+ ┌─────────────────────────────────────────┐
159
+ │ Your Application (OpenAI-compatible) │
160
+ └─────────────────┬───────────────────────┘
161
+
162
+ ┌─────────────────▼───────────────────────┐
163
+ │ TIER 1: ROUTER (CPU, <20ms) │
164
+ │ - SimilarityRouter (learns over time) │
165
+ │ - CostRouter (capability + price) │
166
+ │ - EnsembleRouter (priority chain) │
167
+ │ - Routes to single model OR │
168
+ │ escalates to Tier 2 │
169
+ └─────────────────┬───────────────────────┘
170
+
171
+ ┌─────────────┴─────────────┐
172
+ │ │
173
+ ▼ ▼
174
+ ┌─────────┐ ┌──────────────┐
175
+ │ Single │ │ TIER 2: │
176
+ │ Model │ │ ORCHESTRATOR │
177
+ │ Call │ │ (Phase 2) │
178
+ └─────────┘ └──────────────┘
179
+ ```
180
+
181
+ ### Tier 1 — Intelligent Model Router
182
+
183
+ Three routing strategies in priority order:
184
+
185
+ 1. **SimilarityRouter** — Uses sentence-transformers to find similar past prompts and route to the model that worked best. Gets smarter with every request via the feedback loop.
186
+ 2. **CostRouter** — Capability-aware routing with cost optimization. Respects `prefer_local` for air-gapped deployments.
187
+ 3. **FallbackRouter** — Always returns a result, even with no data.
188
+
189
+ ### Tier 2 — Multi-Agent Orchestrator *(Phase 2)*
190
+
191
+ A planning model that decomposes hard tasks into subtasks, assigns them to specialist models, and synthesizes results. Uses reinforcement learning (GRPO-style) to learn teamwork patterns.
192
+
193
+ ---
194
+
195
+ ## API Reference
196
+
197
+ ### `POST /v1/chat/completions`
198
+
199
+ OpenAI-compatible. Set `model: "auto"` for intelligent routing.
200
+
201
+ Response includes `routing_decision`:
202
+ ```json
203
+ {
204
+ "id": "fugu-698f0a66db98",
205
+ "model": "llama3.2-local",
206
+ "choices": [...],
207
+ "routing_decision": {
208
+ "model": "llama3.2-local",
209
+ "confidence": 0.9,
210
+ "strategy": "ensemble(cost)",
211
+ "latency_ms": 0.05,
212
+ "explanation": "Routed by capability fit + cost"
213
+ }
214
+ }
215
+ ```
216
+
217
+ ### `GET /v1/models` — List available models
218
+
219
+ ### `GET /v1/routing/decisions` — Recent routing decisions
220
+
221
+ ### `GET /v1/stats` — Aggregated stats (cost, tokens, per-model)
222
+
223
+ ### `GET /v1/trace/{request_id}` — Full request trace
224
+
225
+ ### `POST /v1/routing/training` — Seed similarity router
226
+
227
+ ```bash
228
+ curl -X POST http://localhost:6060/v1/routing/training \
229
+ -H "Content-Type: application/json" \
230
+ -d '[{"prompt":"Write Python code","model":"gpt-4o-mini","score":0.95}]'
231
+ ```
232
+
233
+ ### `POST /v1/feedback/rate` — Rate a response (1-5)
234
+
235
+ ```bash
236
+ curl -X POST http://localhost:6060/v1/feedback/rate \
237
+ -d '{"request_id":"fugu-698f0a66db98","rating":5}'
238
+ ```
239
+
240
+ ### `POST /v1/feedback/retrain` — Rebuild similarity index from feedback
241
+
242
+ ### `GET /v1/feedback/stats` — Outcome statistics
243
+
244
+ ### `GET /v1/feedback/rankings` — Per-model win rates
245
+
246
+ ---
247
+
248
+ ## Dashboard
249
+
250
+ Open `http://localhost:6060/dashboard` for a live view:
251
+
252
+ - **Overview**: total requests, tokens, cost, avg routing latency
253
+ - **Model Usage**: bar chart of which models are being picked
254
+ - **Strategy Distribution**: cost vs similarity routing breakdown
255
+ - **Recent Decisions**: live table of every routing decision
256
+
257
+ Auto-refreshes every 3 seconds.
258
+
259
+ ---
260
+
261
+ ## Benchmarking
262
+
263
+ ```bash
264
+ # Install
265
+ pip install fugusashi
266
+
267
+ # Run default benchmark (20 samples)
268
+ fugusashi benchmark
269
+
270
+ # With training data
271
+ fugusashi benchmark --train --verbose
272
+
273
+ # JSON output
274
+ fugusashi benchmark --train --json
275
+
276
+ # Custom dataset
277
+ fugusashi benchmark -d my_data.jsonl
278
+ ```
279
+
280
+ **Results:**
281
+
282
+ | Metric | Without Training | With Training |
283
+ |---|---|---|
284
+ | Accuracy | 70% | **85%** |
285
+ | Code accuracy | 60% | **90%** |
286
+ | Strategy | 100% cost | 60% cost / 40% similarity |
287
+ | Routing latency | <1ms | ~18ms |
288
+
289
+ ---
290
+
291
+ ## Feedback Loop — The Killer Feature
292
+
293
+ Fugu's router is static. Fugusashi's **learns from every request**:
294
+
295
+ ```
296
+ Route → Execute → Evaluate → Learn → (repeat)
297
+ ```
298
+
299
+ 1. **Route**: Router picks a model for the prompt
300
+ 2. **Execute**: Model generates a response
301
+ 3. **Evaluate**: Track outcome (success/failure, cost, latency)
302
+ 4. **Learn**: Feed outcomes back into the similarity router
303
+ 5. **Auto-Retrain**: Every 10 requests, the similarity index rebuilds automatically
304
+
305
+ Outcomes are stored in `.fugusashi_data/outcomes.jsonl` — inspectable, shareable, yours.
306
+
307
+ ---
308
+
309
+ ## Project Structure
310
+
311
+ ```
312
+ fugusashi/
313
+ ├── config.yaml # Model pool + routing config
314
+ ├── pyproject.toml # Dependencies + metadata
315
+ ├── LIVING.md # Living development walkthrough
316
+ ├── README.md # This file
317
+ ├── LICENSE # MIT
318
+ ├── src/fugusashi/
319
+ │ ├── __init__.py
320
+ │ ├── __main__.py # CLI: serve, benchmark
321
+ │ ├── server.py # FastAPI app factory
322
+ │ ├── config.py # Pydantic config from YAML
323
+ │ ├── providers.py # LiteLLM multi-provider wrapper
324
+ │ ├── tracker.py # Cost/routing transparency
325
+ │ ├── feedback.py # Feedback loop + learning
326
+ │ ├── benchmark.py # Benchmark runner
327
+ │ ├── api/
328
+ │ │ └── routes.py # All API endpoints
329
+ │ ├── router/
330
+ │ │ ├── interface.py # Abstract router protocol
331
+ │ │ ├── strategies.py # Cost, Similarity, Fallback routers
332
+ │ │ └── ensemble.py # Priority-chain ensemble
333
+ │ └── static/
334
+ │ └── dashboard.html # Live web dashboard
335
+ ├── tests/
336
+ │ └── test_integration.py # Integration tests
337
+ └── docs/ # GitHub Pages documentation
338
+ ```
339
+
340
+ ---
341
+
342
+ ## How It Beats Sakana AI's Fugu
343
+
344
+ 1. **Transparent**: Every routing decision is visible and explainable. No black box.
345
+ 2. **Self-hosting**: Runs entirely on-premise with local models via Ollama.
346
+ 3. **Learning**: Gets smarter from every request via the feedback loop. Fugu can't do this.
347
+ 4. **Open**: Community-owned preference datasets, not proprietary training data.
348
+ 5. **Extensible**: Add your own routing strategies via the plugin interface.
349
+ 6. **Observable**: Dashboard + stats + traces out of the box.
350
+ 7. **Free**: MIT licensed. No usage fees. No vendor lock-in.
351
+
352
+ ---
353
+
354
+ ## Roadmap
355
+
356
+ - [x] Tier 1: Intelligent model router (cost + similarity)
357
+ - [x] OpenAI-compatible API
358
+ - [x] Transparent routing decisions
359
+ - [x] Web dashboard
360
+ - [x] Benchmarking tool
361
+ - [x] Feedback loop with auto-retraining
362
+ - [ ] Tier 2: Multi-agent orchestrator with GRPO
363
+ - [ ] Community preference dataset sharing
364
+ - [ ] Plugin system for custom routers
365
+ - [ ] CLI improvements (interactive mode, model management)
366
+
367
+ ---
368
+
369
+ ## Contributing
370
+
371
+ We welcome contributions! See [LIVING.md](LIVING.md) for the full development story.
372
+
373
+ 1. Fork the repo
374
+ 2. Create a feature branch
375
+ 3. Add tests
376
+ 4. Submit a pull request
377
+
378
+ ---
379
+
380
+ ## Links
381
+
382
+ - **Website**: [eulogik.com](https://eulogik.com)
383
+ - **GitHub**: [github.com/eulogik/fugusashi](https://github.com/eulogik/fugusashi)
384
+ - **PyPI**: [pypi.org/project/fugusashi](https://pypi.org/project/fugusashi/)
385
+ - **Docs**: [eulogik.github.io/fugusashi](https://eulogik.github.io/fugusashi/)
386
+ - **Issues**: [github.com/eulogik/fugusashi/issues](https://github.com/eulogik/fugusashi/issues)
387
+
388
+ ---
389
+
390
+ ## License
391
+
392
+ MIT — use it however you want.
393
+
394
+ ---
395
+
396
+ <div align="center">
397
+
398
+ **Built with ❤️ by [eulogik](https://eulogik.com)**
399
+
400
+ **[⭐ Star on GitHub](https://github.com/eulogik/fugusashi) · [🐦 Follow on Twitter](https://twitter.com/eulogik) · [💬 Discussions](https://github.com/eulogik/fugusashi/discussions)**
401
+
402
+ </div>