@pipedream/openai 0.4.3 → 0.5.0

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 +6 -3
  2. package/actions/classify-items-into-categories/classify-items-into-categories.mjs +1 -1
  3. package/actions/create-assistant/create-assistant.mjs +1 -1
  4. package/actions/create-embeddings/create-embeddings.mjs +1 -1
  5. package/actions/create-fine-tuning-job/create-fine-tuning-job.mjs +1 -1
  6. package/actions/create-image/create-image.mjs +3 -3
  7. package/actions/create-message/create-message.mjs +3 -3
  8. package/actions/create-run/create-run.mjs +2 -2
  9. package/actions/create-speech/create-speech.mjs +2 -2
  10. package/actions/create-thread/create-thread.mjs +2 -2
  11. package/actions/create-thread-and-run/create-thread-and-run.mjs +2 -2
  12. package/actions/create-transcription/create-transcription.mjs +2 -2
  13. package/actions/delete-file/delete-file.mjs +1 -1
  14. package/actions/list-files/list-files.mjs +1 -1
  15. package/actions/list-messages/list-messages.mjs +3 -3
  16. package/actions/list-run-steps/list-run-steps.mjs +5 -2
  17. package/actions/list-runs/list-runs.mjs +2 -2
  18. package/actions/modify-assistant/modify-assistant.mjs +1 -1
  19. package/actions/modify-message/modify-message.mjs +3 -3
  20. package/actions/modify-run/modify-run.mjs +6 -3
  21. package/actions/retrieve-file/retrieve-file.mjs +1 -1
  22. package/actions/retrieve-file-content/retrieve-file-content.mjs +1 -1
  23. package/actions/retrieve-run/retrieve-run.mjs +6 -3
  24. package/actions/retrieve-run-step/retrieve-run-step.mjs +6 -3
  25. package/actions/send-prompt/send-prompt.mjs +1 -1
  26. package/actions/submit-tool-outputs-to-run/submit-tool-outputs-to-run.mjs +6 -3
  27. package/actions/summarize/summarize.mjs +1 -1
  28. package/actions/translate-text/translate-text.mjs +2 -2
  29. package/actions/upload-file/upload-file.mjs +1 -1
  30. package/openai.app.mjs +11 -2
  31. package/package.json +1 -1
  32. package/sources/new-file-created/new-file-created.mjs +2 -3
  33. package/sources/new-fine-tuning-job-created/new-fine-tuning-job-created.mjs +1 -1
  34. package/sources/new-run-state-changed/new-run-state-changed.mjs +84 -0
@@ -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.6",
8
8
  type: "action",
9
9
  props: {
10
10
  openai,
@@ -18,6 +18,9 @@ export default {
18
18
  propDefinition: [
19
19
  openai,
20
20
  "runId",
21
+ ({ threadId }) => ({
22
+ threadId,
23
+ }),
21
24
  ],
22
25
  },
23
26
  },
@@ -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.10",
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.3",
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.8",
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.5",
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.13",
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.7",
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.3",
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.5",
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.5",
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.3",
9
9
  type: "action",
