Skip to content

Commit 4b62b72

Browse files
committed
add back sample requests
1 parent 8863390 commit 4b62b72

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

samples/sample-usage.ts

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,20 @@ const configuration = new Configuration({
2727
const openai = new OpenAIApi(configuration);
2828

2929
const makeSampleRequests = async () => {
30-
const models = await openai.listModels();
31-
console.log({ models });
32-
// const completionOpts = {
33-
// model: 'text-ada-001',
34-
// prompt: 'write a poem about computers',
35-
// };
36-
// const completion1 = await openai.createCompletion(completionOpts);
37-
// console.log('completion 1:', completion1.data);
38-
39-
// // Ensure that another completion with the same prompt but
40-
// // slightly different options returns a different response:
41-
// const completion2 = await openai.createCompletion({
42-
// ...completionOpts,
43-
// max_tokens: 50,
44-
// });
45-
// console.log('completion 2:', completion2.data);
30+
const completionOpts = {
31+
model: 'text-ada-001',
32+
prompt: 'write a poem about computers',
33+
};
34+
const completion1 = await openai.createCompletion(completionOpts);
35+
console.log('completion 1:', completion1.data);
36+
37+
// Ensure that another completion with the same prompt but
38+
// slightly different options returns a different response:
39+
const completion2 = await openai.createCompletion({
40+
...completionOpts,
41+
max_tokens: 50,
42+
});
43+
console.log('completion 2:', completion2.data);
4644
};
4745

4846
const main = async () => {
@@ -53,7 +51,7 @@ const main = async () => {
5351
// Make the same requests a second time to confirm that
5452
// they are returning a cached result rather than
5553
// hitting OpenAI:
56-
// await makeSampleRequests();
54+
await makeSampleRequests();
5755
};
5856

5957
main();

0 commit comments

Comments
 (0)