UNPKG

@tanstack/ai

Version:

Core TanStack AI library - Open source AI SDK

41 lines (40 loc) 869 B
function createId(prefix) { return `${prefix}-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`; } async function* streamGenerationResult(generator, options) { const runId = createId("run"); yield { type: "RUN_STARTED", runId, timestamp: Date.now() }; try { const result = await generator(); yield { type: "CUSTOM", name: "generation:result", value: result, timestamp: Date.now() }; yield { type: "RUN_FINISHED", runId, finishReason: "stop", timestamp: Date.now() }; } catch (error) { yield { type: "RUN_ERROR", runId, error: { message: error.message || "Generation failed", code: error.code }, timestamp: Date.now() }; } } export { streamGenerationResult }; //# sourceMappingURL=stream-generation-result.js.map