kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
docs: update demo to remove redundant browser conversation demo
rodzic
726550b55b
commit
025e7e3a24
|
@ -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)
|
||||
})
|
|
@ -71,6 +71,7 @@ async function main() {
|
|||
)
|
||||
console.log('\n' + res.response + '\n')
|
||||
|
||||
// close the browser at the end
|
||||
await api.closeSession()
|
||||
}
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
Ładowanie…
Reference in New Issue