@cxai/stream
v1.0.20
Published
## Overview `@cxai/stream` is a powerful TypeScript streaming library designed for advanced streaming capabilities, with a focus on AI-driven applications, state management, and real-time data processing.
Readme
@cxai/stream - Streaming Library
Overview
@cxai/stream is a powerful TypeScript streaming library designed for advanced streaming capabilities, with a focus on AI-driven applications, state management, and real-time data processing.
Features
- AI Streaming Support
- XState Integration
- Server-Sent Events (SSE)
- Async Iterator Utilities
- Yjs Collaborative Editing Support
- Observable Actors
- UI Rendering Helpers
Installation
npm install @cxai/streamPrerequisites
- Node.js 22.8.0+
- Optional Peer Dependencies:
yjsopenai
Core Modules
AI Streaming
Stream text and objects from AI models with advanced configuration options.
import { streamText } from '@cxai/stream/ai';
const result = await streamText({
model: openaiGP4o(),
prompt: "Generate a creative idea"
});XState Integration
Create observable actors and manage complex state transitions.
import { fromAIEventStream } from '@cxai/stream/xstate';
const machine = createMachine({
// Machine configuration with streaming support
});Async Iterator Utilities
Advanced async iterator manipulation and cloning.
import { cloneable } from '@cxai/stream/iterator';
const clonableStream = cloneable(originalStream);Server-Sent Events
Convert async iterators to SSE-compatible streams.
import { sseReadableStream } from '@cxai/stream/iterator/sse';
const sseStream = sseReadableStream(asyncIterator);Development
# Install dependencies
pnpm install
# Build the library
pnpm run build
# Run tests
pnpm testTechnologies
- TypeScript
- XState
- Yjs
- OpenAI
- Atomico
- Server-Sent Events
Contributing
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
License
ISC License
Peer Dependencies
yjs: Collaborative editing support (optional)openai: AI model streaming (optional)
