@pipedream/openai 0.1.10 → 0.3.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 (39) hide show
  1. package/actions/cancel-run/cancel-run.mjs +33 -0
  2. package/actions/chat/chat.mjs +20 -2
  3. package/actions/classify-items-into-categories/classify-items-into-categories.mjs +1 -1
  4. package/actions/common/common-helper.mjs +1 -1
  5. package/actions/common/common.mjs +28 -11
  6. package/actions/create-assistant/create-assistant.mjs +71 -0
  7. package/actions/create-embeddings/create-embeddings.mjs +2 -2
  8. package/actions/create-fine-tuning-job/create-fine-tuning-job.mjs +57 -0
  9. package/actions/create-image/create-image.mjs +55 -2
  10. package/actions/create-message/create-message.mjs +64 -0
  11. package/actions/create-run/create-run.mjs +64 -0
  12. package/actions/create-speech/create-speech.mjs +73 -0
  13. package/actions/create-thread/create-thread.mjs +36 -0
  14. package/actions/create-thread-and-run/create-thread-and-run.mjs +61 -0
  15. package/actions/create-transcription/create-transcription.mjs +2 -3
  16. package/actions/delete-file/delete-file.mjs +26 -0
  17. package/actions/list-files/list-files.mjs +27 -0
  18. package/actions/list-messages/list-messages.mjs +54 -0
  19. package/actions/list-run-steps/list-run-steps.mjs +65 -0
  20. package/actions/list-runs/list-runs.mjs +68 -0
  21. package/actions/modify-assistant/modify-assistant.mjs +82 -0
  22. package/actions/modify-message/modify-message.mjs +42 -0
  23. package/actions/modify-run/modify-run.mjs +42 -0
  24. package/actions/retrieve-file/retrieve-file.mjs +26 -0
  25. package/actions/retrieve-file-content/retrieve-file-content.mjs +25 -0
  26. package/actions/retrieve-run/retrieve-run.mjs +33 -0
  27. package/actions/retrieve-run-step/retrieve-run-step.mjs +40 -0
  28. package/actions/send-prompt/send-prompt.mjs +2 -2
  29. package/actions/submit-tool-outputs-to-run/submit-tool-outputs-to-run.mjs +41 -0
  30. package/actions/summarize/summarize.mjs +1 -1
  31. package/actions/translate-text/translate-text.mjs +1 -1
  32. package/actions/upload-file/upload-file.mjs +46 -0
  33. package/common/constants.mjs +23 -0
  34. package/openai.app.mjs +712 -0
  35. package/package.json +4 -3
  36. package/sources/common.mjs +51 -0
  37. package/sources/new-file-created/new-file-created.mjs +38 -0
  38. package/sources/new-fine-tuning-job-created/new-fine-tuning-job-created.mjs +24 -0
  39. package/app/openai.app.mjs +0 -180
@@ -9,7 +9,7 @@ import { ConfigurationError } from "@pipedream/platform";
9
9
  import common from "../common/common.mjs";
10
10
  import constants from "../common/constants.mjs";
11
11
  import lang from "../common/lang.mjs";
12
- import openai from "../../app/openai.app.mjs";
12
+ import openai from "../../openai.app.mjs";
13
13
  import { promisify } from "util";
14
14
  import stream from "stream";
15
15
  import { exec } from "child_process";
@@ -22,7 +22,7 @@ const pipelineAsync = promisify(stream.pipeline);
22
22
 