10
10
  props: {
11
11
  openai,
@@ -23,8 +23,8 @@ const execAsync = promisify(exec);
23
23
  const pipelineAsync = promisify(stream.pipeline);
24
24
 
25
25
  export default {
26
- name: "Create Transcription",
27
- version: "0.1.6",
26
+ name: "Create Transcription (Whisper)",
27
+ version: "0.1.8",
28
28
  key: "openai-create-transcription",
29
29
  description: "Transcribes audio into the input language. [See docs here](https://platform.openai.com/docs/api-reference/audio/create).",
30
30
  type: "action",
@@ -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.6",
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.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-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.7",
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.6",
8
8
  type: "action",
9
9
  props: {
10
10
  openai,
@@ -18,6 +18,9 @@ export default {
18
18
  propDefinition: [
19
19
  openai,
20
20
  "runId",
21
+ ({ threadId }) => ({
22
+ threadId,
23
+ }),
21
24
  ],
22
25
  },
23
26
  limit: {
@@ -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.7",
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.3",
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.7",
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.6",
8
8
  type: "action",
9
9
  props: {
10
10
  openai,
@@ -18,6 +18,9 @@ export default {
18
18
  propDefinition: [
19
19
  openai,
20
20
  "runId",
21
+ ({ threadId }) => ({
22
+ threadId,
23
+ }),
21
24
  ],
22
25
  },
23
26
  metadata: {
@@ -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.6",
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.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-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.6",
8
8
  type: "action",
9
9
  props: {
10
10
  openai,
@@ -18,6 +18,9 @@ export default {
18
18
  propDefinition: [
19
19
  openai,
20
20
  "runId",
21
+ ({ threadId }) => ({
22
+ threadId,
23
+ }),
21
24
  ],
22
25
  },
23
26
  },
@@ -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.6",
8
8
  type: "action",
9
9
  props: {
10
10
  openai,
@@ -18,6 +18,9 @@ export default {
18
18
  propDefinition: [
19
19
  openai,
20
20
  "runId",
21
+ ({ threadId }) => ({
22
+ threadId,
23
+ }),
21
24
  ],
22
25
  },
23
26
  stepId: {
@@ -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.7",
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.6",
8
8
  type: "action",
9
9
  props: {
10
10
  openai,
@@ -18,6 +18,9 @@ export default {
18
18
  propDefinition: [
19
19
  openai,
20
20
  "runId",
21
+ ({ threadId }) => ({
22
+ threadId,
23
+ }),
21
24
  ],
22
25
  },
23
26
  toolOutputs: {
@@ -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.10",
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.12",
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.9",
10
10
  type: "action",
11
11
  props: {
12
12
  openai,
package/openai.app.mjs CHANGED
@@ -76,6 +76,15 @@ export default {
76
76
  type: "string",
77
77
  label: "Run ID",
78
78
  description: "The unique identifier for the run.",
79
+ async options({ threadId }) {
80
+ if (!threadId) {
81
+ return [];
82
+ }
83
+ const { data: runs } = await this.listRuns({
84
+ threadId,
85
+ });
86
+ return runs.map(({ id }) => id);
87
+ },
79
88
  },
80
89
  stepId: {
81
90
  type: "string",
@@ -222,7 +231,7 @@ export default {
222
231
  ttsModel: {
223
232
  type: "string",
224
233
  label: "Model",
225
- description: "One of the available [TTS models](https://platform.openai.com/docs/models/tts).",
234
+ 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
235
  options: [
227
236
  "tts-1",
228
237
  "tts-1-hd",
@@ -579,7 +588,7 @@ export default {
579
588
  return this._makeRequest({
580
589
  path: `/threads/${threadId}/runs/${runId}`,
581
590
  headers: this._betaHeaders(),
582
- method: "PATCH", // Assuming modification is done via PATCH
591
+ method: "POST",
583
592
  data: opts,
584
593
  });
585
594
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/openai",
3
- "version": "0.4.3",
3
+ "version": "0.5.0",
4
4
  "description": "Pipedream OpenAI Components",
5
5
  "main": "openai.app.mjs",
6
6
  "keywords": [
@@ -1,4 +1,3 @@
1
- import openai from "../../openai.app.mjs";
2
1
  import common from "../common.mjs";
3
2
 
4
3
  export default {
@@ -6,14 +5,14 @@ export default {
6
5
  key: "openai-new-file-created",
7
6
  name: "New File Created",
8
7
  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",
8
+ version: "0.0.5",
10
9
  type: "source",
11
10
  dedupe: "unique",
12
11
  props: {
13
12
  ...common.props,
14
13
  purpose: {
15
14
  propDefinition: [
16
- openai,
15
+ common.props.openai,
17
16
  "purpose",
18
17
  ],
19
18
  description: "If specified, events will only be emitted for files with the specified purpose.",
@@ -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.5",
9
9
  type: "source",
10
10
  dedupe: "unique",
11
11
  methods: {
@@ -0,0 +1,84 @@
1
+ import common from "../common.mjs";
2
+
3
+ export default {
4
+ ...common,
5
+ key: "openai-new-run-state-changed",
6
+ name: "New Run State Changed",
7
+ description: "Emit new event every time a run changes its status. [See the documentation](https://platform.openai.com/docs/api-reference/runs/listRuns)",
8
+ version: "0.0.1",
9
+ type: "source",
10
+ dedupe: "unique",
11
+ props: {
12
+ ...common.props,
13
+ threadId: {
14
+ propDefinition: [
15
+ common.props.openai,
16
+ "threadId",
17
+ ],
18
+ },
19
+ },
20
+ methods: {
21
+ ...common.methods,
22
+ getStatusItems() {
23
+ return this.db.get("statusItems");
24
+ },
25
+ setStatusItems(value) {
26
+ this.db.set("statusItems", value);
27
+ },
28
+ async getData() {
29
+ const {
30
+ openai,
31
+ threadId,
32
+ } = this;
33
+
34
+ const { data } = await openai.listRuns({
35
+ threadId,
36
+ });
37
+
38
+ return data;
39
+ },
40
+ getMeta(item) {
41
+ const ts = Date.now();
42
+ return {
43
+ id: `${item.id}-${ts}`,
44
+ summary: `Run State Changed: ${item.id}`,
45
+ ts,
46
+ };
47
+ },
48
+ statusByItemId(itemId, statusItems) {
49
+ const { [itemId]: status } = statusItems || {};
50
+ return status;
51
+ },
52
+ buildStatusItems(data) {
53
+ return data?.reduce((acc, item) => ({
54
+ ...acc,
55
+ [item.id]: item.status,
56
+ }), {});
57
+ },
58
+ async getAndProcessItems(maxEvents) {
59
+ const {
60
+ getData,
61
+ getStatusItems,
62
+ setStatusItems,
63
+ statusByItemId,
64
+ buildStatusItems,
65
+ getMeta,
66
+ $emit: emit,
67
+ } = this;
68
+
69
+ const data = await getData();
70
+ const statusItems = getStatusItems();
71
+
72
+ Array.from(data)
73
+ .reverse()
74
+ .forEach((item, index) => {
75
+ const statusChanged = statusByItemId(item.id, statusItems) !== item.status;
76
+ if ((!maxEvents || index < maxEvents) && statusChanged) {
77
+ emit(item, getMeta(item));
78
+ }
79
+ });
80
+
81
+ setStatusItems(buildStatusItems(data));
82
+ },
83
+ },
84
+ };