Skip to content

Commit

Permalink
feat: add gpt-4 demo
Browse files Browse the repository at this point in the history
  • Loading branch information
transitive-bullshit committed Mar 15, 2023
1 parent 320ac10 commit fcc84b6
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions demos/demo-gpt-4.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import dotenv from 'dotenv-safe'
import { oraPromise } from 'ora'

import { ChatGPTAPI } from '../src'

dotenv.config()

/**
* Demo CLI for testing the GPT-4 model.
*
* ```
* npx tsx demos/demo-gpt-4.ts
* ```
*/
async function main() {
const api = new ChatGPTAPI({
apiKey: process.env.OPENAI_API_KEY,
debug: true,
completionParams: {
model: 'gpt-4'
}
})

const prompt = 'When should you use Python vs TypeScript?'

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

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

0 comments on commit fcc84b6

Please sign in to comment.