@pipedream/openai 0.3.1 → 0.4.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 (35) hide show
  1. package/actions/cancel-run/cancel-run.mjs +1 -1
  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 +3 -4
  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 +47 -10
  8. package/actions/create-message/create-message.mjs +1 -1
  9. package/actions/create-run/create-run.mjs +3 -2
  10. package/actions/create-speech/create-speech.mjs +1 -1
  11. package/actions/create-thread/create-thread.mjs +1 -1
  12. package/actions/create-thread-and-run/create-thread-and-run.mjs +3 -2
  13. package/actions/create-transcription/create-transcription.mjs +1 -1
  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 +1 -1
  17. package/actions/list-run-steps/list-run-steps.mjs +1 -1
  18. package/actions/list-runs/list-runs.mjs +1 -1
  19. package/actions/modify-assistant/modify-assistant.mjs +3 -2
  20. package/actions/modify-message/modify-message.mjs +1 -1
  21. package/actions/modify-run/modify-run.mjs +1 -1
  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 +1 -1
  25. package/actions/retrieve-run-step/retrieve-run-step.mjs +1 -1
  26. package/actions/send-prompt/send-prompt.mjs +1 -1
  27. package/actions/submit-tool-outputs-to-run/submit-tool-outputs-to-run.mjs +1 -1
  28. package/actions/summarize/summarize.mjs +1 -1
  29. package/actions/translate-text/translate-text.mjs +1 -1
  30. package/actions/upload-file/upload-file.mjs +1 -1
  31. package/common/helpers.mjs +18 -0
  32. package/openai.app.mjs +1 -5
  33. package/package.json +5 -3
  34. package/sources/new-file-created/new-file-created.mjs +1 -1
  35. package/sources/new-fine-tuning-job-created/new-fine-tuning-job-created.mjs +1 -1
