parea-ai
Version:
Client SDK library to connect to Parea AI.
45 lines (44 loc) • 2 kB
TypeScript
import { Completion, Log, TraceLog, UpdateLog } from './types';
/**
* Generates a unique trace ID for each chain of requests.
* @returns {string} A unique UUID v4 string.
*/
export declare function genTraceId(): string;
/**
* Converts a Date object to an ISO 8601 formatted string.
* @param {Date} date - The date to convert.
* @returns {string} The date in ISO 8601 format.
*/
export declare function toDateTimeString(date: Date): string;
/**
* Creates an async generator that limits concurrent execution of promises.
* @param {number} concurrency - The maximum number of concurrent executions.
* @param {Iterable<T>} iterable - The iterable of input items.
* @param {(item: T) => Promise<R>} iteratorFn - The async function to execute for each item.
* @returns {AsyncGenerator<R, void, unknown>} An async generator yielding results.
* @throws {Error} When attempting to consume with no promises executing.
*/
export declare function asyncPool<T, R>(concurrency: number, iterable: Iterable<T>, iteratorFn: (item: T) => Promise<R>): AsyncGenerator<R, void, unknown>;
export type LogData = Completion & TraceLog & Log;
/**
* Serializes metadata values in the log data.
* @param {LogData} logData - The log data to serialize.
* @returns {LogData} The log data with serialized metadata values.
*/
export declare function serializeMetadataValues(logData: LogData): LogData;
/**
* Serializes values in a metadata object.
* @param {{ [key: string]: any }} metadata - The metadata object to serialize.
* @returns {{ [key: string]: string }} An object with all values serialized to strings.
*/
export declare function serializeValues(metadata: {
[key: string]: any;
}): {
[key: string]: string;
};
/**
* Serializes metadata values in an update log.
* @param {UpdateLog} logData - The update log data to serialize.
* @returns {UpdateLog} The update log with serialized metadata values.
*/
export declare function serializeMetadataValuesUpdate(logData: UpdateLog): UpdateLog;