Registry / ai-ml / prai-redis

prai-redis

JSON →
library0.4.16jsnpmunverified

Redis logger for prai, a TypeScript library for programmable AI interactions. Version 0.4.16 provides middleware to log model interactions (prompts, completions, metadata) to Redis streams. Supports automatic serialization, configurable stream names, and integrates with the Node.js redis client. Differentiates by being purpose-built for prai's history/step workflow, offering low-latency logging with Redis stream capabilities. Released under the pmndrs organization, actively maintained.

npm install prai-redis
INSTALL
IMPORT
SIG · PRAI-REDIS
P
prai-redis
ai-mljavascriptv0.4.16
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

redisLogger
import { redisLogger } from 'prai-redis'
import redisLogger from 'prai-redis'
Named export only. Default import will fail with 'redisLogger is not a function'.
RedisLoggerOptions
import { RedisLoggerOptions } from 'prai-redis'
import RedisLoggerOptions from 'prai-redis'
Type export for TypeScript users. Not needed in JavaScript.
createClient
import { createClient } from 'redis'
import redis from 'redis'
Use named import for ESM. CommonJS: const { createClient } = require('redis');

Initializes a prai model and history, creates a Redis client, sets up Redis logger to stream interactions, runs a step, and disconnects.

import { Model, History } from 'prai'; import { redisLogger } from 'prai-redis'; import { createClient } from 'redis'; const model = new Model({ apiKey: process.env.OPENAI_API_KEY ?? '' }); const history = new History(); const client = createClient({ url: process.env.REDIS_URL ?? 'redis://localhost:6379' }); await client.connect(); await redisLogger(history, { streamName: 'stream-name', client, maxLength: 1000 }); const result = await model.step({ input: 'Hello', history }); console.log('Logged to Redis stream'); await client.disconnect();
Debug
Known issues
breakingRequires Redis server running; no fallback if connection fails. Will throw error.
fix
Ensure Redis URL is correct and server is accessible before calling redisLogger.
affects: >=0.4.0
gotcharedisLogger expects a connected client; calling before await client.connect() will throw.
fix
Always await client.connect() before passing client to redisLogger.
affects: >=0.4.0
deprecatedUsing redis v3 client API (legacy mode) may cause incompatibility; prai-redis expects v4 client.
fix
Install redis@4 or later and use the modern createClient API.
affects: >=0.4.16
Errors
Common errors & fixes
TypeError: redisLogger is not a function
Default import instead of named import
fix
Change to: import { redisLogger } from 'prai-redis'
Error: The client is closed
Passing client before connecting or after disconnecting
fix
Ensure client.connect() is awaited before redisLogger, and avoid reusing after client.disconnect()
Uncaught RedisClientError: Ready check failed: NOAUTH Authentication required
Redis server requires password but no password provided or wrong password
fix
Add password to REDIS_URL: redis://:password@host:port
Upgrade
Version history
0.4.16latest on npm
Audit
Dependencies
prairequiredPeer dependency: provides the Model and History classes used by prai-redis logger
redisrequiredPeer dependency: the redis client instance is passed as parameter to redisLogger
Agent activity
5 hits · last 30 days
node
4
Resources
prai-redis — npm install prai-redis · libregistry