@@ -4,7 +4,7 @@ export default {
4
4
  key: "openai-cancel-run",
5
5
  name: "Cancel Run",
6
6
  description: "Cancels a run that is in progress. [See the documentation](https://platform.openai.com/docs/api-reference)",
7
- version: "0.0.2",
7
+ version: "0.0.3",
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.5",
7
+ version: "0.1.6",
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.6",
6
+ version: "0.0.7",
7
7
  key: "openai-classify-items-into-categories",
8
8
  description: "Classify items into specific categories using the Chat API",
9
9
  type: "action",
@@ -1,10 +1,11 @@
1
+ import { parseToolsArray } from "../../common/helpers.mjs";
1
2
  import openai from "../../openai.app.mjs";
2
3
 
3
4
  export default {
4
5
  key: "openai-create-assistant",
5
6
  name: "Create Assistant",
6
7
  description: "Creates an assistant with a model and instructions. [See the docs here](https://platform.openai.com/docs/api-reference/assistants/createAssistant)",
7
- version: "0.0.1",
8
+ version: "0.1.0",
8
9
  type: "action",
9
10
  props: {
10
11
  openai,
@@ -58,9 +59,7 @@ export default {
58
59
  name: this.name,
59
60
  description: this.description,
60
61
  instructions: this.instructions,
61
- tools: (this.tools || []).map((tool) => ({
62
- type: tool,
63
- })),
62
+ tools: parseToolsArray(this.tools),
64
63
  file_ids: this.file_ids,
65
64
  metadata: this.metadata,
66
65
  });
@@ -4,7 +4,7 @@ import { ConfigurationError } from "@pipedream/platform";
4
4
 
5
5
  export default {
6
6
  name: "Create Embeddings",
7
- version: "0.0.4",
7
+ version: "0.0.5",
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.1",
7
+ version: "0.0.2",
8
8
  type: "action",
9
9
  props: {
10
10
  openai,
@@ -1,9 +1,8 @@
1
1
  import openai from "../../openai.app.mjs";
2
- import constants from "../common/constants.mjs";
3
2
 
4
3
  export default {
5
4
  name: "Create Image",
6
- version: "0.1.5",
5
+ version: "0.1.9",
7
6
  key: "openai-create-image",
8
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)",
9
8
  type: "action",
@@ -37,14 +36,6 @@ export default {
37
36
  optional: true,
38
37
  default: 1,
39
38
  },
40
- size: {
41
- label: "Size",
42
- description: "The size of the generated images.",
43
- type: "string",
44
- optional: true,
45
- options: constants.IMAGE_SIZES,
46
- default: "1024x1024",
47
- },
48
39
  quality: {
49
40
  label: "Quality",
50
41
  description: "The quality of the image",
@@ -79,6 +70,52 @@ export default {
79
70
  ],
80
71
  default: "natural",
81
72
  },
73
+ responseFormat: {
74
+ label: "Response Format",
75
+ description: "The format in which the generated images are returned.",
76
+ type: "string",
77
+ optional: true,
78
+ options: [
79
+ {
80
+ label: "URL",
81
+ value: "url",
82
+ },
83
+ {
84
+ label: "Base64 JSON",
85
+ value: "b64_json",
86
+ },
87
+ ],
88
+ default: "url",
89
+ },
90
+ size: {
91
+ label: "Size",
92
+ description: "The size of the generated images.",
93
+ type: "string",
94
+ optional: true,
95
+ options: [
96
+ {
97
+ label: "256x256",
98
+ value: "256x256",
99
+ },
100
+ {
101
+ label: "512x512",
102
+ value: "512x512",
103
+ },
104
+ {
105
+ label: "1024x1024",
106
+ value: "1024x1024",
107
+ },
108
+ {
109
+ label: "1792x1024",
110
+ value: "1792x1024",
111
+ },
112
+ {
113
+ label: "1024x1792",
114
+ value: "1024x1792",
115
+ },
116
+ ],
117
+ default: "1024x1024",
118
+ },
82
119
  },
83
120
  async run({ $ }) {
84
121
  const response = await this.openai.createImage({
@@ -4,7 +4,7 @@ export default {
4
4
  key: "openai-create-message",
5
5
  name: "Create Message",
6
6
  description: "Create a message in a thread. [See the documentation](https://platform.openai.com/docs/api-reference)",
7
- version: "0.0.3",
7
+ version: "0.0.4",
8
8
  type: "action",
9
9
  props: {
10
10
  openai,
@@ -1,10 +1,11 @@
1
+ import { parseToolsArray } from "../../common/helpers.mjs";
1
2
  import openai from "../../openai.app.mjs";
2
3
 
3
4
  export default {
4
5
  key: "openai-create-run",
5
6
  name: "Create Run",
6
7
  description: "Creates a run given a thread ID and assistant ID. [See the documentation](https://platform.openai.com/docs/api-reference/runs/create)",
7
- version: "0.0.3",
8
+ version: "0.1.0",
8
9
  type: "action",
9
10
  props: {
10
11
  openai,
@@ -51,7 +52,7 @@ export default {
51
52
  assistantId: this.assistantId,
52
53
  model: this.model,
53
54
  instructions: this.instructions,
54
- tools: this.tools,
55
+ tools: parseToolsArray(this.tools),
55
56
  metadata: this.metadata,
56
57
  });
57
58
 
@@ -5,7 +5,7 @@ export default {
5
5
  key: "openai-create-speech",
6
6
  name: "Create Speech",
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.1",
8
+ version: "0.0.2",
9
9
  type: "action",
10
10
  props: {
11
11
  openai,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "openai-create-thread",
5
5
  name: "Create Thread",
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.1",
7
+ version: "0.0.2",
8
8
  type: "action",
9
9
  props: {
10
10
  openai,
@@ -1,10 +1,11 @@
1
+ import { parseToolsArray } from "../../common/helpers.mjs";
1
2
  import openai from "../../openai.app.mjs";
2
3
 
3
4
  export default {
4
5
  key: "openai-create-thread-and-run",
5
6
  name: "Create Thread and Run",
6
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)",
7
- version: "0.0.2",
8
+ version: "0.1.0",
8
9
  type: "action",
9
10
  props: {
10
11
  openai,
@@ -51,7 +52,7 @@ export default {
51
52
  thread: this.thread,
52
53
  model: this.model,
53
54
  instructions: this.instructions,
54
- tools: this.tools,
55
+ tools: parseToolsArray(this.tools),
55
56
  metadata: this.metadata,
56
57
  });
57
58
 
@@ -22,7 +22,7 @@ const pipelineAsync = promisify(stream.pipeline);
22
22
 
23
23
  export default {
24
24
  name: "Create Transcription",
25
- version: "0.1.2",
25
+ version: "0.1.3",
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",
@@ -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.2",
7
+ version: "0.0.3",
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.2",
7
+ version: "0.0.3",
8
8
  type: "action",
9
9
  props: {
10
10
  openai,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "openai-list-messages",
5
5
  name: "List Messages",
6
6
  description: "Lists the messages for a given thread. [See the documentation](https://platform.openai.com/docs/api-reference)",
7
- version: "0.0.3",
7
+ version: "0.0.4",
8
8
  type: "action",
9
9
  props: {
10
10
  openai,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "openai-list-run-steps",
5
5
  name: "List Run Steps",
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.2",
7
+ version: "0.0.3",
8
8
  type: "action",
9
9
  props: {
10
10
  openai,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "openai-list-runs",
5
5
  name: "List Runs",
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.3",
7
+ version: "0.0.4",
8
8
  type: "action",
9
9
  props: {
10
10
  openai,
@@ -1,10 +1,11 @@
1
+ import { parseToolsArray } from "../../common/helpers.mjs";
1
2
  import openai from "../../openai.app.mjs";
2
3
 
3
4
  export default {
4
5
  key: "openai-modify-assistant",
5
6
  name: "Modify an Assistant",
6
7
  description: "Modifies an existing OpenAI assistant. [See the documentation](https://platform.openai.com/docs/api-reference/assistants/modifyAssistant)",
7
- version: "0.0.1",
8
+ version: "0.1.0",
8
9
  type: "action",
9
10
  props: {
10
11
  openai,
@@ -72,7 +73,7 @@ export default {
72
73
  name: this.name,
73
74
  description: this.description,
74
75
  instructions: this.instructions,
75
- tools: this.tools,
76
+ tools: parseToolsArray(this.tools),
76
77
  file_ids: this.file_ids,
77
78
  metadata: this.metadata,
78
79
  });
@@ -4,7 +4,7 @@ export default {
4
4
  key: "openai-modify-message",
5
5
  name: "Modify Message",
6
6
  description: "Modifies an existing message in a thread. [See the documentation](https://platform.openai.com/docs/api-reference)",
7
- version: "0.0.3",
7
+ version: "0.0.4",
8
8
  type: "action",
9
9
  props: {
10
10
  openai,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "openai-modify-run",
5
5
  name: "Modify Run",
6
6
  description: "Modifies an existing run. [See the documentation](https://platform.openai.com/docs/api-reference)",
7
- version: "0.0.2",
7
+ version: "0.0.3",
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.2",
7
+ version: "0.0.3",
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.2",
7
+ version: "0.0.3",
8
8
  type: "action",
9
9
  props: {
10
10
  openai,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "openai-retrieve-run",
5
5
  name: "Retrieve Run",
6
6
  description: "Retrieves a specific run within a thread. [See the documentation](https://platform.openai.com/docs/api-reference)",
7
- version: "0.0.2",
7
+ version: "0.0.3",
8
8
  type: "action",
9
9
  props: {
10
10
  openai,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "openai-retrieve-run-step",
5
5
  name: "Retrieve Run Step",
6
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",
7
+ version: "0.0.3",
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.3",
7
+ version: "0.1.4",
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",
@@ -4,7 +4,7 @@ export default {
4
4
  key: "openai-submit-tool-outputs-to-run",
5
5
  name: "Submit Tool Outputs to Run",
6
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",
7
+ version: "0.0.3",
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.6",
6
+ version: "0.0.7",
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.8",
12
+ version: "0.0.9",
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.5",
9
+ version: "0.0.6",
10
10
  type: "action",
11
11
  props: {
12
12
  openai,
@@ -0,0 +1,18 @@
1
+ export function parseToolsArray(arr) {
2
+ if (!arr) return undefined;
3
+ return arr.map((value) => {
4
+ if ([
5
+ "retrieval",
6
+ "code_interpreter",
7
+ ].includes(value)) {
8
+ return {
9
+ type: value,
10
+ };
11
+ }
12
+ try {
13
+ return JSON.parse(value);
14
+ } catch (e) {
15
+ return value;
16
+ }
17
+ });
18
+ }
package/openai.app.mjs CHANGED
@@ -102,11 +102,7 @@ export default {
102
102
  tools: {
103
103
  type: "string[]",
104
104
  label: "Tools",
105
- description: "A list of tools enabled on the assistant. There can be a maximum of 128 tools per assistant",
106
- options: [
107
- "code_interpreter",
108
- "retrieval",
109
- ],
105
+ description: "Each tool should be a valid JSON object. [See the documentation](https://platform.openai.com/docs/api-reference/assistants/createAssistant#assistants-createassistant-tools) for more information. Examples of function tools [can be found here](https://cookbook.openai.com/examples/how_to_call_functions_with_chat_models#basic-concepts).",
110
106
  optional: true,
111
107
  },
112
108
  file_ids: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/openai",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "description": "Pipedream OpenAI Components",
5
5
  "main": "openai.app.mjs",
6
6
  "keywords": [
@@ -17,9 +17,11 @@
17
17
  "@ffmpeg-installer/ffmpeg": "^1.1.0",
18
18
  "@pipedream/platform": "^1.2.1",
19
19
  "@pipedream/types": "^0.1.4",
20
+ "axios": "^1.6.2",
21
+ "bottleneck": "^2.19.5",
22
+ "form-data": "^4.0.0",
20
23
  "got": "^12.6.0",
21
- "openai": "^3.2.1",
22
- "form-data": "^4.0.0"
24
+ "openai": "^3.2.1"
23
25
  },
24
26
  "devDependencies": {
25
27
  "@types/node": "^17.0.45"
@@ -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.1",
9
+ version: "0.0.2",
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.1",
8
+ version: "0.0.2",
9
9
  type: "source",
10
10
  dedupe: "unique",
11
11
  methods: {