nttp 1.4.1 → 1.4.3
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/README.md +45 -0
- package/dist/cli.js +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -99,6 +99,9 @@ Create a new NTTP instance.
|
|
|
99
99
|
apiKey?: string,
|
|
100
100
|
maxSize?: number, // Default: 500
|
|
101
101
|
similarityThreshold?: number // Default: 0.85
|
|
102
|
+
},
|
|
103
|
+
redis?: {
|
|
104
|
+
url: string // Redis connection URL for L1 cache persistence
|
|
102
105
|
}
|
|
103
106
|
},
|
|
104
107
|
limits?: {
|
|
@@ -241,6 +244,47 @@ NTTP works with any SQL database supported by Knex.js:
|
|
|
241
244
|
- **Cache Miss**: ~2-3s (LLM call)
|
|
242
245
|
- **Throughput**: >10,000 req/s (cached)
|
|
243
246
|
|
|
247
|
+
## Cache Persistence with Redis
|
|
248
|
+
|
|
249
|
+
By default, L1 cache uses in-memory storage that resets on each process restart. For production deployments or CLI usage, enable Redis to persist cache across invocations:
|
|
250
|
+
|
|
251
|
+
```typescript
|
|
252
|
+
const nttp = new NTTP({
|
|
253
|
+
database: {
|
|
254
|
+
client: 'pg',
|
|
255
|
+
connection: process.env.DATABASE_URL
|
|
256
|
+
},
|
|
257
|
+
llm: {
|
|
258
|
+
provider: 'anthropic',
|
|
259
|
+
model: 'claude-sonnet-4-5-20250929',
|
|
260
|
+
apiKey: process.env.ANTHROPIC_API_KEY
|
|
261
|
+
},
|
|
262
|
+
cache: {
|
|
263
|
+
redis: {
|
|
264
|
+
url: 'redis://localhost:6379'
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
Or via environment variables with `NTTP.fromEnv()`:
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
# .env file
|
|
274
|
+
REDIS_URL=redis://localhost:6379
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
**Benefits:**
|
|
278
|
+
- ✅ Cache persists across CLI invocations
|
|
279
|
+
- ✅ Shared cache in multi-instance deployments
|
|
280
|
+
- ✅ Reduced cold-start latency
|
|
281
|
+
- ✅ 24-hour TTL for cached entries
|
|
282
|
+
|
|
283
|
+
**Performance with Redis:**
|
|
284
|
+
- L1 cache hit: ~5ms (vs <1ms in-memory)
|
|
285
|
+
- Still 400x faster than LLM call
|
|
286
|
+
- Negligible latency increase for significant persistence benefits
|
|
287
|
+
|
|
244
288
|
## CLI Commands
|
|
245
289
|
|
|
246
290
|
### `npx nttp setup`
|
|
@@ -250,6 +294,7 @@ Beautiful interactive setup wizard (powered by Ink) with Vercel-inspired DX:
|
|
|
250
294
|
- Choose database type (PostgreSQL, MySQL, SQLite, SQL Server)
|
|
251
295
|
- Configure connection details
|
|
252
296
|
- Select LLM provider (Anthropic, OpenAI, Cohere, Mistral, Google)
|
|
297
|
+
- Optional: Enable Redis cache (L1 persistence)
|
|
253
298
|
- Optional: Enable semantic caching (L2 cache)
|
|
254
299
|
- Automatically installs dependencies
|
|
255
300
|
- Creates `.env` file
|
package/dist/cli.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nttp",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.3",
|
|
4
4
|
"description": "natural text to query - Query databases with natural language",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
],
|
|
21
21
|
"scripts": {
|
|
22
22
|
"build": "tsc",
|
|
23
|
-
"dev": "tsc --watch"
|
|
23
|
+
"dev": "tsc --watch",
|
|
24
|
+
"bump": "npm version patch --no-git-tag-version && node -e \"const fs=require('fs');const pkg=require('./package.json');const cli=fs.readFileSync('src/cli.ts','utf8');fs.writeFileSync('src/cli.ts',cli.replace(/\\.version\\('.*?'\\)/,\\`.version('\\${pkg.version}'\\)\\`))\" && npm run build"
|
|
24
25
|
},
|
|
25
26
|
"keywords": [
|
|
26
27
|
"nttp",
|