This code provides a simple way to interact with OpenAI's GPT-3.5 Turbo model and measure the time taken for a completion request. It sends a prompt to the model and prints the response along with the time taken in milliseconds.
- Node.js installed on your system.
- An OpenAI API key.
- Clone this repository
- run
npm install
to install all the necessary dependencies
To run the applications, follow these steps:
1.You can run the application by using node index.js
or npm run start
commands
-runCompletion(prompt)
: Sends a prompt to the GPT-3.5 Turbo model and prints the response. Also calculates the time taken for the request.
-calculateTimeTaken(startTime)
: Calculates and prints the time taken for the request in milliseconds.
Example