@heyputer/puter.js 2.0.2 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts DELETED
@@ -1,479 +0,0 @@
1
- declare global {
2
- interface Window {
3
- puter: Puter;
4
- }
5
- }
6
-
7
- declare namespace Puter {
8
- // Main Puter interface
9
- interface Puter {
10
- // Properties
11
- appID: string;
12
- env: 'app' | 'web' | 'gui';
13
-
14
- // Utility methods
15
- print(text: string, options?: { code?: boolean }): void;
16
- randName(separator?: string): string;
17
- exit(statusCode?: number): void;
18
-
19
- // Sub-modules
20
- ai: AI;
21
- apps: Apps;
22
- auth: Auth;
23
- drivers: Drivers;
24
- fs: FileSystem;
25
- hosting: Hosting;
26
- kv: KV;
27
- net: Networking;
28
- perms: Permissions;
29
- ui: UI;
30
- workers: Workers;
31
- }
32
-
33
- // AI Module
34
- interface AI {
35
- chat(prompt: string, options?: ChatOptions): Promise<ChatResponse>;
36
- chat(prompt: string, testMode?: boolean, options?: ChatOptions): Promise<ChatResponse>;
37
- chat(prompt: string, imageURL?: string, testMode?: boolean, options?: ChatOptions): Promise<ChatResponse>;
38
- chat(prompt: string, imageURLArray?: string[], testMode?: boolean, options?: ChatOptions): Promise<ChatResponse>;
39
- chat(messages: ChatMessage[], testMode?: boolean, options?: ChatOptions): Promise<ChatResponse>;
40
-
41
- img2txt(image: string | File | Blob, testMode?: boolean): Promise<string>;
42
-
43
- txt2img(prompt: string, testMode?: boolean): Promise<HTMLImageElement>;
44
- txt2img(prompt: string, options?: Txt2ImgOptions): Promise<HTMLImageElement>;
45
-
46
- txt2speech(text: string): Promise<HTMLAudioElement>;
47
- txt2speech(text: string, options?: Txt2SpeechOptions): Promise<HTMLAudioElement>;
48
- txt2speech(text: string, language?: string): Promise<HTMLAudioElement>;
49
- txt2speech(text: string, language?: string, voice?: string): Promise<HTMLAudioElement>;
50
- txt2speech(text: string, language?: string, voice?: string, engine?: string): Promise<HTMLAudioElement>;
51
- }
52
-
53
- interface ChatOptions {
54
- model?: string;
55
- stream?: boolean;
56
- max_tokens?: number;
57
- temperature?: number;
58
- tools?: ToolDefinition[];
59
- }
60
-
61
- interface ToolDefinition {
62
- type: 'function';
63
- function: {
64
- name: string;
65
- description: string;
66
- parameters: object;
67
- strict?: boolean;
68
- };
69
- }
70
-
71
- interface ChatMessage {
72
- role: 'system' | 'assistant' | 'user' | 'function' | 'tool';
73
- content: string | ContentObject[];
74
- tool_call_id?: string;
75
- }
76
-
77
- interface ContentObject {
78
- type: 'text' | 'file';
79
- text?: string;
80
- puter_path?: string;
81
- }
82
-
83
- interface ChatResponse {
84
- message: {
85
- role: string;
86
- content: string;
87
- tool_calls?: ToolCall[];
88
- };
89
- }
90
-
91
- interface ToolCall {
92
- id: string;
93
- function: {
94
- name: string;
95
- arguments: string;
96
- };
97
- }
98
-
99
- interface Txt2ImgOptions {
100
- model?: 'gpt-image-1' | 'gemini-2.5-flash-image-preview' | 'dall-e-3';
101
- quality?: 'high' | 'medium' | 'low' | 'hd' | 'standard';
102
- input_image?: string;
103
- input_image_mime_type?: string;
104
- }
105
-
106
- interface Txt2SpeechOptions {
107
- language?: string;
108
- voice?: string;
109
- engine?: 'standard' | 'neural' | 'generative';
110
- }
111
-
112
- // Apps Module
113
- interface Apps {
114
- create(name: string, indexURL: string): Promise<App>;
115
- create(name: string, indexURL: string, title?: string): Promise<App>;
116
- create(name: string, indexURL: string, title?: string, description?: string): Promise<App>;
117
- create(options: CreateAppOptions): Promise<App>;
118
-
119
- delete(name: string): Promise<App>;
120
- get(name: string, options?: GetAppOptions): Promise<App>;
121
- list(options?: ListAppOptions): Promise<App[]>;
122
- update(name: string, attributes: UpdateAppAttributes): Promise<App>;
123
- }
124
-
125
- interface CreateAppOptions {
126
- name: string;
127
- indexURL: string;
128
- title?: string;
129
- description?: string;
130
- icon?: string;
131
- maximizeOnStart?: boolean;
132
- filetypeAssociations?: string[];
133
- }
134
-
135
- interface GetAppOptions {
136
- stats_period?: StatsPeriod;
137
- icon_size?: null | 16 | 32 | 64 | 128 | 256 | 512;
138
- }
139
-
140
- interface ListAppOptions extends GetAppOptions { }
141
-
142
- interface UpdateAppAttributes {
143
- name?: string;
144
- indexURL?: string;
145
- title?: string;
146
- description?: string;
147
- icon?: string;
148
- maximizeOnStart?: boolean;
149
- filetypeAssociations?: string[];
150
- }
151
-
152
- type StatsPeriod = 'all' | 'today' | 'yesterday' | '7d' | '30d' | 'this_month' | 'last_month' | 'this_year' | 'last_year' | 'month_to_date' | 'year_to_date' | 'last_12_months';
153
-
154
- interface App {
155
- uid: string;
156
- name: string;
157
- icon: string;
158
- description: string;
159
- title: string;
160
- maximize_on_start: boolean;
161
- index_url: string;
162
- created_at: string;
163
- background: boolean;
164
- filetype_associations: string[];
165
- open_count: number;
166
- user_count: number;
167
- }
168
-
169
- // Auth Module
170
- interface Auth {
171
- signIn(options?: { attempt_temp_user_creation?: boolean }): Promise<boolean>;
172
- signOut(): void;
173
- isSignedIn(): boolean;
174
- getUser(): Promise<User>;
175
- }
176
-
177
- interface User {
178
- uuid: string;
179
- username: string;
180
- email_confirmed: boolean;
181
- }
182
-
183
- // Drivers Module
184
- interface Drivers {
185
- call(interface: string, driver: string, method: string, args?: object): Promise<any>;
186
- }
187
-
188
- // FileSystem Module
189
- interface FileSystem {
190
- copy(source: string, destination: string, options?: CopyOptions): Promise<FSItem>;
191
- delete(path: string, options?: DeleteOptions): Promise<void>;
192
- getReadURL(path: string, expiresIn?: number): Promise<string>;
193
- mkdir(path: string, options?: MkdirOptions): Promise<FSItem>;
194
- move(source: string, destination: string, options?: MoveOptions): Promise<FSItem>;
195
- read(path: string, options?: ReadOptions): Promise<Blob>;
196
- readdir(path: string, options?: ReaddirOptions): Promise<FSItem[]>;
197
- readdir(options?: ReaddirOptions): Promise<FSItem[]>;
198
- rename(path: string, newName: string): Promise<FSItem>;
199
- space(): Promise<SpaceInfo>;
200
- stat(path: string): Promise<FSItem>;
201
- upload(items: FileList | File[] | Blob[], dirPath?: string, options?: object): Promise<FSItem[]>;
202
- write(path: string, data?: string | File | Blob, options?: WriteOptions): Promise<FSItem>;
203
- }
204
-
205
- interface CopyOptions {
206
- overwrite?: boolean;
207
- dedupeName?: boolean;
208
- newName?: string;
209
- }
210
-
211
- interface DeleteOptions {
212
- recursive?: boolean;
213
- descendantsOnly?: boolean;
214
- }
215
-
216
- interface MkdirOptions {
217
- overwrite?: boolean;
218
- dedupeName?: boolean;
219
- createMissingParents?: boolean;
220
- }
221
-
222
- interface MoveOptions extends CopyOptions {
223
- createMissingParents?: boolean;
224
- }
225
-
226
- interface ReadOptions {
227
- offset?: number;
228
- byte_count?: number;
229
- }
230
-
231
- interface ReaddirOptions {
232
- path?: string;
233
- uid?: string;
234
- }
235
-
236
- interface WriteOptions {
237
- overwrite?: boolean;
238
- dedupeName?: boolean;
239
- createMissingParents?: boolean;
240
- }
241
-
242
- interface SpaceInfo {
243
- capacity: number;
244
- used: number;
245
- }
246
-
247
- interface FSItem {
248
- id: string;
249
- uid: string;
250
- name: string;
251
- path: string;
252
- is_dir: boolean;
253
- parent_id: string;
254
- parent_uid: string;
255
- created: number;
256
- modified: number;
257
- accessed: number;
258
- size: number | null;
259
- writable: boolean;
260
- read(): Promise<Blob>;
261
- readdir(): Promise<FSItem[]>;
262
- }
263
-
264
- // Hosting Module
265
- interface Hosting {
266
- create(subdomain: string, dirPath?: string): Promise<Subdomain>;
267
- delete(subdomain: string): Promise<boolean>;
268
- get(subdomain: string): Promise<Subdomain>;
269
- list(): Promise<Subdomain[]>;
270
- update(subdomain: string, dirPath?: string): Promise<Subdomain>;
271
- }
272
-
273
- interface Subdomain {
274
- uid: string;
275
- subdomain: string;
276
- root_dir: FSItem;
277
- }
278
-
279
- // KV Module
280
- interface KV {
281
- set(key: string, value: string | number | boolean | object | any[]): Promise<boolean>;
282
- get(key: string): Promise<any>;
283
- del(key: string): Promise<boolean>;
284
- incr(key: string, amount?: number): Promise<number>;
285
- decr(key: string, amount?: number): Promise<number>;
286
- list(pattern?: string, returnValues?: boolean): Promise<string[] | KVPair[]>;
287
- list(returnValues?: boolean): Promise<string[] | KVPair[]>;
288
- flush(): Promise<boolean>;
289
- }
290
-
291
- interface KVPair {
292
- key: string;
293
- value: any;
294
- }
295
-
296
- // Networking Module
297
- interface Networking {
298
- fetch(url: string, options?: RequestInit): Promise<Response>;
299
- Socket: typeof Socket;
300
- tls: {
301
- TLSSocket: typeof TLSSocket;
302
- };
303
- }
304
-
305
- class Socket {
306
- constructor(hostname: string, port: number);
307
- write(data: ArrayBuffer | Uint8Array | string): void;
308
- close(): void;
309
- on(event: 'open', callback: () => void): void;
310
- on(event: 'data', callback: (buffer: Uint8Array) => void): void;
311
- on(event: 'error', callback: (reason: string) => void): void;
312
- on(event: 'close', callback: (hadError: boolean) => void): void;
313
- }
314
-
315
- class TLSSocket extends Socket {
316
- constructor(hostname: string, port: number);
317
- }
318
-
319
- // Permissions Module
320
- interface Permissions {
321
- grantApp(app_uid: string, permissionString: string): Promise<object>;
322
- grantAppAnyUser(app_uid: string, permissionString: string): Promise<object>;
323
- grantGroup(group_uid: string, permissionString: string): Promise<object>;
324
- grantOrigin(origin: string, permissionString: string): Promise<object>;
325
- grantUser(username: string, permissionString: string): Promise<object>;
326
- revokeApp(app_uid: string, permissionString: string): Promise<object>;
327
- revokeAppAnyUser(app_uid: string, permissionString: string): Promise<object>;
328
- revokeGroup(group_uid: string, permissionString: string): Promise<object>;
329
- revokeOrigin(origin: string, permissionString: string): Promise<object>;
330
- revokeUser(username: string, permissionString: string): Promise<object>;
331
- }
332
-
333
- // UI Module
334
- interface UI {
335
- alert(message?: string, buttons?: AlertButton[]): Promise<string>;
336
- prompt(message?: string, defaultValue?: string): Promise<string | null>;
337
- authenticateWithPuter(): Promise<boolean>;
338
- contextMenu(options: ContextMenuOptions): void;
339
- createWindow(options?: WindowOptions): void;
340
- exit(statusCode?: number): void;
341
- getLanguage(): Promise<string>;
342
- hideSpinner(): void;
343
- launchApp(appName?: string, args?: object): Promise<AppConnection>;
344
- launchApp(options: LaunchAppOptions): Promise<AppConnection>;
345
- on(eventName: 'localeChanged', handler: (data: { language: string }) => void): void;
346
- on(eventName: 'themeChanged', handler: (data: ThemeData) => void): void;
347
- onItemsOpened(handler: (items: FSItem[]) => void): void;
348
- onLaunchedWithItems(handler: (items: FSItem[]) => void): void;
349
- onWindowClose(handler: () => void): void;
350
- parentApp(): AppConnection | null;
351
- setMenubar(options: MenubarOptions): void;
352
- setWindowHeight(height: number): void;
353
- setWindowPosition(x: number, y: number): void;
354
- setWindowSize(width: number, height: number): void;
355
- setWindowTitle(title: string): void;
356
- setWindowWidth(width: number): void;
357
- setWindowX(x: number): void;
358
- setWindowY(y: number): void;
359
- showColorPicker(defaultColor?: string): Promise<string>;
360
- showColorPicker(options?: object): Promise<string>;
361
- showDirectoryPicker(options?: { multiple?: boolean }): Promise<FSItem | FSItem[]>;
362
- showFontPicker(defaultFont?: string): Promise<{ fontFamily: string }>;
363
- showFontPicker(options?: object): Promise<{ fontFamily: string }>;
364
- showOpenFilePicker(options?: FilePickerOptions): Promise<FSItem | FSItem[]>;
365
- showSaveFilePicker(data?: any, defaultFileName?: string): Promise<FSItem>;
366
- showSpinner(): void;
367
- socialShare(url: string, message?: string, options?: { left?: number; top?: number }): void;
368
- wasLaunchedWithItems(): boolean;
369
- }
370
-
371
- interface AlertButton {
372
- label: string;
373
- value?: string;
374
- type?: 'primary' | 'success' | 'info' | 'warning' | 'danger';
375
- }
376
-
377
- interface ContextMenuOptions {
378
- items: (ContextMenuItem | '-')[];
379
- }
380
-
381
- interface ContextMenuItem {
382
- label: string;
383
- action?: () => void;
384
- icon?: string;
385
- icon_active?: string;
386
- disabled?: boolean;
387
- items?: (ContextMenuItem | '-')[];
388
- }
389
-
390
- interface WindowOptions {
391
- center?: boolean;
392
- content?: string;
393
- disable_parent_window?: boolean;
394
- has_head?: boolean;
395
- height?: number;
396
- is_resizable?: boolean;
397
- show_in_taskbar?: boolean;
398
- title?: string;
399
- width?: number;
400
- }
401
-
402
- interface LaunchAppOptions {
403
- name?: string;
404
- args?: object;
405
- }
406
-
407
- interface ThemeData {
408
- palette: {
409
- primaryHue: number;
410
- primarySaturation: string;
411
- primaryLightness: string;
412
- primaryAlpha: number;
413
- primaryColor: string;
414
- };
415
- }
416
-
417
- interface MenubarOptions {
418
- items: MenuItem[];
419
- }
420
-
421
- interface MenuItem {
422
- label: string;
423
- action?: () => void;
424
- items?: MenuItem[];
425
- }
426
-
427
- interface FilePickerOptions {
428
- multiple?: boolean;
429
- accept?: string | string[];
430
- }
431
-
432
- interface AppConnection {
433
- usesSDK: boolean;
434
- on(eventName: 'message', handler: (message: any) => void): void;
435
- on(eventName: 'close', handler: (data: { appInstanceID: string }) => void): void;
436
- off(eventName: string, handler: Function): void;
437
- postMessage(message: any): void;
438
- close(): void;
439
- }
440
-
441
- // Workers Module
442
- interface Workers {
443
- create(workerName: string, filePath: string): Promise<WorkerDeployment>;
444
- delete(workerName: string): Promise<boolean>;
445
- exec(workerURL: string, options?: WorkerExecOptions): Promise<Response>;
446
- get(workerName: string): Promise<WorkerInfo>;
447
- list(): Promise<WorkerInfo[]>;
448
- }
449
-
450
- interface WorkerDeployment {
451
- success: boolean;
452
- url: string;
453
- errors: any[];
454
- }
455
-
456
- interface WorkerExecOptions extends RequestInit {
457
- method?: string;
458
- headers?: object;
459
- body?: string | object;
460
- cache?: RequestCache;
461
- credentials?: RequestCredentials;
462
- mode?: RequestMode;
463
- redirect?: RequestRedirect;
464
- referrer?: string;
465
- signal?: AbortSignal;
466
- }
467
-
468
- interface WorkerInfo {
469
- name: string;
470
- url: string;
471
- file_path: string;
472
- file_uid: string;
473
- created_at: string;
474
- }
475
- }
476
-
477
- declare const puter: Puter.Puter;
478
-
479
- export = Puter;
package/src/entry.js DELETED
@@ -1,9 +0,0 @@
1
- const goodContext = {}
2
-
3
- let puter;
4
- with (goodContext) {
5
- puter = await import('./src/index.js');
6
- }
7
-
8
-
9
- module.exports = { puter };
package/test/ai.test.js DELETED
@@ -1,214 +0,0 @@
1
- /* eslint-disable */
2
- // TODO: Make these more compatible with eslint
3
-
4
- // Define models to test
5
- const TEST_MODELS = [
6
- "openrouter:openai/gpt-4.1-mini",
7
- "openrouter:anthropic/claude-3.5-sonnet-20240620",
8
- "gpt-4o-mini",
9
- "openai/gpt-4.1-nano",
10
- "claude-sonnet-4-latest",
11
- // Add more models as needed
12
- ];
13
-
14
- // Core test functions that can be reused across models
15
- const testChatBasicPromptCore = async function(model) {
16
- // Test basic string prompt with test mode enabled
17
- const result = await puter.ai.chat("Hello, how are you?", { model: model });
18
-
19
- // Check that result is an object and not null
20
- assert(typeof result === 'object', "chat should return an object");
21
- assert(result !== null, "chat should not return null");
22
-
23
- // Check response structure
24
- assert(typeof result.message === 'object', "result should have message object");
25
- assert(typeof result.finish_reason === 'string', "result should have finish_reason string");
26
- assert(typeof result.via_ai_chat_service === 'boolean', "result should have via_ai_chat_service boolean");
27
-
28
- // Check message structure
29
- assert(typeof result.message.role === 'string', "message should have role string");
30
- assert(result.message.role === 'assistant', "message role should be 'assistant'");
31
- assert(typeof result.message.content === 'string' || Array.isArray(result.message.content), "message should have content string or an array");
32
-
33
- // Check that toString() and valueOf() methods exist and work
34
- assert(typeof result.toString === 'function', "result should have toString method");
35
- assert(typeof result.valueOf === 'function', "result should have valueOf method");
36
-
37
- // Check that toString() and valueOf() return the message content
38
- assert(result.toString() === result.message.content, "toString() should return message content");
39
- assert(result.valueOf() === result.message.content, "valueOf() should return message content");
40
-
41
- // Content should not be empty
42
- assert(result.message.content.length > 0, "message content should not be empty");
43
- };
44
-
45
- const testChatWithParametersCore = async function(model) {
46
- // Test chat with parameters object
47
- const result = await puter.ai.chat("What is 2+2?", {
48
- model: model,
49
- temperature: 0.7,
50
- max_tokens: 50
51
- });
52
-
53
- // Check basic result structure
54
- assert(typeof result === 'object', "chat should return an object");
55
- assert(result !== null, "chat should not return null");
56
- assert(typeof result.message === 'object', "result should have message object");
57
- assert(typeof result.message.content === 'string' || Array.isArray(result.message.content), "result.message should have content string or an array");
58
-
59
- // Check that the methods work
60
- assert(typeof result.toString === 'function', "result should have toString method");
61
- assert(typeof result.valueOf === 'function', "result should have valueOf method");
62
-
63
- // Check that finish_reason is present and valid
64
- const validFinishReasons = ['stop', 'length', 'function_call', 'content_filter', 'tool_calls'];
65
- assert(validFinishReasons.includes(result.finish_reason),
66
- `finish_reason should be one of: ${validFinishReasons.join(', ')}`);
67
-
68
- // Check that via_ai_chat_service is true
69
- assert(result.via_ai_chat_service === true, "via_ai_chat_service should be true");
70
- };
71
-
72
- const testChatWithMessageArrayCore = async function(model) {
73
- // Test chat with message array format
74
- const messages = [
75
- { role: "system", content: "You are a helpful assistant." },
76
- { role: "user", content: "Hello!" }
77
- ];
78
- const result = await puter.ai.chat(messages, { model: model });
79
-
80
- // Check basic structure
81
- assert(typeof result === 'object', "chat should return an object");
82
- assert(typeof result.message === 'object', "result should have message object");
83
- assert(result.message.role === 'assistant', "response should be from assistant");
84
-
85
- // Check that content is present and not empty
86
- assert(result.message.content.length > 0, "message content should not be empty");
87
- };
88
-
89
- const testChatStreamingCore = async function(model) {
90
- // Test chat with streaming enabled
91
- const result = await puter.ai.chat("Count from 1 to 5", {
92
- model: model,
93
- stream: true,
94
- max_tokens: 100
95
- });
96
-
97
- // Check that result is an object and not null
98
- assert(typeof result === 'object', "streaming chat should return an object");
99
- assert(result !== null, "streaming chat should not return null");
100
-
101
- // For streaming, we need to check if it's an async iterator or has a different structure
102
- // The exact structure depends on the implementation, but we should verify it's consumable
103
- if (result[Symbol.asyncIterator]) {
104
- // If it's an async iterator, test that we can consume it
105
- let chunks = [];
106
- let chunkCount = 0;
107
- const maxChunks = 10; // Limit to prevent infinite loops in tests
108
-
109
- for await (const chunk of result) {
110
- chunks.push(chunk);
111
- chunkCount++;
112
-
113
- // Verify each chunk has expected structure
114
- assert(typeof chunk === 'object', "each streaming chunk should be an object");
115
-
116
- // Break after reasonable number of chunks for testing
117
- if (chunkCount >= maxChunks) break;
118
- }
119
-
120
- assert(chunks.length > 0, "streaming should produce at least one chunk");
121
-
122
- } else {
123
- // If not an async iterator, it might be a different streaming implementation
124
- // Check for common streaming response patterns
125
-
126
- // Check basic result structure (similar to non-streaming but may have different properties)
127
- assert(typeof result.message === 'object' || typeof result.content === 'string',
128
- "streaming result should have message object or content string");
129
-
130
- // Check that it has streaming-specific properties
131
- assert(typeof result.stream === 'boolean' || result.stream === true,
132
- "streaming result should indicate it's a stream");
133
-
134
- // Check that toString() and valueOf() methods exist and work
135
- assert(typeof result.toString === 'function', "streaming result should have toString method");
136
- assert(typeof result.valueOf === 'function', "streaming result should have valueOf method");
137
- }
138
- };
139
-
140
- // Function to generate test functions for a specific model
141
- const generateTestsForModel = function(model) {
142
- const modelName = model.replace(/[^a-zA-Z0-9]/g, '_'); // Sanitize model name for function names
143
-
144
- return {
145
- [`testChatBasicPrompt_${modelName}`]: {
146
- name: `testChatBasicPrompt_${modelName}`,
147
- description: `Test basic AI chat prompt with ${model} model and verify response structure`,
148
- test: async function() {
149
- try {
150
- await testChatBasicPromptCore(model);
151
- pass(`testChatBasicPrompt_${modelName} passed`);
152
- } catch (error) {
153
- fail(`testChatBasicPrompt_${modelName} failed:`, error);
154
- }
155
- }
156
- },
157
-
158
- [`testChatWithParameters_${modelName}`]: {
159
- name: `testChatWithParameters_${modelName}`,
160
- description: `Test AI chat with parameters (temperature, max_tokens) using ${model} model`,
161
- test: async function() {
162
- try {
163
- await testChatWithParametersCore(model);
164
- pass(`testChatWithParameters_${modelName} passed`);
165
- } catch (error) {
166
- fail(`testChatWithParameters_${modelName} failed:`, error);
167
- }
168
- }
169
- },
170
-
171
- [`testChatWithMessageArray_${modelName}`]: {
172
- name: `testChatWithMessageArray_${modelName}`,
173
- description: `Test AI chat with message array format using ${model} model`,
174
- test: async function() {
175
- try {
176
- await testChatWithMessageArrayCore(model);
177
- pass(`testChatWithMessageArray_${modelName} passed`);
178
- } catch (error) {
179
- fail(`testChatWithMessageArray_${modelName} failed:`, error);
180
- }
181
- }
182
- },
183
-
184
- [`testChatStreaming_${modelName}`]: {
185
- name: `testChatStreaming_${modelName}`,
186
- description: `Test AI chat with streaming enabled using ${model} model`,
187
- test: async function() {
188
- try {
189
- await testChatStreamingCore(model);
190
- pass(`testChatStreaming_${modelName} passed`);
191
- } catch (error) {
192
- fail(`testChatStreaming_${modelName} failed:`, error);
193
- }
194
- }
195
- },
196
- };
197
- };
198
-
199
- // Generate all test functions for all models
200
- const generateAllTests = function() {
201
- const allTests = [];
202
-
203
- TEST_MODELS.forEach(model => {
204
- const modelTests = generateTestsForModel(model);
205
- Object.values(modelTests).forEach(test => {
206
- allTests.push(test);
207
- });
208
- });
209
-
210
- return allTests;
211
- };
212
-
213
- // Export the generated tests
214
- window.aiTests = generateAllTests();