This TypeScript CLI tool helps you generate question-answer pairs for input examples using OpenAI's GPT-3. The tool takes a code example and a description, sends it to the GPT-3 API, receives question-answer pairs related to the input, and saves the generated data to a JSON file.
- Node.js 14.x or later
- An OpenAI API key
npm install
- Replace
your-api-key
in thegenerate_qa_pairs.ts
file with your OpenAI API key:
const apiKey = "your-api-key";
- Run the CLI tool:
npm start
-
Follow the prompts to enter a code example and a description. Press Enter on an full stop line to finish entering multiline input.
-
The generated question-answer pairs will be saved to a JSON file named output-TIMESTAMP.json, where TIMESTAMP is the current Unix timestamp.
Suppose you have the following input:
Q: Implement Pick<T, K>
A: ```
type MyPick<T, K extends keyof T> = {
[Key in K]: T[Key];
}
The CLI tool will send this input to the GPT-3 API and save the generated question-answer pairs to a JSON file.