/** * Internal dependencies */ import type { Candidates, AsyncCandidatesGenerator } from '../types'; type CandidatesCallback = (candidates: Candidates) => void; /** * Class to process a candidates stream. * * @since 0.3.0 */ export default class CandidatesStreamProcessor { generator: AsyncCandidatesGenerator; candidates: Candidates | null; /** * Constructor. * * @since 0.3.0 * * @param generator - The generator that yields chunks of response candidates with the generated text content. */ constructor(generator: AsyncCandidatesGenerator); /** * Reads all chunks from the generator and adds them to the overall candidates instance. * * A callback can be passed that is called for each chunk of candidates. You could use such a callback for example * to echo the text contents of each chunk as they are being processed. * * @since 0.3.0 * * @param chunkCallback - Optional. Callback that is called for each chunk of candidates. * @returns The complete candidates instance. */ readAll(chunkCallback?: CandidatesCallback | null): Promise; /** * Adds a chunk of candidates to the overall candidates instance. * * @since 0.3.0 * * @param candidates - The chunk of candidates to add. */ addChunk(candidates: Candidates): void; /** * Gets the complete candidates instance. * * @since 0.3.0 * * @returns The complete candidates instance, or null if the generator is not done yet. */ getComplete(): Candidates | null; } export {}; //# sourceMappingURL=candidates-stream-processor.d.ts.map