mirror of
https://github.com/HeyPuter/puter.git
synced 2026-05-29 12:50:59 +00:00
add conditional type overload for streaming
This commit is contained in:
committed by
Neal Shah
parent
1affbb4cc8
commit
f60e02565f
@@ -24,6 +24,7 @@ jobs:
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
rm package-lock.json
|
||||
npm install
|
||||
npm run test
|
||||
|
||||
|
||||
Vendored
+16
-5
@@ -32,11 +32,19 @@ declare class Puter {
|
||||
|
||||
// AI Module
|
||||
interface AI {
|
||||
chat(prompt: string, options?: ChatOptions): Promise<ChatResponse> | AsyncIterable<ChatResponseChunk>;
|
||||
chat(prompt: string, testMode?: boolean, options?: ChatOptions): Promise<ChatResponse> | AsyncIterable<ChatResponseChunk>;
|
||||
chat(prompt: string, imageURL?: string, testMode?: boolean, options?: ChatOptions): Promise<ChatResponse> | AsyncIterable<ChatResponseChunk>;
|
||||
chat(prompt: string, imageURLArray?: string[], testMode?: boolean, options?: ChatOptions): Promise<ChatResponse> | AsyncIterable<ChatResponseChunk>;
|
||||
chat(messages: ChatMessage[], testMode?: boolean, options?: ChatOptions): Promise<ChatResponse> | AsyncIterable<ChatResponseChunk>;
|
||||
// Streaming overloads
|
||||
chat(prompt: string, options: StreamingChatOptions): AsyncIterable<ChatResponseChunk>;
|
||||
chat(prompt: string, testMode: boolean, options: StreamingChatOptions): AsyncIterable<ChatResponseChunk>;
|
||||
chat(prompt: string, imageURL: string, testMode: boolean, options: StreamingChatOptions): AsyncIterable<ChatResponseChunk>;
|
||||
chat(prompt: string, imageURLArray: string[], testMode: boolean, options: StreamingChatOptions): AsyncIterable<ChatResponseChunk>;
|
||||
chat(messages: ChatMessage[], testMode: boolean, options: StreamingChatOptions): AsyncIterable<ChatResponseChunk>;
|
||||
|
||||
// Non-streaming overloads
|
||||
chat(prompt: string, options?: NonStreamingChatOptions): Promise<ChatResponse>;
|
||||
chat(prompt: string, testMode?: boolean, options?: NonStreamingChatOptions): Promise<ChatResponse>;
|
||||
chat(prompt: string, imageURL?: string, testMode?: boolean, options?: NonStreamingChatOptions): Promise<ChatResponse>;
|
||||
chat(prompt: string, imageURLArray?: string[], testMode?: boolean, options?: NonStreamingChatOptions): Promise<ChatResponse>;
|
||||
chat(messages: ChatMessage[], testMode?: boolean, options?: NonStreamingChatOptions): Promise<ChatResponse>;
|
||||
|
||||
img2txt(image: string | File | Blob, testMode?: boolean): Promise<string>;
|
||||
|
||||
@@ -50,6 +58,9 @@ interface AI {
|
||||
txt2speech(text: string, language?: string, voice?: string, engine?: string): Promise<HTMLAudioElement>;
|
||||
}
|
||||
|
||||
type StreamingChatOptions = Omit<ChatOptions, "stream"> & { stream: true };
|
||||
type NonStreamingChatOptions = Omit<ChatOptions, "stream"> & { stream?: false | undefined };
|
||||
|
||||
interface ChatOptions {
|
||||
model?: string;
|
||||
stream?: boolean;
|
||||
|
||||
Reference in New Issue
Block a user