From b5698e3ae2fdc2f4db822341d31d8db269bd7af1 Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Wed, 18 Jan 2023 00:21:05 -0600 Subject: [PATCH] chore: remove unused code --- src/chatgpt-api-browser.ts | 106 ------------------------------------- 1 file changed, 106 deletions(-) diff --git a/src/chatgpt-api-browser.ts b/src/chatgpt-api-browser.ts index 2722f23..866316a 100644 --- a/src/chatgpt-api-browser.ts +++ b/src/chatgpt-api-browser.ts @@ -421,69 +421,6 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI { } } - // async getLastMessage(): Promise { - // const messages = await this.getMessages() - - // if (messages) { - // return messages[messages.length - 1] - // } else { - // return null - // } - // } - - // async getPrompts(): Promise { - // // Get all prompts - // const messages = await this._page.$$( - // '.text-base:has(.whitespace-pre-wrap):not(:has(button:nth-child(2))) .whitespace-pre-wrap' - // ) - - // // Prompts are always plaintext - // return Promise.all(messages.map((a) => a.evaluate((el) => el.textContent))) - // } - - // async getMessages(): Promise { - // // Get all complete messages - // // (in-progress messages that are being streamed back don't contain action buttons) - // const messages = await this._page.$$( - // '.text-base:has(.whitespace-pre-wrap):has(button:nth-child(2)) .whitespace-pre-wrap' - // ) - - // if (this._markdown) { - // const htmlMessages = await Promise.all( - // messages.map((a) => a.evaluate((el) => el.innerHTML)) - // ) - - // const markdownMessages = htmlMessages.map((messageHtml) => { - // // parse markdown from message HTML - // messageHtml = messageHtml - // .replaceAll('Copy code', '') - // .replace(/Copy code\s*<\/button>/gim, '') - - // return html2md(messageHtml, { - // ignoreTags: [ - // 'button', - // 'svg', - // 'style', - // 'form', - // 'noscript', - // 'script', - // 'meta', - // 'head' - // ], - // skipTags: ['button', 'svg'] - // }) - // }) - - // return markdownMessages - // } else { - // // plaintext - // const plaintextMessages = await Promise.all( - // messages.map((a) => a.evaluate((el) => el.textContent)) - // ) - // return plaintextMessages - // } - // } - override async sendMessage( message: string, opts: types.SendMessageOptions = {} @@ -619,49 +556,6 @@ export class ChatGPTAPIBrowser extends AChatGPTAPI { } while (!result) cleanup() - // console.log('<<< EVALUATE', result) - - // const lastMessage = await this.getLastMessage() - - // await inputBox.focus() - // const paragraphs = message.split('\n') - // for (let i = 0; i < paragraphs.length; i++) { - // await inputBox.type(paragraphs[i], { delay: 0 }) - // if (i < paragraphs.length - 1) { - // await this._page.keyboard.down('Shift') - // await inputBox.press('Enter') - // await this._page.keyboard.up('Shift') - // } else { - // await inputBox.press('Enter') - // } - // } - - // const responseP = new Promise(async (resolve, reject) => { - // try { - // do { - // await delay(1000) - - // // TODO: this logic needs some work because we can have repeat messages... - // const newLastMessage = await this.getLastMessage() - // if ( - // newLastMessage && - // lastMessage?.toLowerCase() !== newLastMessage?.toLowerCase() - // ) { - // return resolve(newLastMessage) - // } - // } while (true) - // } catch (err) { - // return reject(err) - // } - // }) - - // if (timeoutMs) { - // return pTimeout(responseP, { - // milliseconds: timeoutMs - // }) - // } else { - // return responseP - // } } async resetThread() {