UNPKG

unlimited-ai

Version:

Fast, minimal Node.js wrapper for the Voids API AI chat completions.

106 lines 3.11 kB
//#region src/types.d.ts type Role = "system" | "user" | "assistant"; interface Message { role: Role; content: string; } interface CompletionResponse { id: string; object: string; created: number; model: string; choices: Array<{ index: number; message: { role: string; content: string; }; finish_reason: string; }>; usage: { prompt_tokens: number; completion_tokens: number; total_tokens: number; }; } interface ModelListResponse { object: string; data: Array<{ id: string; object: string; owned_by: string; }>; } type ConversationStore = Record<string, Message[]>; interface StreamChunk { id: string; object: string; created: number; model: string; choices: Array<{ index: number; delta: { content?: string; role?: string; }; finish_reason: string | null; }>; } //#endregion //#region src/client.d.ts declare class AI { private model; private messages; private useSearch; private conversationMap; private activeConversationId; constructor(init?: { model?: string; messages?: Message[]; system?: string; }); setModel(model: string, search?: boolean): this; setMessages(messages: Message[]): this; addMessage(message: Message): this; removeMessage(index: number): this; clearMessages(): this; setSystem(content: string): this; useConversation(id: string | null): this; listConversations(): string[]; getConversationMessages(id: string): Message[]; clearConversation(id: string): this; deleteConversation(id: string): this; exportConversations(id: string): Message[]; exportConversations(): ConversationStore; importConversations(data: ConversationStore, replace?: boolean): this; generate(raw: true): Promise<CompletionResponse>; generate(raw?: false): Promise<string>; ask(prompt: string, conversationId?: string): Promise<string>; stream(prompt: string, conversationId?: string): AsyncGenerator<string>; getFormat(): { model: string; messages: Message[]; }; } //#endregion //#region src/generate.d.ts declare function generate(model: string, messages: Message[], raw: true): Promise<CompletionResponse>; declare function generate(model: string, messages: Message[], raw?: false): Promise<string>; declare function stream(model: string, messages: Message[]): AsyncGenerator<string>; declare function ask(model: string, prompt: string, system?: string): Promise<string>; //#endregion //#region src/models.d.ts declare function models(): Promise<string[]>; //#endregion //#region src/search.d.ts declare function searchModels(word: string): Promise<string[]>; //#endregion //#region src/config.d.ts declare const config: { readonly API_URL: "https://api.voids.top/v1/chat/completions"; readonly MODELS_URL: "https://api.voids.top/v1/models"; }; type Config = typeof config; //#endregion export { AI, type CompletionResponse, type Config, type ConversationStore, type Message, type ModelListResponse, type Role, type StreamChunk, ask, config, generate, models, searchModels, stream }; //# sourceMappingURL=index.d.cts.map