forked from transitive-bullshit/agentic
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
320ac10
commit fcc84b6
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
}) |