Skip to content

Commit

Permalink
Merge pull request transitive-bullshit#10 from brunoocal/main
Browse files Browse the repository at this point in the history
  • Loading branch information
transitive-bullshit authored Dec 5, 2022
2 parents 7b5fca8 + 53d9384 commit 8ac59b8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/chatgpt-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,14 @@ export class ChatGPTAPI {
} while (true)
}

async resetThread() {
const resetButton = await this._page.$('nav > a:nth-child(1)')

if (!resetButton) throw new Error('not signed in')

await resetButton.click()
}

async close() {
await this._browser.close()
this._page = null
Expand Down
9 changes: 8 additions & 1 deletion src/example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,16 @@ async function main() {
// Wait forever; useful for debugging chromium sessions
// await new Promise(() => {})

await api.resetThread()

const newResponse = await api.sendMessage(
// 'Write a TypeScript function for conway sort.'
'Write a javascript version of bubble sort. Do not include example usage.'
)

await api.close()

return response
return newResponse
}

main().then((res) => {
Expand Down

0 comments on commit 8ac59b8

Please sign in to comment.