import { LLMInputs } from '../../types';
import { Trace } from './Trace';
/**
 * Handles streaming results from an asynchronous iterable source.
 * @template Item The type of items in the stream.
 */
export declare class StreamHandler<Item> {
    private trace;
    private configuration;
    /**
     * Creates a new StreamHandler instance.
     * @param trace The trace object for logging.
     * @param configuration Optional configuration for the language model.
     */
    constructor(trace: Trace, configuration?: LLMInputs);
    /**
     * Handles the streaming result and returns a ReadableStream.
     * @param result The asynchronous iterable result to process.
     * @returns A ReadableStream of the processed items.
     */
    handle(result: AsyncIterable<Item>): ReadableStream;
    /**
     * Finalizes the trace with the collected results and metrics.
     * @param allResults All the results collected from the stream.
     * @param timeToFirstToken The time taken to receive the first token.
     * @param responseModel The model used for the response.
     */
    private finalizeTrace;
    /**
     * aggregate the streaming results to extract relevant information.
     * @param results The array of results from the stream.
     * @returns An object containing the processed output and metrics.
     */
    private aggregateStreamingResults;
}
