diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index da7ce04f4..9d2dc4cbf 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,6 +24,7 @@ jobs: - name: Build run: | + rm package-lock.json npm install npm run test diff --git a/src/puter-js/index.d.ts b/src/puter-js/index.d.ts index 5693f826c..bcfcd334a 100644 --- a/src/puter-js/index.d.ts +++ b/src/puter-js/index.d.ts @@ -32,11 +32,19 @@ declare class Puter { // AI Module interface AI { - chat(prompt: string, options?: ChatOptions): Promise | AsyncIterable; - chat(prompt: string, testMode?: boolean, options?: ChatOptions): Promise | AsyncIterable; - chat(prompt: string, imageURL?: string, testMode?: boolean, options?: ChatOptions): Promise | AsyncIterable; - chat(prompt: string, imageURLArray?: string[], testMode?: boolean, options?: ChatOptions): Promise | AsyncIterable; - chat(messages: ChatMessage[], testMode?: boolean, options?: ChatOptions): Promise | AsyncIterable; + // Streaming overloads + chat(prompt: string, options: StreamingChatOptions): AsyncIterable; + chat(prompt: string, testMode: boolean, options: StreamingChatOptions): AsyncIterable; + chat(prompt: string, imageURL: string, testMode: boolean, options: StreamingChatOptions): AsyncIterable; + chat(prompt: string, imageURLArray: string[], testMode: boolean, options: StreamingChatOptions): AsyncIterable; + chat(messages: ChatMessage[], testMode: boolean, options: StreamingChatOptions): AsyncIterable; + + // Non-streaming overloads + chat(prompt: string, options?: NonStreamingChatOptions): Promise; + chat(prompt: string, testMode?: boolean, options?: NonStreamingChatOptions): Promise; + chat(prompt: string, imageURL?: string, testMode?: boolean, options?: NonStreamingChatOptions): Promise; + chat(prompt: string, imageURLArray?: string[], testMode?: boolean, options?: NonStreamingChatOptions): Promise; + chat(messages: ChatMessage[], testMode?: boolean, options?: NonStreamingChatOptions): Promise; img2txt(image: string | File | Blob, testMode?: boolean): Promise; @@ -50,6 +58,9 @@ interface AI { txt2speech(text: string, language?: string, voice?: string, engine?: string): Promise; } +type StreamingChatOptions = Omit & { stream: true }; +type NonStreamingChatOptions = Omit & { stream?: false | undefined }; + interface ChatOptions { model?: string; stream?: boolean;