OpenAI Chat Chunk Builder (concerns/chunk.ts)

OpenCursor · src/agent/oauth/protocols/translator/concerns/chunk.ts · typescript · MIT
ai, realtime, chat, lang:typescript

Utility function that constructs OpenAI-compatible chat completion streaming chunks with configurable ID, timestamp, model, and delta content.

// Source: https://github.com/PawanOsman/OpenCursor | License: MIT | Copyright 2026 Pawan Osman
// Provided via justclaw.it.com; keep this notice with the code.
/*
 * Copyright (c) 2026 Pawan Osman <https://github.com/PawanOsman>
 *
 * This file is part of OpenCursor — AI coding agent chat inside VS Code.
 * https://github.com/PawanOsman/OpenCursor
 *
 * Licensed under the MIT License. See LICENSE file in the project root.
 */

import type { StreamDelta, ResponseChunk } from "../../wireTypes.js";
// Build OpenAI chat.completion.chunk. Caller supplies id/created/model so each
// translator keeps its exact id-generation + created semantics (no Date.now here).
export function buildChunk({ id, created, model }: { id?: string; created?: number; model?: string | null }, delta: StreamDelta, finis

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key