@langchain/core
Version:
Core LangChain.js abstractions and schemas
4 lines (3 loc) • 297 B
JavaScript
import { AIMessageChunk } from "../../messages/index.js";
/** Tiny helper to convert string into char chunk. For eg: Turn `"Hi!"` into `[AIMessageChunk("H"), AIMessageChunk("i"), AIMessageChunk("!")] */
export const charChunks = (text) => [...text].map((c) => new AIMessageChunk({ content: c }));