roast-api 1.4.0 → 1.5.0

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/index.html DELETED
@@ -1,338 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
-
4
- <head>
5
- <meta charset="UTF-8" />
6
- <title>Roast as a Service · RaaS</title>
7
- <meta name="viewport" content="width=device-width, initial-scale=1" />
8
-
9
- <!-- Meta -->
10
- <meta name="description"
11
- content="Roast as a Service (RaaS) – a CDN-backed static JSON API that serves blazing-fast developer roasts in English and Bangla. Plug it into your apps, bots, and CI.">
12
-
13
- <!-- Open Graph -->
14
- <meta property="og:title" content="Roast as a Service · RaaS" />
15
- <meta property="og:description"
16
- content="Blazing-fast static JSON API for developer roasts. EN + BN, CDN cached, no backend." />
17
- <meta property="og:url" content="https://maijied.github.io/roast-as-a-service/" />
18
- <meta property="og:type" content="website" />
19
- <!-- Optional preview image -->
20
- <!-- <meta property="og:image" content="https://maijied.github.io/roast-as-a-service/assets/preview.png" /> -->
21
-
22
- <!-- Twitter -->
23
- <meta name="twitter:card" content="summary_large_image" />
24
- <meta name="twitter:title" content="Roast as a Service · RaaS" />
25
- <meta name="twitter:description" content="Random dev roasts over a static JSON API.">
26
-
27
- <link rel="stylesheet" href="./assets/style.css" />
28
- </head>
29
-
30
- <body>
31
- <div class="shell">
32
- <header class="hero">
33
- <div class="hero-text">
34
- <div class="brand-pill">🐛 Powered by <a href="https://github.com/Maijied/lorapok"
35
- target="_blank">Lorapok</a></div>
36
- <h1><img src="./assets/logo.png" alt="RaaS Logo" class="logo-md" /> Roast as a Service <span
37
- class="badge">RaaS</span></h1>
38
- <p class="subtitle">
39
- CDN‑served static JSON API for developer roasts. Zero backend, ultra‑low latency, English &amp;
40
- Bangla support.
41
- </p>
42
- <div class="hero-actions">
43
- <button id="btn-en" class="btn primary">🔥 Roast me (EN)</button>
44
- <button id="btn-bn" class="btn ghost">🔥 Roast me (BN)</button>
45
- </div>
46
- <p class="meta">
47
- Served from GitHub Pages edge cache. Designed for bots, CLIs, dashboards, and CI pipelines.
48
- </p>
49
- <div style="display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px;">
50
- <a href="https://www.npmjs.com/package/roast-api" target="_blank"><img
51
- src="https://img.shields.io/npm/v/roast-api?style=flat-square&color=f97316&labelColor=020617"
52
- alt="npm version" /></a>
53
- <a href="https://www.npmjs.com/package/roast-api" target="_blank"><img
54
- src="https://img.shields.io/npm/dm/roast-api?style=flat-square&color=ec4899&labelColor=020617"
55
- alt="npm downloads" /></a>
56
- <a href="https://pypi.org/project/roast-api/" target="_blank"><img
57
- src="https://img.shields.io/pypi/v/roast-api?style=flat-square&color=3b82f6&labelColor=020617"
58
- alt="PyPI version" /></a>
59
- <a href="https://packagist.org/packages/maizied/roast-api" target="_blank"><img
60
- src="https://img.shields.io/packagist/v/maizied/roast-api?style=flat-square&color=10b981&labelColor=020617"
61
- alt="Packagist version" /></a>
62
- <a href="https://github.com/Maijied/roast-as-a-service" target="_blank"><img
63
- src="https://img.shields.io/github/stars/Maijied/roast-as-a-service?style=flat-square&color=f97316&labelColor=020617"
64
- alt="GitHub stars" /></a>
65
- </div>
66
- </div>
67
-
68
- <div class="hero-card">
69
- <div class="card-header">
70
- <span class="dot red"></span>
71
- <span class="dot amber"></span>
72
- <span class="dot green"></span>
73
- <span class="card-title">RaaS Console</span>
74
- </div>
75
- <pre id="roast-box" class="terminal">
76
- $ raas get --lang=en
77
- # Press "Roast me" to receive fire...
78
- </pre>
79
- </div>
80
- </header>
81
-
82
- <main>
83
- <section class="section">
84
- <h2>How it works</h2>
85
- RaaS exposes sharded JSON datasets over GitHub Pages, then a tiny client SDK picks, filters, and caches
86
- roasts in the browser, giving you an API‑like experience with pure static hosting.
87
- </p>
88
- <div class="grid">
89
- <div class="card">
90
- <h3>Static API</h3>
91
- <p>
92
- Roasts are stored in language‑specific shards (<code>en</code>, <code>bn</code>) and served
93
- as JSON over GitHub Pages’ global CDN for low TTFB.
94
- </p>
95
- </div>
96
- <div class="card">
97
- <h3>Smart client</h3>
98
- <p>
99
- The bundled client fetches a small shard, caches it, and returns random roasts with optional
100
- intensity and length filters.
101
- </p>
102
- </div>
103
- <div class="card">
104
- <h3>Zero ops</h3>
105
- <p>
106
- No servers, no cold starts, no scaling issues. Push to main, let Pages deploy and cache
107
- everything at the edge.
108
- </p>
109
- </div>
110
- </div>
111
- </section>
112
-
113
- <section class="section section-accent">
114
- <h2>Why this architecture feels overkill (in a good way)</h2>
115
- <p>
116
- RaaS is not a toy endpoint glued to a random server. It is a static API designed to exploit CDN edge
117
- caching, sharded JSON, and a smart client so you get API-level UX without any backend attached.
118
- </p>
119
-
120
- <div class="grid arch-grid">
121
- <div class="card arch-card">
122
- <h3>Edge-first delivery</h3>
123
- <p>
124
- All JSON and JS is served from GitHub Pages’ global PoPs, so most requests are satisfied
125
- from edge cache with minimal latency and no application server in the path.
126
- </p>
127
- </div>
128
- <div class="card arch-card">
129
- <h3>Static API, dynamic feel</h3>
130
- <p>
131
- The API surface is just files, but the client SDK handles randomness, filtering, and caching
132
- to make it behave like a dynamic service while staying 100% static.
133
- </p>
134
- </div>
135
- <div class="card arch-card">
136
- <h3>Shard &amp; scale</h3>
137
- <p>
138
- Roasts are split into language shards, which keeps payloads small, cache hit rates high, and
139
- lets you grow the dataset without slowing down clients.
140
- </p>
141
- </div>
142
- <div class="card arch-card">
143
- <h3>Operationally boring</h3>
144
- <p>
145
- No servers, no containers, no warmup, no autoscaling rules. Git pushes become deployments,
146
- and the CDN takes care of distribution, caching, and reliability.
147
- </p>
148
- </div>
149
- </div>
150
- </section>
151
-
152
- <section class="section">
153
- <h2>Quick start</h2>
154
- <div class="code-grid">
155
- <div class="code-card">
156
- <h3>npm install</h3>
157
- <pre><code>npm install roast-api
158
-
159
- // Usage
160
- const RaaS = require('roast-api');
161
- RaaS.getRandomRoast({ lang: 'en' })
162
- .then(r =&gt; console.log(r.text));</code></pre>
163
- </div>
164
- <div class="code-card">
165
- <h3>Script include</h3>
166
- <pre><code>&lt;script src="https://maijied.github.io/roast-as-a-service/api/client.js"&gt;&lt;/script&gt;
167
-
168
- &lt;script&gt;
169
- RaaS.getRandomRoast({ lang: 'bn', intensity: 2 })
170
- .then(r =&gt; console.log(r.text));
171
- &lt;/script&gt;</code></pre>
172
- <div class="code-card">
173
- <h3>Composer (PHP)</h3>
174
- <pre><code>composer require maizied/roast-api
175
-
176
- // Usage
177
- use Maizied\RoastApi\RaaS;
178
-
179
- $roast = RaaS::getRandomRoast(['lang' =&gt; 'en']);
180
- echo $roast['text'];</code></pre>
181
- </div>
182
- <div class="code-card">
183
- <h3>pip (Python)</h3>
184
- <pre><code>pip install roast-api
185
-
186
- # Usage
187
- from roast_api import get_random_roast
188
-
189
- roast = get_random_roast(lang='en')
190
- print(roast['text'])</code></pre>
191
- </div>
192
- </div>
193
- </section>
194
-
195
- <section class="section">
196
- <h2>API usage</h2>
197
- <p>
198
- RaaS is a read‑only static API, so you interact with it using simple GET requests or the client SDK.
199
- </p>
200
- <div class="code-grid">
201
- <div class="code-card">
202
- <h3>cURL</h3>
203
- <pre><code># Get English shard 1
204
- curl https://maijied.github.io/roast-as-a-service/api/en/roasts-en-1.json
205
-
206
- # Pretty-print first roast (requires jq)
207
- curl -s https://maijied.github.io/roast-as-a-service/api/en/roasts-en-1.json \
208
- | jq '.roasts[0].text'</code></pre>
209
- </div>
210
- <div class="code-card">
211
- <h3>Node.js</h3>
212
- <pre><code>import fetch from 'node-fetch';
213
-
214
- async function getRandomRoast(lang = 'en') {
215
- const url = `https://maijied.github.io/roast-as-a-service/api/${lang}/roasts-${lang}-1.json`;
216
- const res = await fetch(url);
217
- const data = await res.json();
218
- const list = data.roasts;
219
- const pick = list[Math.floor(Math.random() * list.length)];
220
- return pick.text;
221
- }</code></pre>
222
- </div>
223
- </div>
224
- </section>
225
-
226
- <section class="section">
227
- <h2>Performance</h2>
228
- <div class="code-card"
229
- style="background: linear-gradient(135deg, rgba(249,115,22,0.1), rgba(236,72,153,0.1)); border: 1px solid var(--border-subtle);">
230
- <div style="padding: 16px;">
231
- <div
232
- style="display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 20px; text-align: center;">
233
- <div>
234
- <div style="font-size: 1.8rem; font-weight: 800; color: var(--accent);">2,000+</div>
235
- <div style="font-size: 0.8rem; text-transform: uppercase; color: var(--text-muted);">
236
- Requests / Sec</div>
237
- </div>
238
- <div>
239
- <div style="font-size: 1.8rem; font-weight: 800; color: var(--accent-2);">100%</div>
240
- <div style="font-size: 0.8rem; text-transform: uppercase; color: var(--text-muted);">
241
- Success Rate</div>
242
- </div>
243
- <div>
244
- <div style="font-size: 1.8rem; font-weight: 800; color: #10b981;">~50ms</div>
245
- <div style="font-size: 0.8rem; text-transform: uppercase; color: var(--text-muted);">Avg
246
- Latency</div>
247
- </div>
248
- <div>
249
- <div style="font-size: 1.8rem; font-weight: 800; color: #3b82f6;">90%</div>
250
- <div style="font-size: 0.8rem; text-transform: uppercase; color: var(--text-muted);">
251
- Cache Hits</div>
252
- </div>
253
- </div>
254
- <p style="font-size: 0.85rem; margin-top: 20px; color: var(--text-soft); text-align: center;">
255
- Zero backend, zero cold starts. Optimized for extreme throughput and low TTFB using GitHub
256
- Pages' edge CDN.
257
- </p>
258
- </div>
259
- </div>
260
- </section>
261
-
262
- <section class="section">
263
- <h2>Postman collection</h2>
264
- <p>
265
- Prefer GUI testing? Import the Postman collection and hit the static endpoints directly.
266
- </p>
267
- <div class="code-card">
268
- <h3>Download</h3>
269
- <div style="padding: 0 12px 14px;">
270
- <a href="./postman/roast-as-a-service.postman_collection.json" download class="btn primary"
271
- style="width: 100%; display: block; text-align: center; text-decoration: none; margin-bottom: 10px;">
272
- Download Postman Collection
273
- </a>
274
- <p style="font-size: 0.8rem; margin: 0; color: var(--text-muted);">
275
- Import this JSON file into Postman to test all endpoints instantly.
276
- </p>
277
- </div>
278
- </div>
279
- </section>
280
-
281
- <section class="section">
282
- <h2>Share RaaS</h2>
283
- <p>Like what you see? Share the service with your friends, team, or followers.</p>
284
- <div class="share-buttons">
285
- <a id="share-twitter" class="share-btn">X / Twitter</a>
286
- <a id="share-facebook" class="share-btn">Facebook</a>
287
- <a id="share-whatsapp" class="share-btn">WhatsApp</a>
288
- <a id="share-linkedin" class="share-btn">LinkedIn</a>
289
- </div>
290
- </section>
291
- </main>
292
-
293
- <footer class="footer">
294
- <p>Roast as a Service · Static JSON over CDN · Built on GitHub Pages.</p>
295
- <p>A <a href="https://github.com/Maijied/lorapok">Lorapok</a> Project · <a
296
- href="https://github.com/maijied/roast-as-a-service">View source</a> · Made by <a
297
- href="mailto:mdshuvo40@gmail.com">Maizied</a></p>
298
- <div style="margin-top: 10px; opacity: 0.8;">
299
- <img src="https://hits.sh/maijied.github.io/roast-as-a-service.svg?view=today-total&style=flat-square&label=visitors&color=ec4899&labelColor=020617"
300
- alt="Visitor Count" />
301
- </div>
302
- </footer>
303
- </div>
304
-
305
- <script src="./api/client.js"></script>
306
- <script>
307
- const roastBox = document.getElementById('roast-box');
308
- const btnEn = document.getElementById('btn-en');
309
- const btnBn = document.getElementById('btn-bn');
310
-
311
- async function showRoast(lang) {
312
- roastBox.textContent = 'Loading...';
313
- try {
314
- const data = await RaaS.getRandomRoast({ lang });
315
- roastBox.textContent = data.text;
316
- } catch (err) {
317
- roastBox.textContent = 'Error: ' + err.message;
318
- }
319
- }
320
-
321
- btnEn.addEventListener('click', () => showRoast('en'));
322
- btnBn.addEventListener('click', () => showRoast('bn'));
323
-
324
- const pageUrl = encodeURIComponent('https://maijied.github.io/roast-as-a-service/');
325
- const text = encodeURIComponent('Roast as a Service (RaaS): CDN-backed static JSON API for developer roasts.');
326
-
327
- document.getElementById('share-twitter').href =
328
- `https://twitter.com/intent/tweet?url=${pageUrl}&text=${text}`;
329
- document.getElementById('share-facebook').href =
330
- `https://www.facebook.com/sharer/sharer.php?u=${pageUrl}`;
331
- document.getElementById('share-whatsapp').href =
332
- `https://api.whatsapp.com/send?text=${text}%20${pageUrl}`;
333
- document.getElementById('share-linkedin').href =
334
- `https://www.linkedin.com/sharing/share-offsite/?url=${pageUrl}`;
335
- </script>
336
- </body>
337
-
338
- </html>
package/load_test.js DELETED
@@ -1,72 +0,0 @@
1
- const RaaS = require('./api/client.js');
2
-
3
- async function runLoadTest(totalRequests = 1000, concurrency = 50) {
4
- console.log(`🚀 Starting Load Test: ${totalRequests} total requests, Concurrency: ${concurrency}\n`);
5
-
6
- const results = {
7
- latencies: [],
8
- errors: 0,
9
- networkRequests: 0,
10
- startTime: Date.now()
11
- };
12
-
13
- // Instrument RaaS fetch to count network hits
14
- const originalFetch = global.fetch;
15
- global.fetch = async (...args) => {
16
- results.networkRequests++;
17
- return originalFetch(...args);
18
- };
19
-
20
- const languages = ['en', 'bn'];
21
- let count = totalRequests;
22
-
23
- async function worker() {
24
- while (count > 0) {
25
- count--;
26
- const start = Date.now();
27
- try {
28
- const lang = languages[Math.floor(Math.random() * languages.length)];
29
- await RaaS.getRandomRoast({ lang });
30
- results.latencies.push(Date.now() - start);
31
- } catch (err) {
32
- results.errors++;
33
- console.error(`❌ Request failed: ${err.message}`);
34
- }
35
- }
36
- }
37
-
38
- // Spawn workers
39
- const workers = Array(concurrency).fill(0).map(() => worker());
40
- await Promise.all(workers);
41
-
42
- // Restore fetch
43
- global.fetch = originalFetch;
44
-
45
- // Results Calculation
46
- const totalTime = (Date.now() - results.startTime) / 1000;
47
- const avgLatency = results.latencies.reduce((a, b) => a + b, 0) / results.latencies.length;
48
- results.latencies.sort((a, b) => a - b);
49
- const p95 = results.latencies[Math.floor(results.latencies.length * 0.95)] || 0;
50
- const p99 = results.latencies[Math.floor(results.latencies.length * 0.99)] || 0;
51
-
52
- console.log('-------------------------------------------');
53
- console.log('📊 LOAD TEST RESULTS (INSTRUMENTED)');
54
- console.log('-------------------------------------------');
55
- console.log(`Total Time: ${totalTime.toFixed(2)}s`);
56
- console.log(`Requests/sec: ${(totalRequests / totalTime).toFixed(2)}`);
57
- console.log(`Success Rate: ${((totalRequests - results.errors) / totalRequests * 100).toFixed(2)}%`);
58
- console.log(`Avg Latency: ${avgLatency.toFixed(2)}ms`);
59
- console.log(`P95 Latency: ${p95}ms`);
60
- console.log(`P99 Latency: ${p99}ms`);
61
- console.log(`Network Requests: ${results.networkRequests}`);
62
- console.log(`Cache Hits: ${totalRequests - results.networkRequests}`);
63
- console.log(`Cache Efficiency: ${((1 - results.networkRequests / totalRequests) * 100).toFixed(2)}%`);
64
- console.log(`Total Errors: ${results.errors}`);
65
- console.log('-------------------------------------------');
66
- }
67
-
68
- // Get args or defaults
69
- const requests = parseInt(process.argv[2]) || 1000;
70
- const concurrency = parseInt(process.argv[3]) || 50;
71
-
72
- runLoadTest(requests, concurrency);
@@ -1,79 +0,0 @@
1
- {
2
- "info": {
3
- "name": "Roast as a Service (RaaS)",
4
- "_postman_id": "8c5a4e1b-aaaa-bbbb-cccc-112233445566",
5
- "description": "Postman collection for testing Roast as a Service (RaaS) static JSON API on GitHub Pages.",
6
- "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
7
- },
8
- "item": [
9
- {
10
- "name": "Get manifest",
11
- "request": {
12
- "method": "GET",
13
- "header": [],
14
- "url": {
15
- "raw": "https://maijied.github.io/roast-as-a-service/api/manifest.json",
16
- "protocol": "https",
17
- "host": [
18
- "maijied",
19
- "github",
20
- "io"
21
- ],
22
- "path": [
23
- "roast-as-a-service",
24
- "api",
25
- "manifest.json"
26
- ]
27
- }
28
- },
29
- "response": []
30
- },
31
- {
32
- "name": "Get English shard 1",
33
- "request": {
34
- "method": "GET",
35
- "header": [],
36
- "url": {
37
- "raw": "https://maijied.github.io/roast-as-a-service/api/en/roasts-en-1.json",
38
- "protocol": "https",
39
- "host": [
40
- "maijied",
41
- "github",
42
- "io"
43
- ],
44
- "path": [
45
- "roast-as-a-service",
46
- "api",
47
- "en",
48
- "roasts-en-1.json"
49
- ]
50
- }
51
- },
52
- "response": []
53
- },
54
- {
55
- "name": "Get Bangla shard 1",
56
- "request": {
57
- "method": "GET",
58
- "header": [],
59
- "url": {
60
- "raw": "https://maijied.github.io/roast-as-a-service/api/bn/roasts-bn-1.json",
61
- "protocol": "https",
62
- "host": [
63
- "maijied",
64
- "github",
65
- "io"
66
- ],
67
- "path": [
68
- "roast-as-a-service",
69
- "api",
70
- "bn",
71
- "roasts-bn-1.json"
72
- ]
73
- }
74
- },
75
- "response": []
76
- }
77
- ],
78
- "variable": []
79
- }
package/pyproject.toml DELETED
@@ -1,32 +0,0 @@
1
- [build-system]
2
- requires = ["setuptools>=61.0"]
3
- build-backend = "setuptools.build_meta"
4
-
5
- [project]
6
- name = "roast-api"
7
- version = "1.4.0"
8
- description = "A Python client for RaaS — Roast as a Service. CDN-served static JSON API for developer roasts."
9
- readme = "README.md"
10
- license = {text = "MIT"}
11
- requires-python = ">=3.7"
12
- authors = [
13
- {name = "Maizied", email = "mdshuvo40@gmail.com"}
14
- ]
15
- keywords = ["roast", "api", "developer", "humor", "fun", "cdn"]
16
- classifiers = [
17
- "Development Status :: 5 - Production/Stable",
18
- "Intended Audience :: Developers",
19
- "License :: OSI Approved :: MIT License",
20
- "Programming Language :: Python :: 3",
21
- "Topic :: Software Development :: Libraries :: Python Modules",
22
- ]
23
- dependencies = [
24
- "requests>=2.20.0",
25
- ]
26
-
27
- [project.urls]
28
- Homepage = "https://maijied.github.io/roast-as-a-service/"
29
- Repository = "https://github.com/Maijied/roast-as-a-service"
30
-
31
- [tool.setuptools.packages.find]
32
- include = ["roast_api*"]
@@ -1,29 +0,0 @@
1
- """
2
- RaaS — Roast as a Service Python Client
3
-
4
- A lightweight Python client for fetching developer roasts from the
5
- RaaS static JSON API hosted on GitHub Pages.
6
-
7
- Usage:
8
- from roast_api import get_random_roast, get_all_roasts
9
-
10
- roast = get_random_roast(lang='en')
11
- print(roast['text'])
12
- """
13
-
14
- from roast_api.client import (
15
- get_random_roast,
16
- get_all_roasts,
17
- get_manifest,
18
- get_shard,
19
- clear_cache,
20
- )
21
-
22
- __version__ = "1.4.0"
23
- __all__ = [
24
- "get_random_roast",
25
- "get_all_roasts",
26
- "get_manifest",
27
- "get_shard",
28
- "clear_cache",
29
- ]
@@ -1,89 +0,0 @@
1
- """
2
- RaaS Python Client — core logic.
3
-
4
- Fetches roasts from the static JSON API on GitHub Pages,
5
- with in-memory caching and optional filtering.
6
- """
7
-
8
- import random
9
- from typing import Any, Dict, List, Optional
10
-
11
- import requests
12
-
13
- BASE_URL = "https://maijied.github.io/roast-as-a-service/api"
14
-
15
- # In-memory caches
16
- _manifest_cache: Optional[Dict[str, Any]] = None
17
- _shard_cache: Dict[str, Dict[str, Any]] = {}
18
-
19
-
20
- def get_manifest() -> Dict[str, Any]:
21
- """Fetch and cache the API manifest."""
22
- global _manifest_cache
23
- if _manifest_cache is not None:
24
- return _manifest_cache
25
-
26
- url = f"{BASE_URL}/manifest.json"
27
- resp = requests.get(url, timeout=10)
28
- resp.raise_for_status()
29
- _manifest_cache = resp.json()
30
- return _manifest_cache
31
-
32
-
33
- def get_shard(lang: str = "en", shard: int = 1) -> Dict[str, Any]:
34
- """Fetch and cache a specific language shard."""
35
- key = f"{lang}-{shard}"
36
- if key in _shard_cache:
37
- return _shard_cache[key]
38
-
39
- url = f"{BASE_URL}/{lang}/roasts-{lang}-{shard}.json"
40
- resp = requests.get(url, timeout=10)
41
- resp.raise_for_status()
42
- _shard_cache[key] = resp.json()
43
- return _shard_cache[key]
44
-
45
-
46
- def get_random_roast(
47
- lang: str = "en",
48
- intensity: Optional[int] = None,
49
- max_length: Optional[int] = None,
50
- ) -> Dict[str, Any]:
51
- """
52
- Get a random roast.
53
-
54
- Args:
55
- lang: Language code ('en' or 'bn'). Default: 'en'.
56
- intensity: Filter by intensity (1–3). Default: None (any).
57
- max_length: Maximum text length. Default: None (any).
58
-
59
- Returns:
60
- A dict with keys: id, text, intensity, length.
61
-
62
- Raises:
63
- ValueError: If no roasts match the given filters.
64
- """
65
- data = get_shard(lang)
66
- roasts: List[Dict[str, Any]] = data.get("roasts", [])
67
-
68
- if intensity is not None:
69
- roasts = [r for r in roasts if r.get("intensity") == intensity]
70
- if max_length is not None:
71
- roasts = [r for r in roasts if r.get("length", 0) <= max_length]
72
-
73
- if not roasts:
74
- raise ValueError("No roasts match the given filters.")
75
-
76
- return random.choice(roasts)
77
-
78
-
79
- def get_all_roasts(lang: str = "en") -> List[Dict[str, Any]]:
80
- """Get all roasts for a language."""
81
- data = get_shard(lang)
82
- return data.get("roasts", [])
83
-
84
-
85
- def clear_cache() -> None:
86
- """Clear the in-memory caches."""
87
- global _manifest_cache, _shard_cache
88
- _manifest_cache = None
89
- _shard_cache = {}