UNPKG

flowise-sdk

Version:

Flowise SDK for streaming API responses.

53 lines (52 loc) 1.28 kB
export interface PredictionData { chatflowId: string; question: string; overrideConfig?: Record<string, any>; chatId?: string; streaming?: boolean; history?: IMessage[]; uploads?: IFileUpload[]; leadEmail?: string; action?: IAction; } interface IAction { id?: string; elements?: Array<{ type: string; label: string; }>; mapping?: { approve: string; reject: string; toolCalls: any[]; }; } interface IFileUpload { data?: string; type: string; name: string; mime: string; } interface IMessage { message: string; type: MessageType; role?: MessageType; content?: string; } type MessageType = 'apiMessage' | 'userMessage'; export interface StreamResponse { event: string; data: string; } interface FlowiseClientOptions { baseUrl?: string; apiKey?: string; } type PredictionResponse<T extends PredictionData> = T['streaming'] extends true ? AsyncGenerator<StreamResponse, void, unknown> : Record<string, any>; export default class FlowiseClient { private baseUrl; private apiKey; constructor(options?: FlowiseClientOptions); createPrediction<T extends PredictionData>(data: T): Promise<PredictionResponse<T>>; } export {};