From 025e7e3a245827a4693eae0e8c937ce77d81f6c1 Mon Sep 17 00:00:00 2001 From: Travis Fischer Date: Mon, 2 Jan 2023 17:28:35 -0600 Subject: [PATCH] docs: update demo to remove redundant browser conversation demo --- demos/demo-conversation-browser.ts | 81 ------------------------------ demos/demo-conversation.ts | 1 + readme.md | 6 --- 3 files changed, 1 insertion(+), 87 deletions(-) delete mode 100644 demos/demo-conversation-browser.ts diff --git a/demos/demo-conversation-browser.ts b/demos/demo-conversation-browser.ts deleted file mode 100644 index fd4c59db9..000000000 --- a/demos/demo-conversation-browser.ts +++ /dev/null @@ -1,81 +0,0 @@ -import dotenv from 'dotenv-safe' -import { oraPromise } from 'ora' - -import { ChatGPTAPIBrowser } from '../src' - -dotenv.config() - -/** - * Demo CLI for testing conversation support. - * - * ``` - * npx tsx demos/demo-conversation-browser.ts - * ``` - */ -async function main() { - const email = process.env.OPENAI_EMAIL - const password = process.env.OPENAI_PASSWORD - - const api = new ChatGPTAPIBrowser({ - email, - password, - debug: false, - minimize: true - }) - await api.initSession() - - const prompt = 'Write a poem about cats.' - - let res = await oraPromise(api.sendMessage(prompt), { - text: prompt - }) - - console.log('\n' + res.response + '\n') - - const prompt2 = 'Can you make it cuter and shorter?' - - res = await oraPromise( - api.sendMessage(prompt2, { - conversationId: res.conversationId, - parentMessageId: res.messageId - }), - { - text: prompt2 - } - ) - console.log('\n' + res.response + '\n') - - const prompt3 = 'Now write it in French.' - - res = await oraPromise( - api.sendMessage(prompt3, { - conversationId: res.conversationId, - parentMessageId: res.messageId - }), - { - text: prompt3 - } - ) - console.log('\n' + res.response + '\n') - - const prompt4 = 'What were we talking about again?' - - res = await oraPromise( - api.sendMessage(prompt4, { - conversationId: res.conversationId, - parentMessageId: res.messageId - }), - { - text: prompt4 - } - ) - console.log('\n' + res.response + '\n') - - // close the browser at the end - await api.closeSession() -} - -main().catch((err) => { - console.error(err) - process.exit(1) -}) diff --git a/demos/demo-conversation.ts b/demos/demo-conversation.ts index 86e3f92af..1c4d69499 100644 --- a/demos/demo-conversation.ts +++ b/demos/demo-conversation.ts @@ -71,6 +71,7 @@ async function main() { ) console.log('\n' + res.response + '\n') + // close the browser at the end await api.closeSession() } diff --git a/readme.md b/readme.md index 3c1457c33..bb44b1d67 100644 --- a/readme.md +++ b/readme.md @@ -203,12 +203,6 @@ A [conversation demo](./demos/demo-conversation.ts) is also included: npx tsx demos/demo-conversation.ts ``` -A [browser-based conversation demo](./demos/demo-conversation-browser.ts) is also included: - -```bash -npx tsx demos/demo-conversation-browser.ts -``` - ### Authentication The authentication section relates to the REST-based version (using `getOpenAIAuth` + `ChatGPTAPI`). The browser-based solution, `ChatGPTAPIBrowser`, takes care of all the authentication for you.