@c0-ui/server
v0.1.2
Published
System prompts, OpenAI stream adapter, and response builder for c0 — an open-source generative UI pipeline for any OpenAI-compatible LLM (BYOK).
Downloads
283
Maintainers
Readme
@c0-ui/server
Server-side runtime for c0 — the open-source generative UI pipeline. System prompts, an OpenAI-compatible stream adapter, and a response builder. BYOK (Bring Your Own Key) — works with any OpenAI-compatible LLM, including local models.
Install
npm install @c0-ui/server
# openai is an optional peer dependency
npm install openaiQuick Start
import { createSystemPrompt, transformOpenAIStream } from '@c0-ui/server';
import OpenAI from 'openai';
const openai = new OpenAI(); // or any OpenAI-compatible endpoint (BYOK)
const stream = await openai.chat.completions.create({
model: process.env.LLM_MODEL!,
stream: true,
messages: [
{ role: 'system', content: createSystemPrompt({ modelTier: 'weak' }) },
{ role: 'user', content: 'Show me last quarter sales as a table' },
],
});
// Returns a ReadableStream<string> of the c0 XML-DSL — pipe to the client
return new Response(transformOpenAIStream(stream));Key exports
| Export | Purpose |
|--------|---------|
| createSystemPrompt(options) | Build the system prompt; modelTier: 'weak' tunes it for small models (7B–13B) |
| transformOpenAIStream(stream) | Adapt an OpenAI chat stream into the c0 DSL ReadableStream<string> |
| toOpenAIMessages(...) | Convert c0 thread state into OpenAI message format |
| makeC0Response() | Manually build a streamed response (writeContent / writeArtifact / writeThink) |
| BASE_PROMPT, C0_SYSTEM_PROMPT, DEFAULT_ARTIFACT_TYPES, MODEL_COMPATIBILITY | Prompt + artifact-type building blocks |
Why c0 server (vs a closed Gen UI API)?
The entire pipeline — LLM routing, the component-selection prompt, quality filtering — is open and runs in your process. No black-box server, no model lock-in, debuggable in production.
License
MIT © domuk-k
