@pipedream/openai 0.4.2 → 0.4.4

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.
Files changed (34) hide show
  1. package/actions/cancel-run/cancel-run.mjs +3 -3
  2. package/actions/chat/chat.mjs +1 -1
  3. package/actions/classify-items-into-categories/classify-items-into-categories.mjs +1 -1
  4. package/actions/create-assistant/create-assistant.mjs +1 -1
  5. package/actions/create-embeddings/create-embeddings.mjs +1 -1
  6. package/actions/create-fine-tuning-job/create-fine-tuning-job.mjs +1 -1
  7. package/actions/create-image/create-image.mjs +3 -3
  8. package/actions/create-message/create-message.mjs +3 -3
  9. package/actions/create-run/create-run.mjs +2 -2
  10. package/actions/create-speech/create-speech.mjs +2 -2
  11. package/actions/create-thread/create-thread.mjs +2 -2
  12. package/actions/create-thread-and-run/create-thread-and-run.mjs +2 -2
  13. package/actions/create-transcription/create-transcription.mjs +31 -10
  14. package/actions/delete-file/delete-file.mjs +1 -1
  15. package/actions/list-files/list-files.mjs +1 -1
  16. package/actions/list-messages/list-messages.mjs +3 -3
  17. package/actions/list-run-steps/list-run-steps.mjs +2 -2
  18. package/actions/list-runs/list-runs.mjs +2 -2
  19. package/actions/modify-assistant/modify-assistant.mjs +1 -1
  20. package/actions/modify-message/modify-message.mjs +3 -3
  21. package/actions/modify-run/modify-run.mjs +3 -3
  22. package/actions/retrieve-file/retrieve-file.mjs +1 -1
  23. package/actions/retrieve-file-content/retrieve-file-content.mjs +1 -1
  24. package/actions/retrieve-run/retrieve-run.mjs +3 -3
  25. package/actions/retrieve-run-step/retrieve-run-step.mjs +3 -3
  26. package/actions/send-prompt/send-prompt.mjs +1 -1
  27. package/actions/submit-tool-outputs-to-run/submit-tool-outputs-to-run.mjs +3 -3
  28. package/actions/summarize/summarize.mjs +1 -1
  29. package/actions/translate-text/translate-text.mjs +2 -2
  30. package/actions/upload-file/upload-file.mjs +1 -1
  31. package/openai.app.mjs +1 -1
  32. package/package.json +1 -1
  33. package/sources/new-file-created/new-file-created.mjs +1 -1
  34. package/sources/new-fine-tuning-job-created/new-fine-tuning-job-created.mjs +1 -1
@@ -2,9 +2,9 @@ import openai from "../../openai.app.mjs";
2
2
 
