Skip to content

Commit 3b1b878

Browse files
authored
fix(openAI): inline config (#170)
1 parent c4d2f12 commit 3b1b878

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

.grit/patterns/openai_v4.md

+22-7
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,19 @@ language js
1414
pattern change_constructor() {
1515
`new $constructor($params)` where {
1616
$constructor <: `OpenAIApi` => `OpenAI`,
17-
$params <: [$config],
18-
$program <: contains or {
19-
`const $config = new Configuration($details)`,
20-
`let $config = new Configuration($details)`,
21-
`var $config = new Configuration($details)`
22-
} => .,
17+
or {
18+
$params <: contains `new Configuration($details)`,
19+
and {
20+
$params <: [$config],
21+
$program <: contains or {
22+
`const $config = new Configuration($details)`,
23+
`let $config = new Configuration($details)`,
24+
`var $config = new Configuration($details)`
25+
} => .,
26+
}
27+
},
2328
$params => `$details`,
24-
$program <: contains change_imports(),
29+
$program <: maybe contains change_imports(),
2530
}
2631
}
2732
@@ -347,11 +352,21 @@ const response = await openai.audio.transcriptions.create({
347352
## File handling
348353

349354
```js
355+
const openai = new OpenAIApi(
356+
new Configuration({
357+
apiKey: process.env.OPENAI_API_KEY,
358+
}),
359+
);
360+
350361
const myFile = await openai.downloadFile('my-file', options);
351362
console.log(myFile);
352363
```
353364

354365
```ts
366+
const openai = new OpenAI({
367+
apiKey: process.env.OPENAI_API_KEY,
368+
});
369+
355370
const myFile = await openai.files.retrieveContent('my-file', options);
356371
console.log(myFile);
357372
```

0 commit comments

Comments
 (0)