UNPKG

@butlerbot/sdk

Version:

The official ButlerBot SDK

63 lines (62 loc) 2.71 kB
import { RequestResponse } from "../types/dialogue_response_v3"; export type DialogueRequestParams = { /** Unique identifier for the chat session */ chatId?: string; /** The message to be sent to the AI */ message: string; /** AI model to use for generating responses */ model?: string; /** Additional instructions for location-specific context */ instructions?: string; /** Platform where the chat is occurring */ platform?: string; /** Custom personality configuration for the AI */ personality?: string; }; export type DialogueRequestOptions = Omit<Omit<DialogueRequestParams, "message">, "chatId">; export type ConversationOptions = { /** The conversation ID to load the conversation from, server will error if this convo id doesn't exist */ convoId?: string; /** The API key to use */ apiKey: string; /** The server URL to use */ serverUrl?: string; /** The path to append to the server URL specifying the API endpoint to use */ path?: string; /** Whether to enable debug logs */ debug?: boolean; }; export declare class Conversation { convoId?: string; apiKey: string; private debug; private options?; private endpoint; constructor(config: ConversationOptions); /** Sets the endpoint where the request is sent to, appended to server URL */ setEndpoint(endpoint: string): this; /** Sets the conversation ID, has to be an existing conversation ID, undefined otherwise */ setConvoId(convoId: string | undefined): this; /** Sets the AI model used for the next interaction, e.g Claude-Sonnet, GPT-4 */ setModel(model: string): this; /** Sets additional instructions for location-specific context */ setInstructions(instructions: string): this; /** Sets the platform where the chat is occurring, used internally for logging - ignore in most contexts */ setPlatform(platform: string): this; /** Sets a custom personality configuration for the AI */ setPersonality(personality: string): this; /** Gets the current conversation ID */ getConvoId(): string | undefined; /** Gets the current endpoint */ getEndpoint(): string; /** Gets the current options object */ getModel(): string | undefined; /** Gets the current location-specific instructions */ getInstructions(): string | undefined; /** Gets the current platform */ getPlatform(): string | undefined; /** Gets the current personality configuration */ getPersonality(): string | undefined; /** Sends a message into the conversation */ send(message: string, cb: (chunk: RequestResponse) => any, options?: DialogueRequestOptions): Promise<void>; }