kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
feat: add gpt-4 demo
rodzic
320ac10b2a
commit
fcc84b61e4
|
@ -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)
|
||||||
|
})
|
Ładowanie…
Reference in New Issue