MCPcopy Create free account
hub / github.com/TechJeeper/Printventory / saveModelFromUpload

Function saveModelFromUpload

main.js:9740–9772  ·  view source on GitHub ↗
(payload)

Source from the content-addressed store, hash-verified

9738 puterPendingRequests.set(requestId, { resolve, reject, webContents, wsClient });
9739
9740 // In server mode with WebSocket client, send via WebSocket
9741 // This routes to the browser client where Puter.js is loaded and can show the captcha
9742 if (isServerMode && wsClient) {
9743 console.log('[Puter AI] Sending request to browser client via WebSocket (captcha will appear in browser window)');
9744 wsClient.send(JSON.stringify({
9745 type: 'event',
9746 channel: 'puter-ai-chat-request',
9747 args: [requestId, prompt, imageUrl, model]
9748 }));
9749 } else if (webContents) {
9750 // Normal mode: use the webContents from the event
9751 webContents.send('puter-ai-chat-request', requestId, prompt, imageUrl, model);
9752 } else if (mainWindow && !mainWindow.isDestroyed()) {
9753 // Fallback: use mainWindow (for backward compatibility)
9754 mainWindow.webContents.send('puter-ai-chat-request', requestId, prompt, imageUrl, model);
9755 } else {
9756 reject(new Error('No valid client available for Puter AI request'));
9757 return;
9758 }
9759
9760 // Timeout after 60 seconds
9761 setTimeout(() => {
9762 if (puterPendingRequests.has(requestId)) {
9763 puterPendingRequests.delete(requestId);
9764 reject(new Error('Puter AI request timeout'));
9765 }
9766 }, 60000);
9767 });
9768 };
9769}
9770
9771// IPC handler for puter.com AI calls (forwards to renderer)
9772ipcMain.handle('puter-ai-chat', async (event, prompt, imageUrl, model) => {
9773 // Pass event so it can route to the correct client (WebSocket in server mode, IPC in normal mode)
9774 const handler = createPuterIPCHandler(event);
9775 return await handler(prompt, imageUrl, model);

Callers 2

startHttpServerFunction · 0.85
main.jsFile · 0.85

Calls 1

saveModelFunction · 0.85

Tested by

no test coverage detected