Skip to content

Commit

Permalink
docs(README): fix variable names in some examples (#327)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot committed Sep 21, 2023
1 parent 8daf11f commit 5e05b31
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ const openai = new OpenAI({
});

async function main() {
const completion = await openai.chat.completions.create({
const chatCompletion = await openai.chat.completions.create({
messages: [{ role: 'user', content: 'Say this is a test' }],
model: 'gpt-3.5-turbo',
});

console.log(completion.choices);
console.log(chatCompletion.choices);
}

main();
Expand Down Expand Up @@ -81,7 +81,7 @@ async function main() {
messages: [{ role: 'user', content: 'Say this is a test' }],
model: 'gpt-3.5-turbo',
};
const completion: OpenAI.Chat.ChatCompletion = await openai.chat.completions.create(params);
const chatCompletion: OpenAI.Chat.ChatCompletion = await openai.chat.completions.create(params);
}

main();
Expand Down Expand Up @@ -226,8 +226,8 @@ You can use `for await … of` syntax to iterate through items across all pages:
async function fetchAllFineTuningJobs(params) {
const allFineTuningJobs = [];
// Automatically fetches more pages as needed.
for await (const job of openai.fineTuning.jobs.list({ limit: 20 })) {
allFineTuningJobs.push(job);
for await (const fineTuningJob of openai.fineTuning.jobs.list({ limit: 20 })) {
allFineTuningJobs.push(fineTuningJob);
}
return allFineTuningJobs;
}
Expand All @@ -237,8 +237,8 @@ Alternatively, you can make request a single page at a time:

```ts
let page = await openai.fineTuning.jobs.list({ limit: 20 });
for (const job of page.data) {
console.log(job);
for (const fineTuningJob of page.data) {
console.log(fineTuningJob);
}

// Convenience methods are provided for manually paginating:
Expand All @@ -265,11 +265,11 @@ const response = await openai.chat.completions
console.log(response.headers.get('X-My-Header'));
console.log(response.statusText); // access the underlying Response object

const { data: completions, response: raw } = await openai.chat.completions
const { data: chatCompletion, response: raw } = await openai.chat.completions
.create({ messages: [{ role: 'user', content: 'Say this is a test' }], model: 'gpt-3.5-turbo' })
.withResponse();
console.log(raw.headers.get('X-My-Header'));
console.log(completions.choices);
console.log(chatCompletion.choices);
```

## Configuring an HTTP(S) Agent (e.g., for proxies)
Expand Down

0 comments on commit 5e05b31

Please sign in to comment.