@pipedream/openai 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
1
1
  import axios from "axios";
2
+ import Bottleneck from "bottleneck";
2
3
  import fs from "fs";
3
4
  import {
4
5
  join, extname,
@@ -21,7 +22,7 @@ const pipelineAsync = promisify(stream.pipeline);
21
22
 
22
23
  export default {
23
24
  name: "Create Transcription",
24
- version: "0.0.3",
25
+ version: "0.0.5",
25
26
  key: "openai-create-transcription",
26
27
  description: "Transcribes audio into the input language. [See docs here](https://platform.openai.com/docs/api-reference/audio/create).",
27
28
  type: "action",
@@ -157,11 +158,18 @@ export default {
157
158
  async transcribeFiles({
158
159
  files, outputDir, $,
159
160
  }) {
160
- const transcriptions = await Promise.all(files.map((file) => this.transcribe({
161
- file,
162
- outputDir,
163
- $,
164
- })));
161
+ const limiter = new Bottleneck({
162
+ maxConcurrent: 1,
163
+ minTime: 1000 / 59,
164
+ });
165
+
166
+ const transcriptions = await Promise.all(files.map((file) => {
167
+ return limiter.schedule(() => this.transcribe({
168
+ file,
169
+ outputDir,
170
+ $,
171
+ }));
172
+ }));
165
173
  return transcriptions.join(" ");
166
174
  },
167
175
  async transcribe({
@@ -194,6 +202,7 @@ export default {
194
202
  if (!fs.existsSync(path)) {
195
203
  throw new Error(`${path} does not exist`);
196
204
  }
205
+
197
206
  file = path;
198
207
  } else if (url) {
199
208
  const ext = extname(url);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/openai",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Pipedream OpenAI Components",
5
5
  "main": "app/openai.app.mjs",
6
6
  "keywords": [