UNPKG

mongodb-rag-core

Version:

Common elements used by MongoDB Chatbot Framework components.

78 lines 2.15 kB
import { Response } from "express"; import { OpenAiStreamingResponse } from "./llm"; import { References } from "./References"; export declare function escapeNewlines(str: string): string; interface StreamParams { stream: OpenAiStreamingResponse; references?: string; } type StreamEvent = { type: string; data: unknown; }; /** Event when server streams additional message response to the client. */ export type DeltaStreamEvent = StreamEvent & { type: "delta"; data: string; }; /** Event for when the server is processing a request. */ export type ProcessingStreamEvent = StreamEvent & { type: "processing"; /** Information about processing that is occurring. @example "Searching for related content" */ data: string; }; /** Event when server streams single {@link References} object to the client. */ export type ReferencesStreamEvent = StreamEvent & { type: "references"; data: References; }; /** Event when server streams a metadata object to the client. */ export type MetadataStreamEvent = StreamEvent & { type: "metadata"; data: Record<string, unknown>; }; /** Event denoting the end of streaming. */ export type FinishedStreamEvent = StreamEvent & { type: "finished"; data: string; }; /** Event when server streams the conversation ID to the client. */ export type ConversationIdStreamEvent = StreamEvent & { type: "conversationId"; data: string; }; /** The event types streamed from the chat server to the client. */ export type SomeStreamEvent = DeltaStreamEvent | MetadataStreamEvent | ProcessingStreamEvent | ReferencesStreamEvent | FinishedStreamEvent | ConversationIdStreamEvent; /** Service that streams data to the client. */ export interface DataStreamer { connected: boolean; connect(res: Response): void; disconnect(): void; streamData(data: SomeStreamEvent): void; stream(params: StreamParams): Promise<string>; } /** Create a {@link DataStreamer} that streams data to the client. */ export declare function makeDataStreamer(): DataStreamer; export {}; //# sourceMappingURL=DataStreamer.d.ts.map