3
3
  export default {
4
4
  key: "openai-cancel-run",
5
- name: "Cancel Run",
6
- description: "Cancels a run that is in progress. [See the documentation](https://platform.openai.com/docs/api-reference)",
7
- version: "0.0.4",
5
+ name: "Cancel Run (Assistants)",
6
+ description: "Cancels a run that is in progress. [See the documentation](https://platform.openai.com/docs/api-reference/runs/cancelRun)",
7
+ version: "0.0.5",
8
8
  type: "action",
9
9
  props: {
10
10
  openai,
@@ -4,7 +4,7 @@ import common from "../common/common.mjs";
4
4
  export default {
5
5
  ...common,
6
6
  name: "Chat",
7
- version: "0.1.7",
7
+ version: "0.1.8",
8
8
  key: "openai-chat",
9
9
  description: "The Chat API, using the `gpt-3.5-turbo` or `gpt-4` model. [See docs here](https://platform.openai.com/docs/api-reference/chat)",
10
10
  type: "action",
@@ -3,7 +3,7 @@ import common from "../common/common-helper.mjs";
3
3
  export default {
4
4
  ...common,
5
5
  name: "Classify Items into Categories",
6
- version: "0.0.8",
6
+ version: "0.0.9",
7
7
  key: "openai-classify-items-into-categories",
8
8
  description: "Classify items into specific categories using the Chat API",
9
9
  type: "action",
@@ -5,7 +5,7 @@ export default {
5
5
  key: "openai-create-assistant",
6
6
  name: "Create Assistant",
7
7
  description: "Creates an assistant with a model and instructions. [See the docs here](https://platform.openai.com/docs/api-reference/assistants/createAssistant)",
8
- version: "0.1.1",
8
+ version: "0.1.2",
9
9
  type: "action",
10
10
  props: {
11
11
  openai,
@@ -4,7 +4,7 @@ import common from "../common/common.mjs";
4
4
 
5
5
  export default {
6
6
  name: "Create Embeddings",
7
- version: "0.0.6",
7
+ version: "0.0.7",
8
8
  key: "openai-create-embeddings",
9
9
  description: "Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms. [See the docs here](https://platform.openai.com/docs/api-reference/embeddings)",
10
10
  type: "action",
@@ -4,7 +4,7 @@ export default {
4
4
  key: "openai-create-fine-tuning-job",
5
5
  name: "Create Fine Tuning Job",
6
6
  description: "Creates a job that fine-tunes a specified model from a given dataset. [See the documentation](https://platform.openai.com/docs/api-reference/fine-tuning/create)",
7
- version: "0.0.3",
7
+ version: "0.0.4",
8
8
  type: "action",
9
9
  props: {
10
10
  openai,
@@ -1,10 +1,10 @@
1
1
  import openai from "../../openai.app.mjs";
2
2
 
3
3
  export default {
4
- name: "Create Image",
5
- version: "0.1.11",
4
+ name: "Create Image (Dall-E)",
5
+ version: "0.1.12",
6
6
  key: "openai-create-image",
7
- description: "Creates an image given a prompt. returns a URL to the image. [See docs here](https://platform.openai.com/docs/api-reference/images)",
7
+ description: "Creates an image given a prompt returning a URL to the image. [See docs here](https://platform.openai.com/docs/api-reference/images)",
8
8
  type: "action",
9
9
  props: {
10
10
  openai,
@@ -2,9 +2,9 @@ import openai from "../../openai.app.mjs";
2
2
 
3
3
  export default {
4
4
  key: "openai-create-message",
5
- name: "Create Message",
6
- description: "Create a message in a thread. [See the documentation](https://platform.openai.com/docs/api-reference)",
7
- version: "0.0.5",
5
+ name: "Create Message (Assistants)",
6
+ description: "Create a message in a thread. [See the documentation](https://platform.openai.com/docs/api-reference/messages/createMessage)",
7
+ version: "0.0.6",
8
8
  type: "action",
9
9
  props: {
10
10
  openai,
@@ -3,9 +3,9 @@ import openai from "../../openai.app.mjs";
3
3
 
4
4
  export default {
5
5
  key: "openai-create-run",
6
- name: "Create Run",
6
+ name: "Create Run (Assistants)",
7
7
  description: "Creates a run given a thread ID and assistant ID. [See the documentation](https://platform.openai.com/docs/api-reference/runs/create)",
8
- version: "0.1.1",
8
+ version: "0.1.2",
9
9
  type: "action",
10
10
  props: {
11
11
  openai,
@@ -3,9 +3,9 @@ import openai from "../../openai.app.mjs";
3
3
 
4
4
  export default {
5
5
  key: "openai-create-speech",
6
- name: "Create Speech",
6
+ name: "Create Speech (TTS)",
7
7
  description: "Generates audio from the input text. [See the documentation](https://platform.openai.com/docs/api-reference/audio/createSpeech)",
8
- version: "0.0.3",
8
+ version: "0.0.4",
9
9
  type: "action",
10
10
  props: {
11
11
  openai,
@@ -2,9 +2,9 @@ import openai from "../../openai.app.mjs";
2
2
 
3
3
  export default {
4
4
  key: "openai-create-thread",
5
- name: "Create Thread",
5
+ name: "Create Thread (Assistants)",
6
6
  description: "Creates a thread with optional messages and metadata. [See the documentation](https://platform.openai.com/docs/api-reference/threads/createThread)",
7
- version: "0.0.3",
7
+ version: "0.0.4",
8
8
  type: "action",
9
9
  props: {
10
10
  openai,
@@ -3,9 +3,9 @@ import openai from "../../openai.app.mjs";
3
3
 
4
4
  export default {
5
5
  key: "openai-create-thread-and-run",
6
- name: "Create Thread and Run",
6
+ name: "Create Thread and Run (Assistants)",
7
7
  description: "Create a thread and run it in one request using the specified assistant ID and optional parameters. [See the documentation](https://platform.openai.com/docs/api-reference)",
8
- version: "0.1.1",
8
+ version: "0.1.2",
9
9
  type: "action",
10
10
  props: {
11
11
  openai,
@@ -17,13 +17,14 @@ import constants from "../common/constants.mjs";
17
17
  import lang from "../common/lang.mjs";
18
18
 
19
19
  const COMMON_AUDIO_FORMATS_TEXT = "Your audio file must be in one of these formats: mp3, mp4, mpeg, mpga, m4a, wav, or webm.";
20
+ const CHUNK_SIZE_MB = 20;
20
21
 
21
22
  const execAsync = promisify(exec);
22
23
  const pipelineAsync = promisify(stream.pipeline);
23
24
 
24
25
  export default {
25
- name: "Create Transcription",
26
- version: "0.1.5",
26
+ name: "Create Transcription (Whisper)",
27
+ version: "0.1.7",
27
28
  key: "openai-create-transcription",
28
29
  description: "Transcribes audio into the input language. [See docs here](https://platform.openai.com/docs/api-reference/audio/create).",
29
30
  type: "action",
@@ -104,6 +105,18 @@ export default {
104
105
  form.append("file", readStream);
105
106
  return form;
106
107
  },
108
+ async splitLargeChunks(files, outputDir) {
109
+ for (const file of files) {
110
+ if (fs.statSync(`${outputDir}/${file}`).size / (1024 * 1024) > CHUNK_SIZE_MB) {
111
+ await this.chunkFile({
112
+ file: `${outputDir}/${file}`,
113
+ outputDir,
114
+ index: file.slice(6, 9),
115
+ });
116
+ await execAsync(`rm -f "${outputDir}/${file}"`);
117
+ }
118
+ }
119
+ },
107
120
  async chunkFileAndTranscribe({
108
121
  file, $,
109
122
  }) {
@@ -116,16 +129,20 @@ export default {
116
129
  outputDir,
117
130
  });
118
131
 
119
- const files = await fs.promises.readdir(outputDir);
132
+ let files = await fs.promises.readdir(outputDir);
133
+ // ffmpeg will sometimes return chunks larger than the allowed size,
134
+ // so we need to identify large chunks and break them down further
135
+ await this.splitLargeChunks(files, outputDir);
136
+ files = await fs.promises.readdir(outputDir);
120
137
 
121
- return await this.transcribeFiles({
138
+ return this.transcribeFiles({
122
139
  files,
123
140
  outputDir,
124
141
  $,
125
142
  });
126
143
  },
127
144
  async chunkFile({
128
- file, outputDir,
145
+ file, outputDir, index,
129
146
  }) {
130
147
  const ffmpegPath = ffmpegInstaller.path;
131
148
  const ext = extname(file);
@@ -133,8 +150,10 @@ export default {
133
150
  const fileSizeInMB = fs.statSync(file).size / (1024 * 1024);
134
151
  // We're limited to 26MB per request. Because of how ffmpeg splits files,
135
152
  // we need to be conservative in the number of chunks we create
136
- const conservativeChunkSizeMB = 20;
137
- const numberOfChunks = Math.ceil(fileSizeInMB / conservativeChunkSizeMB);
153
+ const conservativeChunkSizeMB = CHUNK_SIZE_MB;
154
+ const numberOfChunks = !index
155
+ ? Math.ceil(fileSizeInMB / conservativeChunkSizeMB)
156
+ : 2;
138
157
 
139
158
  if (numberOfChunks === 1) {
140
159
  await execAsync(`cp "${file}" "${outputDir}/chunk-000${ext}"`);
@@ -152,7 +171,9 @@ export default {
152
171
  const totalSeconds = (hours * 60 * 60) + (minutes * 60) + seconds;
153
172
  const segmentTime = Math.ceil(totalSeconds / numberOfChunks);
154
173
 
155
- const command = `${ffmpegPath} -i "${file}" -f segment -segment_time ${segmentTime} -c copy "${outputDir}/chunk-%03d${ext}"`;
174
+ const command = `${ffmpegPath} -i "${file}" -f segment -segment_time ${segmentTime} -c copy "${outputDir}/chunk-${index
175
+ ? `${index}-`
176
+ : ""}%03d${ext}"`;
156
177
  await execAsync(command);
157
178
  },
158
179
  transcribeFiles({
@@ -194,14 +215,14 @@ export default {
194
215
  } = this;
195
216
 
196
217
  if (!url && !path) {
197
- throw new Error("Must specify either File URL or File Path");
218
+ throw new ConfigurationError("Must specify either File URL or File Path");
198
219
  }
199
220
 
200
221
  let file;
201
222
 
202
223
  if (path) {
203
224
  if (!fs.existsSync(path)) {
204
- throw new Error(`${path} does not exist`);
225
+ throw new ConfigurationError(`${path} does not exist`);
205
226
  }
206
227
 
207
228
  file = path;
@@ -4,7 +4,7 @@ export default {
4
4
  key: "openai-delete-file",
5
5
  name: "Delete File",
6
6
  description: "Deletes a specified file from OpenAI. [See the documentation](https://platform.openai.com/docs/api-reference/files/delete)",
7
- version: "0.0.4",
7
+ version: "0.0.5",
8
8
  type: "action",
9
9
  props: {
10
10
  openai,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "openai-list-files",
5
5
  name: "List Files",
6
6
  description: "Returns a list of files that belong to the user's organization. [See the documentation](https://platform.openai.com/docs/api-reference/files/list)",
7
- version: "0.0.4",
7
+ version: "0.0.5",
8
8
  type: "action",
9
9
  props: {
10
10
  openai,
@@ -2,9 +2,9 @@ import openai from "../../openai.app.mjs";
2
2
 
3
3
  export default {
4
4
  key: "openai-list-messages",
5
- name: "List Messages",
6
- description: "Lists the messages for a given thread. [See the documentation](https://platform.openai.com/docs/api-reference)",
7
- version: "0.0.5",
5
+ name: "List Messages (Assistants)",
6
+ description: "Lists the messages for a given thread. [See the documentation](https://platform.openai.com/docs/api-reference/messages/listMessages)",
7
+ version: "0.0.6",
8
8
  type: "action",
9
9
  props: {
10
10
  openai,
@@ -2,9 +2,9 @@ import openai from "../../openai.app.mjs";
2
2
 
3
3
  export default {
4
4
  key: "openai-list-run-steps",
5
- name: "List Run Steps",
5
+ name: "List Run Steps (Assistants)",
6
6
  description: "Returns a list of run steps belonging to a run. [See the documentation](https://platform.openai.com/docs/api-reference/runs/list-run-steps)",
7
- version: "0.0.4",
7
+ version: "0.0.5",
8
8
  type: "action",
9
9
  props: {
10
10
  openai,
@@ -2,9 +2,9 @@ import openai from "../../openai.app.mjs";
2
2
 
3
3
  export default {
4
4
  key: "openai-list-runs",
5
- name: "List Runs",
5
+ name: "List Runs (Assistants)",
6
6
  description: "Returns a list of runs belonging to a thread. [See the documentation](https://platform.openai.com/docs/api-reference/runs/list)",
7
- version: "0.0.5",
7
+ version: "0.0.6",
8
8
  type: "action",
9
9
  props: {
10
10
  openai,
@@ -5,7 +5,7 @@ export default {
5
5
  key: "openai-modify-assistant",
6
6
  name: "Modify an Assistant",
7
7
  description: "Modifies an existing OpenAI assistant. [See the documentation](https://platform.openai.com/docs/api-reference/assistants/modifyAssistant)",
8
- version: "0.1.1",
8
+ version: "0.1.2",
9
9
  type: "action",
10
10
  props: {
11
11
  openai,
@@ -2,9 +2,9 @@ import openai from "../../openai.app.mjs";
2
2
 
3
3
  export default {
4
4
  key: "openai-modify-message",
5
- name: "Modify Message",
6
- description: "Modifies an existing message in a thread. [See the documentation](https://platform.openai.com/docs/api-reference)",
7
- version: "0.0.5",
5
+ name: "Modify Message (Assistants)",
6
+ description: "Modifies an existing message in a thread. [See the documentation](https://platform.openai.com/docs/api-reference/messages/modifyMessage)",
7
+ version: "0.0.6",
8
8
  type: "action",
9
9
  props: {
10
10
  openai,
@@ -2,9 +2,9 @@ import openai from "../../openai.app.mjs";
2
2
 
3
3
  export default {
4
4
  key: "openai-modify-run",
5
- name: "Modify Run",
6
- description: "Modifies an existing run. [See the documentation](https://platform.openai.com/docs/api-reference)",
7
- version: "0.0.4",
5
+ name: "Modify Run (Assistants)",
6
+ description: "Modifies an existing run. [See the documentation](https://platform.openai.com/docs/api-reference/runs/modifyRun)",
7
+ version: "0.0.5",
8
8
  type: "action",
9
9
  props: {
10
10
  openai,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "openai-retrieve-file",
5
5
  name: "Retrieve File",
6
6
  description: "Retrieves a specific file from OpenAI. [See the documentation](https://platform.openai.com/docs/api-reference/files/retrieve)",
7
- version: "0.0.4",
7
+ version: "0.0.5",
8
8
  type: "action",
9
9
  props: {
10
10
  openai,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "openai-retrieve-file-content",
5
5
  name: "Retrieve File Content",
6
6
  description: "Retrieves the contents of the specified file. [See the documentation](https://platform.openai.com/docs/api-reference/files/retrieve-content)",
7
- version: "0.0.4",
7
+ version: "0.0.5",
8
8
  type: "action",
9
9
  props: {
10
10
  openai,
@@ -2,9 +2,9 @@ import openai from "../../openai.app.mjs";
2
2
 
3
3
  export default {
4
4
  key: "openai-retrieve-run",
5
- name: "Retrieve Run",
6
- description: "Retrieves a specific run within a thread. [See the documentation](https://platform.openai.com/docs/api-reference)",
7
- version: "0.0.4",
5
+ name: "Retrieve Run (Assistants)",
6
+ description: "Retrieves a specific run within a thread. [See the documentation](https://platform.openai.com/docs/api-reference/runs/getRun)",
7
+ version: "0.0.5",
8
8
  type: "action",
9
9
  props: {
10
10
  openai,
@@ -2,9 +2,9 @@ import openai from "../../openai.app.mjs";
2
2
 
3
3
  export default {
4
4
  key: "openai-retrieve-run-step",
5
- name: "Retrieve Run Step",
6
- description: "Retrieve a specific run step in a thread. [See the documentation](https://platform.openai.com/docs/api-reference)",
7
- version: "0.0.4",
5
+ name: "Retrieve Run Step (Assistants)",
6
+ description: "Retrieve a specific run step in a thread. [See the documentation](https://platform.openai.com/docs/api-reference/runs/getRunStep)",
7
+ version: "0.0.5",
8
8
  type: "action",
9
9
  props: {
10
10
  openai,
@@ -4,7 +4,7 @@ import common from "../common/common.mjs";
4
4
  export default {
5
5
  ...common,
6
6
  name: "Create Completion (Send Prompt)",
7
- version: "0.1.5",
7
+ version: "0.1.6",
8
8
  key: "openai-send-prompt",
9
9
  description: "OpenAI recommends using the **Chat** action for the latest `gpt-3.5-turbo` API, since it's faster and 10x cheaper. This action creates a completion for the provided prompt and parameters using the older `/completions` API. [See docs here](https://beta.openai.com/docs/api-reference/completions/create)",
10
10
  type: "action",
@@ -2,9 +2,9 @@ import openai from "../../openai.app.mjs";
2
2
 
3
3
  export default {
4
4
  key: "openai-submit-tool-outputs-to-run",
5
- name: "Submit Tool Outputs to Run",
6
- description: "Submits tool outputs to a run that requires action. [See the documentation](https://platform.openai.com/docs/api-reference)",
7
- version: "0.0.4",
5
+ name: "Submit Tool Outputs to Run (Assistants)",
6
+ description: "Submits tool outputs to a run that requires action. [See the documentation](https://platform.openai.com/docs/api-reference/runs/submitToolOutputs)",
7
+ version: "0.0.5",
8
8
  type: "action",
9
9
  props: {
10
10
  openai,
@@ -3,7 +3,7 @@ import common from "../common/common-helper.mjs";
3
3
  export default {
4
4
  ...common,
5
5
  name: "Summarize Text",
6
- version: "0.0.8",
6
+ version: "0.0.9",
7
7
  key: "openai-summarize",
8
8
  description: "Summarizes text using the Chat API",
9
9
  type: "action",
@@ -8,8 +8,8 @@ const langOptions = lang.LANGUAGES.map((l) => ({
8
8
 
9
9
  export default {
10
10
  ...common,
11
- name: "Translate Text",
12
- version: "0.0.10",
11
+ name: "Translate Text (Whisper)",
12
+ version: "0.0.11",
13
13
  key: "openai-translate-text",
14
14
  description: "Translate text from one language to another using the Chat API",
15
15
  type: "action",
@@ -6,7 +6,7 @@ export default {
6
6
  key: "openai-upload-file",
7
7
  name: "Upload File",
8
8
  description: "Upload a file that can be used across various endpoints/features. The size of individual files can be a maximum of 512mb. [See the documentation](https://platform.openai.com/docs/api-reference/files/create)",
9
- version: "0.0.7",
9
+ version: "0.0.8",
10
10
  type: "action",
11
11
  props: {
12
12
  openai,
package/openai.app.mjs CHANGED
@@ -222,7 +222,7 @@ export default {
222
222
  ttsModel: {
223
223
  type: "string",
224
224
  label: "Model",
225
- description: "One of the available [TTS models](https://platform.openai.com/docs/models/tts).",
225
+ description: "One of the available [TTS models](https://platform.openai.com/docs/models/tts). `tts-1` is optimized for speed, while `tts-1-hd` is optimized for quality.",
226
226
  options: [
227
227
  "tts-1",
228
228
  "tts-1-hd",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/openai",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "description": "Pipedream OpenAI Components",
5
5
  "main": "openai.app.mjs",
6
6
  "keywords": [
@@ -6,7 +6,7 @@ export default {
6
6
  key: "openai-new-file-created",
7
7
  name: "New File Created",
8
8
  description: "Emit new event when a new file is created in OpenAI. [See the documentation](https://platform.openai.com/docs/api-reference/files/list)",
9
- version: "0.0.3",
9
+ version: "0.0.4",
10
10
  type: "source",
11
11
  dedupe: "unique",
12
12
  props: {
@@ -5,7 +5,7 @@ export default {
5
5
  key: "openai-new-fine-tuning-job-created",
6
6
  name: "New Fine Tuning Job Created",
7
7
  description: "Emit new event when a new fine-tuning job is created in OpenAI. [See the documentation](https://platform.openai.com/docs/api-reference/fine-tuning/list)",
8
- version: "0.0.3",
8
+ version: "0.0.4",
9
9
  type: "source",
10
10
  dedupe: "unique",
11
11
  methods: {