23
23
  export default {
24
24
  name: "Create Transcription",
25
- version: "0.0.9",
25
+ version: "0.1.2",
26
26
  key: "openai-create-transcription",
27
27
  description: "Transcribes audio into the input language. [See docs here](https://platform.openai.com/docs/api-reference/audio/create).",
28
28
  type: "action",
@@ -43,7 +43,6 @@ export default {
43
43
  description: "**Optional**. The language of the input audio. Supplying the input language will improve accuracy and latency.",
44
44
  type: "string",
45
45
  optional: true,
46
- default: "en",
47
46
  options: lang.LANGUAGES.map((l) => ({
48
47
  label: l.label,
49
48
  value: l.value,
@@ -0,0 +1,26 @@
1
+ import openai from "../../openai.app.mjs";
2
+
3
+ export default {
4
+ key: "openai-delete-file",
5
+ name: "Delete File",
6
+ description: "Deletes a specified file from OpenAI. [See the documentation](https://platform.openai.com/docs/api-reference/files/delete)",
7
+ version: "0.0.2",
8
+ type: "action",
9
+ props: {
10
+ openai,
11
+ file_id: {
12
+ propDefinition: [
13
+ openai,
14
+ "file_id",
15
+ ],
16
+ },
17
+ },
18
+ async run({ $ }) {
19
+ const response = await this.openai.deleteFile({
20
+ file_id: this.file_id,
21
+ });
22
+
23
+ $.export("$summary", `Successfully deleted file with ID: ${this.file_id}`);
24
+ return response;
25
+ },
26
+ };
@@ -0,0 +1,27 @@
1
+ import openai from "../../openai.app.mjs";
2
+
3
+ export default {
4
+ key: "openai-list-files",
5
+ name: "List Files",
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.2",
8
+ type: "action",
9
+ props: {
10
+ openai,
11
+ purpose: {
12
+ propDefinition: [
13
+ openai,
14
+ "purpose",
15
+ ],
16
+ optional: true,
17
+ },
18
+ },
19
+ async run({ $ }) {
20
+ const response = await this.openai.listFiles({
21
+ purpose: this.purpose,
22
+ });
23
+ const summary = `Successfully listed ${response.length} files`;
24
+ $.export("$summary", summary);
25
+ return response;
26
+ },
27
+ };
@@ -0,0 +1,54 @@
1
+ import openai from "../../openai.app.mjs";
2
+
3
+ export default {
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.3",
8
+ type: "action",
9
+ props: {
10
+ openai,
11
+ threadId: {
12
+ propDefinition: [
13
+ openai,
14
+ "threadId",
15
+ ],
16
+ },
17
+ limit: {
18
+ propDefinition: [
19
+ openai,
20
+ "limit",
21
+ ],
22
+ },
23
+ order: {
24
+ propDefinition: [
25
+ openai,
26
+ "order",
27
+ ],
28
+ },
29
+ after: {
30
+ propDefinition: [
31
+ openai,
32
+ "after",
33
+ ],
34
+ },
35
+ before: {
36
+ propDefinition: [
37
+ openai,
38
+ "before",
39
+ ],
40
+ },
41
+ },
42
+ async run({ $ }) {
43
+ const response = await this.openai.listMessages({
44
+ threadId: this.threadId,
45
+ limit: this.limit,
46
+ order: this.order,
47
+ after: this.after,
48
+ before: this.before,
49
+ });
50
+
51
+ $.export("$summary", `Successfully listed ${response.data.length} messages for thread ID ${this.threadId}`);
52
+ return response.data;
53
+ },
54
+ };
@@ -0,0 +1,65 @@
1
+ import openai from "../../openai.app.mjs";
2
+
3
+ export default {
4
+ key: "openai-list-run-steps",
5
+ name: "List Run Steps",
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.2",
8
+ type: "action",
9
+ props: {
10
+ openai,
11
+ threadId: {
12
+ propDefinition: [
13
+ openai,
14
+ "threadId",
15
+ ],
16
+ },
17
+ runId: {
18
+ propDefinition: [
19
+ openai,
20
+ "runId",
21
+ ],
22
+ },
23
+ limit: {
24
+ propDefinition: [
25
+ openai,
26
+ "limit",
27
+ ],
28
+ optional: true,
29
+ },
30
+ order: {
31
+ propDefinition: [
32
+ openai,
33
+ "order",
34
+ ],
35
+ optional: true,
36
+ },
37
+ after: {
38
+ propDefinition: [
39
+ openai,
40
+ "after",
41
+ ],
42
+ optional: true,
43
+ },
44
+ before: {
45
+ propDefinition: [
46
+ openai,
47
+ "before",
48
+ ],
49
+ optional: true,
50
+ },
51
+ },
52
+ async run({ $ }) {
53
+ const response = await this.openai.listRunSteps({
54
+ threadId: this.threadId,
55
+ runId: this.runId,
56
+ limit: this.limit,
57
+ order: this.order,
58
+ after: this.after,
59
+ before: this.before,
60
+ });
61
+
62
+ $.export("$summary", `Successfully listed run steps for run ${this.runId}`);
63
+ return response;
64
+ },
65
+ };
@@ -0,0 +1,68 @@
1
+ import openai from "../../openai.app.mjs";
2
+
3
+ export default {
4
+ key: "openai-list-runs",
5
+ name: "List Runs",
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.3",
8
+ type: "action",
9
+ props: {
10
+ openai,
11
+ threadId: {
12
+ propDefinition: [
13
+ openai,
14
+ "threadId",
15
+ ],
16
+ },
17
+ limit: {
18
+ propDefinition: [
19
+ openai,
20
+ "limit",
21
+ ],
22
+ optional: true,
23
+ },
24
+ order: {
25
+ propDefinition: [
26
+ openai,
27
+ "order",
28
+ ],
29
+ optional: true,
30
+ },
31
+ after: {
32
+ propDefinition: [
33
+ openai,
34
+ "after",
35
+ ],
36
+ },
37
+ before: {
38
+ propDefinition: [
39
+ openai,
40
+ "before",
41
+ ],
42
+ },
43
+ },
44
+ async run({ $ }) {
45
+ const params = {
46
+ ...(this.limit && {
47
+ limit: this.limit,
48
+ }),
49
+ ...(this.order && {
50
+ order: this.order,
51
+ }),
52
+ ...(this.after && {
53
+ after: this.after,
54
+ }),
55
+ ...(this.before && {
56
+ before: this.before,
57
+ }),
58
+ };
59
+
60
+ const response = await this.openai.listRuns({
61
+ threadId: this.threadId,
62
+ ...params,
63
+ });
64
+
65
+ $.export("$summary", `Successfully retrieved runs for thread ${this.threadId}`);
66
+ return response;
67
+ },
68
+ };
@@ -0,0 +1,82 @@
1
+ import openai from "../../openai.app.mjs";
2
+
3
+ export default {
4
+ key: "openai-modify-assistant",
5
+ name: "Modify an Assistant",
6
+ description: "Modifies an existing OpenAI assistant. [See the documentation](https://platform.openai.com/docs/api-reference/assistants/modifyAssistant)",
7
+ version: "0.0.1",
8
+ type: "action",
9
+ props: {
10
+ openai,
11
+ assistant: {
12
+ propDefinition: [
13
+ openai,
14
+ "assistant",
15
+ ],
16
+ },
17
+ model: {
18
+ propDefinition: [
19
+ openai,
20
+ "assistantModel",
21
+ ],
22
+ optional: true,
23
+ },
24
+ name: {
25
+ propDefinition: [
26
+ openai,
27
+ "name",
28
+ ],
29
+ optional: true,
30
+ },
31
+ description: {
32
+ propDefinition: [
33
+ openai,
34
+ "description",
35
+ ],
36
+ optional: true,
37
+ },
38
+ instructions: {
39
+ propDefinition: [
40
+ openai,
41
+ "instructions",
42
+ ],
43
+ optional: true,
44
+ },
45
+ tools: {
46
+ propDefinition: [
47
+ openai,
48
+ "tools",
49
+ ],
50
+ optional: true,
51
+ },
52
+ file_ids: {
53
+ propDefinition: [
54
+ openai,
55
+ "file_ids",
56
+ ],
57
+ optional: true,
58
+ },
59
+ metadata: {
60
+ propDefinition: [
61
+ openai,
62
+ "metadata",
63
+ ],
64
+ optional: true,
65
+ },
66
+ },
67
+ async run({ $ }) {
68
+ const response = await this.openai.modifyAssistant({
69
+ $,
70
+ assistant: this.assistant,
71
+ model: this.model,
72
+ name: this.name,
73
+ description: this.description,
74
+ instructions: this.instructions,
75
+ tools: this.tools,
76
+ file_ids: this.file_ids,
77
+ metadata: this.metadata,
78
+ });
79
+ $.export("$summary", `Successfully modified assistant ${this.assistant}`);
80
+ return response;
81
+ },
82
+ };
@@ -0,0 +1,42 @@
1
+ import openai from "../../openai.app.mjs";
2
+
3
+ export default {
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.3",
8
+ type: "action",
9
+ props: {
10
+ openai,
11
+ threadId: {
12
+ propDefinition: [
13
+ openai,
14
+ "threadId",
15
+ ],
16
+ },
17
+ messageId: {
18
+ propDefinition: [
19
+ openai,
20
+ "messageId",
21
+ ],
22
+ },
23
+ metadata: {
24
+ type: "string",
25
+ label: "Metadata",
26
+ description: "Metadata for the message in JSON string format",
27
+ optional: true,
28
+ },
29
+ },
30
+ async run({ $ }) {
31
+ const response = await this.openai.modifyMessage({
32
+ threadId: this.threadId,
33
+ messageId: this.messageId,
34
+ metadata: this.metadata
35
+ ? JSON.parse(this.metadata)
36
+ : undefined,
37
+ });
38
+
39
+ $.export("$summary", `Successfully modified message ${this.messageId} in thread ${this.threadId}`);
40
+ return response;
41
+ },
42
+ };
@@ -0,0 +1,42 @@
1
+ import openai from "../../openai.app.mjs";
2
+
3
+ export default {
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.2",
8
+ type: "action",
9
+ props: {
10
+ openai,
11
+ threadId: {
12
+ propDefinition: [
13
+ openai,
14
+ "threadId",
15
+ ],
16
+ },
17
+ runId: {
18
+ propDefinition: [
19
+ openai,
20
+ "runId",
21
+ ],
22
+ },
23
+ metadata: {
24
+ propDefinition: [
25
+ openai,
26
+ "metadata",
27
+ ],
28
+ },
29
+ },
30
+ async run({ $ }) {
31
+ const response = await this.openai.modifyRun({
32
+ threadId: this.threadId,
33
+ runId: this.runId,
34
+ ...(this.metadata && {
35
+ metadata: this.metadata,
36
+ }),
37
+ });
38
+
39
+ $.export("$summary", `Successfully modified run with ID: ${this.runId}`);
40
+ return response;
41
+ },
42
+ };
@@ -0,0 +1,26 @@
1
+ import openai from "../../openai.app.mjs";
2
+
3
+ export default {
4
+ key: "openai-retrieve-file",
5
+ name: "Retrieve File",
6
+ description: "Retrieves a specific file from OpenAI. [See the documentation](https://platform.openai.com/docs/api-reference/files/retrieve)",
7
+ version: "0.0.2",
8
+ type: "action",
9
+ props: {
10
+ openai,
11
+ file_id: {
12
+ propDefinition: [
13
+ openai,
14
+ "file_id",
15
+ ],
16
+ },
17
+ },
18
+ async run({ $ }) {
19
+ const response = await this.openai.retrieveFile({
20
+ file_id: this.file_id,
21
+ });
22
+
23
+ $.export("$summary", `Successfully retrieved file with ID ${this.file_id}`);
24
+ return response;
25
+ },
26
+ };
@@ -0,0 +1,25 @@
1
+ import openai from "../../openai.app.mjs";
2
+
3
+ export default {
4
+ key: "openai-retrieve-file-content",
5
+ name: "Retrieve File Content",
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.2",
8
+ type: "action",
9
+ props: {
10
+ openai,
11
+ file_id: {
12
+ propDefinition: [
13
+ openai,
14
+ "file_id",
15
+ ],
16
+ },
17
+ },
18
+ async run({ $ }) {
19
+ const response = await this.openai.retrieveFileContent({
20
+ file_id: this.file_id,
21
+ });
22
+ $.export("$summary", `Successfully retrieved file content with ID ${this.file_id}`);
23
+ return response;
24
+ },
25
+ };
@@ -0,0 +1,33 @@
1
+ import openai from "../../openai.app.mjs";
2
+
3
+ export default {
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.2",
8
+ type: "action",
9
+ props: {
10
+ openai,
11
+ threadId: {
12
+ propDefinition: [
13
+ openai,
14
+ "threadId",
15
+ ],
16
+ },
17
+ runId: {
18
+ propDefinition: [
19
+ openai,
20
+ "runId",
21
+ ],
22
+ },
23
+ },
24
+ async run({ $ }) {
25
+ const response = await this.openai.retrieveRun({
26
+ threadId: this.threadId,
27
+ runId: this.runId,
28
+ });
29
+
30
+ $.export("$summary", `Successfully retrieved run ${this.runId} in thread ${this.threadId}`);
31
+ return response;
32
+ },
33
+ };
@@ -0,0 +1,40 @@
1
+ import openai from "../../openai.app.mjs";
2
+
3
+ export default {
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.2",
8
+ type: "action",
9
+ props: {
10
+ openai,
11
+ threadId: {
12
+ propDefinition: [
13
+ openai,
14
+ "threadId",
15
+ ],
16
+ },
17
+ runId: {
18
+ propDefinition: [
19
+ openai,
20
+ "runId",
21
+ ],
22
+ },
23
+ stepId: {
24
+ propDefinition: [
25
+ openai,
26
+ "stepId",
27
+ ],
28
+ },
29
+ },
30
+ async run({ $ }) {
31
+ const response = await this.openai.retrieveRunStep({
32
+ threadId: this.threadId,
33
+ runId: this.runId,
34
+ stepId: this.stepId,
35
+ });
36
+
37
+ $.export("$summary", `Successfully retrieved run step with ID ${this.stepId}`);
38
+ return response;
39
+ },
40
+ };
@@ -1,10 +1,10 @@
1
- import openai from "../../app/openai.app.mjs";
1
+ import openai from "../../openai.app.mjs";
2
2
  import common from "../common/common.mjs";
3
3
 
4
4
  export default {
5
5
  ...common,
6
6
  name: "Create Completion (Send Prompt)",
7
- version: "0.1.1",
7
+ version: "0.1.3",
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",
@@ -0,0 +1,41 @@
1
+ import openai from "../../openai.app.mjs";
2
+
3
+ export default {
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.2",
8
+ type: "action",
9
+ props: {
10
+ openai,
11
+ threadId: {
12
+ propDefinition: [
13
+ openai,
14
+ "threadId",
15
+ ],
16
+ },
17
+ runId: {
18
+ propDefinition: [
19
+ openai,
20
+ "runId",
21
+ ],
22
+ },
23
+ toolOutputs: {
24
+ propDefinition: [
25
+ openai,
26
+ "toolOutputs",
27
+ ],
28
+ },
29
+ },
30
+ async run({ $ }) {
31
+ const parsedToolOutputs = this.toolOutputs.map(JSON.parse);
32
+ const response = await this.openai.submitToolOutputs({
33
+ threadId: this.threadId,
34
+ runId: this.runId,
35
+ toolOutputs: parsedToolOutputs,
36
+ });
37
+
38
+ $.export("$summary", `Successfully submitted tool outputs to run ${this.runId}`);
39
+ return response;
40
+ },
41
+ };
@@ -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.4",
6
+ version: "0.0.6",
7
7
  key: "openai-summarize",
8
8
  description: "Summarizes text using the Chat API",
9
9
  type: "action",
@@ -9,7 +9,7 @@ const langOptions = lang.LANGUAGES.map((l) => ({
9
9
  export default {
10
10
  ...common,
11
11
  name: "Translate Text",
12
- version: "0.0.6",
12
+ version: "0.0.8",
13
13
  key: "openai-translate-text",
14
14
  description: "Translate text from one language to another using the Chat API",
15
15
  type: "action",
@@ -0,0 +1,46 @@
1
+ import openai from "../../openai.app.mjs";
2
+ import FormData from "form-data";
3
+ import fs from "fs";
4
+
5
+ export default {
6
+ key: "openai-upload-file",
7
+ name: "Upload File",
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.5",
10
+ type: "action",
11
+ props: {
12
+ openai,
13
+ file: {
14
+ propDefinition: [
15
+ openai,
16
+ "file",
17
+ ],
18
+ },
19
+ purpose: {
20
+ propDefinition: [
21
+ openai,
22
+ "purpose",
23
+ ],
24
+ },
25
+ },
26
+ async run({ $ }) {
27
+ const {
28
+ file, purpose,
29
+ } = this;
30
+ const data = new FormData();
31
+ const content = fs.createReadStream(file.includes("tmp/")
32
+ ? file
33
+ : `/tmp/${file}`);
34
+ data.append("purpose", purpose);
35
+ data.append("file", content);
36
+
37
+ const response = await this.openai.uploadFile({
38
+ $,
39
+ data,
40
+ headers: data.getHeaders(),
41
+ });
42
+
43
+ $.export("$summary", `Successfully uploaded file with purpose: ${purpose}`);
44
+ return response;
45
+ },
46
+ };