Skip to content

Commit

Permalink
feat: add google auth demo
Browse files Browse the repository at this point in the history
  • Loading branch information
transitive-bullshit committed Jan 11, 2023
1 parent 980c8fd commit a70d6f5
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions demos/demo-google-auth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import dotenv from 'dotenv-safe'
import { oraPromise } from 'ora'

import { ChatGPTAPIBrowser } from '../src'

dotenv.config()

/**
* Demo CLI for testing basic functionality using Google auth.
*
* ```
* npx tsx demos/demo.ts
* ```
*/
async function main() {
const email = process.env.OPENAI_EMAIL
const password = process.env.OPENAI_PASSWORD

const api = new ChatGPTAPIBrowser({
email,
password,
isGoogleLogin: true,
debug: false,
minimize: true
})
await api.initSession()

const prompt =
'Write a python version of bubble sort. Do not include example usage.'

const res = await oraPromise(api.sendMessage(prompt), {
text: prompt
})
console.log(res.response)

// close the browser at the end
await api.closeSession()
}

main().catch((err) => {
console.error(err)
process.exit(1)
})

0 comments on commit a70d6f5

Please sign in to comment.