@pipedream/openai 0.2.0 → 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.
- package/actions/cancel-run/cancel-run.mjs +1 -1
- package/actions/chat/chat.mjs +12 -1
- package/actions/classify-items-into-categories/classify-items-into-categories.mjs +1 -1
- package/actions/common/common.mjs +3 -0
- package/actions/create-assistant/create-assistant.mjs +1 -1
- package/actions/create-embeddings/create-embeddings.mjs +1 -1
- package/actions/create-fine-tuning-job/create-fine-tuning-job.mjs +57 -0
- package/actions/create-image/create-image.mjs +1 -1
- package/actions/create-message/create-message.mjs +1 -1
- package/actions/create-run/create-run.mjs +1 -1
- package/actions/create-speech/create-speech.mjs +73 -0
- package/actions/create-thread/create-thread.mjs +1 -1
- package/actions/create-thread-and-run/create-thread-and-run.mjs +1 -1
- package/actions/create-transcription/create-transcription.mjs +1 -1
- package/actions/delete-file/delete-file.mjs +1 -1
- package/actions/list-files/list-files.mjs +2 -1
- package/actions/list-messages/list-messages.mjs +1 -1
- package/actions/list-run-steps/list-run-steps.mjs +1 -1
- package/actions/list-runs/list-runs.mjs +1 -1
- package/actions/modify-assistant/modify-assistant.mjs +1 -1
- package/actions/modify-message/modify-message.mjs +1 -1
- package/actions/modify-run/modify-run.mjs +1 -1
- package/actions/retrieve-file/retrieve-file.mjs +1 -1
- package/actions/retrieve-file-content/retrieve-file-content.mjs +1 -1
- package/actions/retrieve-run/retrieve-run.mjs +1 -1
- package/actions/retrieve-run-step/retrieve-run-step.mjs +1 -1
- package/actions/send-prompt/send-prompt.mjs +1 -1
- package/actions/submit-tool-outputs-to-run/submit-tool-outputs-to-run.mjs +1 -1
- package/actions/summarize/summarize.mjs +1 -1
- package/actions/translate-text/translate-text.mjs +1 -1
- package/actions/upload-file/upload-file.mjs +25 -20
- package/common/constants.mjs +23 -0
- package/openai.app.mjs +97 -12
- package/package.json +4 -3
- package/sources/common.mjs +51 -0
- package/sources/new-file-created/new-file-created.mjs +38 -0
- package/sources/new-fine-tuning-job-created/new-fine-tuning-job-created.mjs +24 -0
|
@@ -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.
|
|
7
|
+
version: "0.0.2",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
openai,
|
package/actions/chat/chat.mjs
CHANGED
|
@@ -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
|
+
version: "0.1.4",
|
|
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",
|
|
@@ -39,6 +39,17 @@ export default {
|
|
|
39
39
|
description: "Provide one or more images to [OpenAI's vision model](https://platform.openai.com/docs/guides/vision). Accepts URLs or base64 encoded strings. Compatible with the `gpt4-vision-preview model`",
|
|
40
40
|
optional: true,
|
|
41
41
|
},
|
|
42
|
+
responseFormat: {
|
|
43
|
+
type: "string",
|
|
44
|
+
label: "Response Format",
|
|
45
|
+
description: "Specify the format that the model must output. [Setting to `json_object` guarantees the message the model generates is valid JSON](https://platform.openai.com/docs/api-reference/chat/create#chat-create-response_format). Defaults to `text`",
|
|
46
|
+
optiions: [
|
|
47
|
+
"text",
|
|
48
|
+
"json_object",
|
|
49
|
+
],
|
|
50
|
+
optional: true,
|
|
51
|
+
default: "text",
|
|
52
|
+
},
|
|
42
53
|
...common.props,
|
|
43
54
|
},
|
|
44
55
|
async run({ $ }) {
|
|
@@ -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
|
+
version: "0.0.6",
|
|
7
7
|
key: "openai-classify-items-into-categories",
|
|
8
8
|
description: "Classify items into specific categories using the Chat API",
|
|
9
9
|
type: "action",
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "openai-create-assistant",
|
|
5
5
|
name: "Create Assistant",
|
|
6
6
|
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.
|
|
7
|
+
version: "0.0.1",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
openai,
|
|
@@ -4,7 +4,7 @@ import { ConfigurationError } from "@pipedream/platform";
|
|
|
4
4
|
|
|
5
5
|
export default {
|
|
6
6
|
name: "Create Embeddings",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.4",
|
|
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",
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import openai from "../../openai.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "openai-create-fine-tuning-job",
|
|
5
|
+
name: "Create Fine Tuning Job",
|
|
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",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
openai,
|
|
11
|
+
model: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
openai,
|
|
14
|
+
"fineTuningModel",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
trainingFile: {
|
|
18
|
+
propDefinition: [
|
|
19
|
+
openai,
|
|
20
|
+
"trainingFile",
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
hyperParameters: {
|
|
24
|
+
type: "object",
|
|
25
|
+
label: "Hyperparameters",
|
|
26
|
+
description: "The hyperparameters used for the fine-tuning job. [See details in the documentation](https://platform.openai.com/docs/api-reference/fine-tuning/create#fine-tuning-create-hyperparameters).",
|
|
27
|
+
optional: true,
|
|
28
|
+
},
|
|
29
|
+
suffix: {
|
|
30
|
+
type: "string",
|
|
31
|
+
label: "Suffix",
|
|
32
|
+
description: "A string of up to 18 characters that will be added to your fine-tuned model name.",
|
|
33
|
+
optional: true,
|
|
34
|
+
},
|
|
35
|
+
validationFile: {
|
|
36
|
+
type: "string",
|
|
37
|
+
label: "Validation File",
|
|
38
|
+
description: "The ID of an uploaded file that contains validation data. [See details in the documentation](https://platform.openai.com/docs/api-reference/fine-tuning/create#fine-tuning-create-validation_file).",
|
|
39
|
+
optional: true,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
async run({ $ }) {
|
|
43
|
+
const response = await this.openai.createFineTuningJob({
|
|
44
|
+
$,
|
|
45
|
+
data: {
|
|
46
|
+
model: this.model,
|
|
47
|
+
training_file: this.trainingFile,
|
|
48
|
+
hyperparameters: this.hyperParameters,
|
|
49
|
+
suffix: this.suffix,
|
|
50
|
+
validation_file: this.validationFile,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
$.export("$summary", `Successfully created fine-tuning job with model ${this.model}`);
|
|
55
|
+
return response;
|
|
56
|
+
},
|
|
57
|
+
};
|
|
@@ -3,7 +3,7 @@ import constants from "../common/constants.mjs";
|
|
|
3
3
|
|
|
4
4
|
export default {
|
|
5
5
|
name: "Create Image",
|
|
6
|
-
version: "0.1.
|
|
6
|
+
version: "0.1.5",
|
|
7
7
|
key: "openai-create-image",
|
|
8
8
|
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
9
|
type: "action",
|
|
@@ -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.
|
|
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-create-run",
|
|
5
5
|
name: "Create Run",
|
|
6
6
|
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.
|
|
7
|
+
version: "0.0.3",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
openai,
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import openai from "../../openai.app.mjs";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
key: "openai-create-speech",
|
|
6
|
+
name: "Create Speech",
|
|
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",
|
|
9
|
+
type: "action",
|
|
10
|
+
props: {
|
|
11
|
+
openai,
|
|
12
|
+
model: {
|
|
13
|
+
propDefinition: [
|
|
14
|
+
openai,
|
|
15
|
+
"ttsModel",
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
input: {
|
|
19
|
+
propDefinition: [
|
|
20
|
+
openai,
|
|
21
|
+
"input",
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
voice: {
|
|
25
|
+
propDefinition: [
|
|
26
|
+
openai,
|
|
27
|
+
"voice",
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
responseFormat: {
|
|
31
|
+
propDefinition: [
|
|
32
|
+
openai,
|
|
33
|
+
"responseFormat",
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
speed: {
|
|
37
|
+
propDefinition: [
|
|
38
|
+
openai,
|
|
39
|
+
"speed",
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
outputFile: {
|
|
43
|
+
type: "string",
|
|
44
|
+
label: "Output Filename",
|
|
45
|
+
description: "The filename of the output audio file that will be written to the `/tmp` folder, e.g. `/tmp/myFile.mp3`",
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
async run({ $ }) {
|
|
49
|
+
const response = await this.openai.createSpeech({
|
|
50
|
+
$,
|
|
51
|
+
data: {
|
|
52
|
+
model: this.model,
|
|
53
|
+
input: this.input,
|
|
54
|
+
voice: this.voice,
|
|
55
|
+
response_format: this.responseFormat,
|
|
56
|
+
speed: Number(this.speed),
|
|
57
|
+
},
|
|
58
|
+
responseType: "arraybuffer",
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const outputFilePath = this.outputFile.includes("tmp/")
|
|
62
|
+
? this.outputFile
|
|
63
|
+
: `/tmp/${this.outputFile}`;
|
|
64
|
+
|
|
65
|
+
await fs.promises.writeFile(outputFilePath, Buffer.from(response));
|
|
66
|
+
|
|
67
|
+
$.export("$summary", "Generated audio successfully");
|
|
68
|
+
return {
|
|
69
|
+
outputFilePath,
|
|
70
|
+
response,
|
|
71
|
+
};
|
|
72
|
+
},
|
|
73
|
+
};
|
|
@@ -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.
|
|
7
|
+
version: "0.0.1",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
openai,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "openai-create-thread-and-run",
|
|
5
5
|
name: "Create Thread and Run",
|
|
6
6
|
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.
|
|
7
|
+
version: "0.0.2",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
openai,
|
|
@@ -22,7 +22,7 @@ const pipelineAsync = promisify(stream.pipeline);
|
|
|
22
22
|
|
|
23
23
|
export default {
|
|
24
24
|
name: "Create Transcription",
|
|
25
|
-
version: "0.1.
|
|
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",
|
|
@@ -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.
|
|
7
|
+
version: "0.0.2",
|
|
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.
|
|
7
|
+
version: "0.0.2",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
openai,
|
|
@@ -13,6 +13,7 @@ export default {
|
|
|
13
13
|
openai,
|
|
14
14
|
"purpose",
|
|
15
15
|
],
|
|
16
|
+
optional: true,
|
|
16
17
|
},
|
|
17
18
|
},
|
|
18
19
|
async run({ $ }) {
|
|
@@ -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.
|
|
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-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.
|
|
7
|
+
version: "0.0.2",
|
|
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.
|
|
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-modify-assistant",
|
|
5
5
|
name: "Modify an Assistant",
|
|
6
6
|
description: "Modifies an existing OpenAI assistant. [See the documentation](https://platform.openai.com/docs/api-reference/assistants/modifyAssistant)",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.1",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
openai,
|
|
@@ -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.
|
|
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.
|
|
7
|
+
version: "0.0.2",
|
|
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.
|
|
7
|
+
version: "0.0.2",
|
|
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.
|
|
7
|
+
version: "0.0.2",
|
|
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.
|
|
7
|
+
version: "0.0.2",
|
|
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.
|
|
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",
|
|
@@ -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.
|
|
7
|
+
version: "0.0.2",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
openai,
|
|
@@ -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.
|
|
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",
|
|
@@ -1,41 +1,46 @@
|
|
|
1
1
|
import openai from "../../openai.app.mjs";
|
|
2
|
+
import FormData from "form-data";
|
|
3
|
+
import fs from "fs";
|
|
2
4
|
|
|
3
5
|
export default {
|
|
4
6
|
key: "openai-upload-file",
|
|
5
7
|
name: "Upload File",
|
|
6
|
-
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://
|
|
7
|
-
version: "0.0.
|
|
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",
|
|
8
10
|
type: "action",
|
|
9
11
|
props: {
|
|
10
12
|
openai,
|
|
11
13
|
file: {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
propDefinition: [
|
|
15
|
+
openai,
|
|
16
|
+
"file",
|
|
17
|
+
],
|
|
15
18
|
},
|
|
16
19
|
purpose: {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
options: [
|
|
21
|
-
{
|
|
22
|
-
label: "fine-tune",
|
|
23
|
-
value: "fine-tune",
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
label: "assistants",
|
|
27
|
-
value: "assistants",
|
|
28
|
-
},
|
|
20
|
+
propDefinition: [
|
|
21
|
+
openai,
|
|
22
|
+
"purpose",
|
|
29
23
|
],
|
|
30
24
|
},
|
|
31
25
|
},
|
|
32
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
|
+
|
|
33
37
|
const response = await this.openai.uploadFile({
|
|
34
|
-
|
|
35
|
-
|
|
38
|
+
$,
|
|
39
|
+
data,
|
|
40
|
+
headers: data.getHeaders(),
|
|
36
41
|
});
|
|
37
42
|
|
|
38
|
-
$.export("$summary", `Successfully uploaded file with purpose: ${
|
|
43
|
+
$.export("$summary", `Successfully uploaded file with purpose: ${purpose}`);
|
|
39
44
|
return response;
|
|
40
45
|
},
|
|
41
46
|
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const FINE_TUNING_MODEL_OPTIONS = [
|
|
2
|
+
{
|
|
3
|
+
label: "gpt-3.5-turbo-1106 (recommended)",
|
|
4
|
+
value: "gpt-3.5-turbo-1106",
|
|
5
|
+
},
|
|
6
|
+
{
|
|
7
|
+
label: "gpt-3.5-turbo-0613",
|
|
8
|
+
value: "gpt-3.5-turbo-0613",
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
label: "babbage-002",
|
|
12
|
+
value: "babbage-002",
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
label: "davinci-002",
|
|
16
|
+
value: "davinci-002",
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
label:
|
|
20
|
+
"gpt-4-0613 (experimental — eligible users will be presented with an option to request access in the fine-tuning UI)",
|
|
21
|
+
value: "gpt-4-0613",
|
|
22
|
+
},
|
|
23
|
+
];
|
package/openai.app.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { axios } from "@pipedream/platform";
|
|
2
|
+
import { FINE_TUNING_MODEL_OPTIONS } from "./common/constants.mjs";
|
|
2
3
|
|
|
3
4
|
export default {
|
|
4
5
|
type: "app",
|
|
@@ -76,6 +77,11 @@ export default {
|
|
|
76
77
|
label: "Run ID",
|
|
77
78
|
description: "The unique identifier for the run.",
|
|
78
79
|
},
|
|
80
|
+
stepId: {
|
|
81
|
+
type: "string",
|
|
82
|
+
label: "Step ID",
|
|
83
|
+
description: "The unique identifier for the step.",
|
|
84
|
+
},
|
|
79
85
|
assistantId: {
|
|
80
86
|
type: "string",
|
|
81
87
|
label: "Assistant ID",
|
|
@@ -203,16 +209,76 @@ export default {
|
|
|
203
209
|
}));
|
|
204
210
|
},
|
|
205
211
|
},
|
|
212
|
+
file: {
|
|
213
|
+
type: "string",
|
|
214
|
+
label: "File",
|
|
215
|
+
description: "The path to a file in the `/tmp` directory. [See the documentation on working with files](https://pipedream.com/docs/code/nodejs/working-with-files/#writing-a-file-to-tmp). See the [Assistants Tools guide](https://platform.openai.com/docs/assistants/tools) to learn more about the types of files supported. The Fine-tuning API only supports `.jsonl` files.",
|
|
216
|
+
},
|
|
206
217
|
purpose: {
|
|
207
218
|
type: "string",
|
|
208
219
|
label: "Purpose",
|
|
209
|
-
description: "The intended purpose of the file.",
|
|
220
|
+
description: "The intended purpose of the uploaded file. Use 'fine-tune' for fine-tuning and 'assistants' for assistants and messages.",
|
|
221
|
+
options: [
|
|
222
|
+
"fine-tune",
|
|
223
|
+
"assistants",
|
|
224
|
+
],
|
|
225
|
+
},
|
|
226
|
+
ttsModel: {
|
|
227
|
+
type: "string",
|
|
228
|
+
label: "Model",
|
|
229
|
+
description: "One of the available [TTS models](https://platform.openai.com/docs/models/tts).",
|
|
230
|
+
options: [
|
|
231
|
+
"tts-1",
|
|
232
|
+
"tts-1-hd",
|
|
233
|
+
],
|
|
234
|
+
},
|
|
235
|
+
fineTuningModel: {
|
|
236
|
+
type: "string",
|
|
237
|
+
label: "Fine Tuning Model",
|
|
238
|
+
description: "The name of the model to fine-tune. [See the supported models](https://platform.openai.com/docs/guides/fine-tuning/what-models-can-be-fine-tuned).",
|
|
239
|
+
options: FINE_TUNING_MODEL_OPTIONS,
|
|
240
|
+
},
|
|
241
|
+
input: {
|
|
242
|
+
type: "string",
|
|
243
|
+
label: "Input",
|
|
244
|
+
description: "The text to generate audio for. The maximum length is 4096 characters.",
|
|
245
|
+
},
|
|
246
|
+
voice: {
|
|
247
|
+
type: "string",
|
|
248
|
+
label: "Voice",
|
|
249
|
+
description: "The voice to use when generating the audio.",
|
|
250
|
+
options: [
|
|
251
|
+
"alloy",
|
|
252
|
+
"echo",
|
|
253
|
+
"fable",
|
|
254
|
+
"onyx",
|
|
255
|
+
"nova",
|
|
256
|
+
"shimmer",
|
|
257
|
+
],
|
|
258
|
+
},
|
|
259
|
+
responseFormat: {
|
|
260
|
+
type: "string",
|
|
261
|
+
label: "Response Format",
|
|
262
|
+
description: "The format to audio in.",
|
|
263
|
+
options: [
|
|
264
|
+
"mp3",
|
|
265
|
+
"opus",
|
|
266
|
+
"aac",
|
|
267
|
+
"flac",
|
|
268
|
+
],
|
|
210
269
|
optional: true,
|
|
211
270
|
},
|
|
212
|
-
|
|
271
|
+
speed: {
|
|
213
272
|
type: "string",
|
|
214
|
-
label: "
|
|
215
|
-
description: "The
|
|
273
|
+
label: "Speed",
|
|
274
|
+
description: "The speed of the generated audio. Provide a value from 0.25 to 4.0.",
|
|
275
|
+
default: "1.0",
|
|
276
|
+
optional: true,
|
|
277
|
+
},
|
|
278
|
+
trainingFile: {
|
|
279
|
+
type: "string",
|
|
280
|
+
label: "Training File",
|
|
281
|
+
description: "The ID of an uploaded file that contains training data. You can use the **Upload File** action and reference the returned ID here.",
|
|
216
282
|
},
|
|
217
283
|
},
|
|
218
284
|
methods: {
|
|
@@ -241,12 +307,13 @@ export default {
|
|
|
241
307
|
...args
|
|
242
308
|
} = {}) {
|
|
243
309
|
return axios($, {
|
|
310
|
+
...args,
|
|
244
311
|
url: `${this._baseApiUrl()}${path}`,
|
|
245
312
|
headers: {
|
|
313
|
+
...args.headers,
|
|
246
314
|
...this._commonHeaders(),
|
|
247
315
|
},
|
|
248
316
|
maxBodyLength: Infinity,
|
|
249
|
-
...args,
|
|
250
317
|
});
|
|
251
318
|
},
|
|
252
319
|
async models({ $ }) {
|
|
@@ -591,16 +658,14 @@ export default {
|
|
|
591
658
|
},
|
|
592
659
|
});
|
|
593
660
|
},
|
|
594
|
-
async uploadFile({
|
|
595
|
-
file, purpose,
|
|
596
|
-
}) {
|
|
661
|
+
async uploadFile(args) {
|
|
597
662
|
return this._makeRequest({
|
|
598
663
|
method: "POST",
|
|
599
664
|
path: "/files",
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
665
|
+
...args,
|
|
666
|
+
headers: {
|
|
667
|
+
...args.headers,
|
|
668
|
+
...this._betaHeaders(),
|
|
604
669
|
},
|
|
605
670
|
});
|
|
606
671
|
},
|
|
@@ -623,5 +688,25 @@ export default {
|
|
|
623
688
|
path: `/files/${file_id}/content`,
|
|
624
689
|
});
|
|
625
690
|
},
|
|
691
|
+
async listFineTuningJobs(args) {
|
|
692
|
+
return this._makeRequest({
|
|
693
|
+
path: "/fine_tuning/jobs",
|
|
694
|
+
...args,
|
|
695
|
+
});
|
|
696
|
+
},
|
|
697
|
+
async createSpeech(args) {
|
|
698
|
+
return this._makeRequest({
|
|
699
|
+
path: "/audio/speech",
|
|
700
|
+
method: "POST",
|
|
701
|
+
...args,
|
|
702
|
+
});
|
|
703
|
+
},
|
|
704
|
+
async createFineTuningJob(args) {
|
|
705
|
+
return this._makeRequest({
|
|
706
|
+
path: "/fine_tuning/jobs",
|
|
707
|
+
method: "POST",
|
|
708
|
+
...args,
|
|
709
|
+
});
|
|
710
|
+
},
|
|
626
711
|
},
|
|
627
712
|
};
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipedream/openai",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Pipedream OpenAI Components",
|
|
5
|
-
"main": "
|
|
5
|
+
"main": "openai.app.mjs",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"pipedream",
|
|
8
8
|
"openai"
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
"@pipedream/platform": "^1.2.1",
|
|
19
19
|
"@pipedream/types": "^0.1.4",
|
|
20
20
|
"got": "^12.6.0",
|
|
21
|
-
"openai": "^3.2.1"
|
|
21
|
+
"openai": "^3.2.1",
|
|
22
|
+
"form-data": "^4.0.0"
|
|
22
23
|
},
|
|
23
24
|
"devDependencies": {
|
|
24
25
|
"@types/node": "^17.0.45"
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";
|
|
2
|
+
import openai from "../openai.app.mjs";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
props: {
|
|
6
|
+
openai,
|
|
7
|
+
db: "$.service.db",
|
|
8
|
+
timer: {
|
|
9
|
+
type: "$.interface.timer",
|
|
10
|
+
default: {
|
|
11
|
+
intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
methods: {
|
|
16
|
+
_getSavedItems() {
|
|
17
|
+
return this.db.get("savedItems") ?? [];
|
|
18
|
+
},
|
|
19
|
+
_setSavedItems(value) {
|
|
20
|
+
this.db.set("savedItems", value);
|
|
21
|
+
},
|
|
22
|
+
getMeta() {
|
|
23
|
+
throw new Error("No item metadata implemented!");
|
|
24
|
+
},
|
|
25
|
+
async getData() {
|
|
26
|
+
throw new Error("No item fetching implemented!");
|
|
27
|
+
},
|
|
28
|
+
async getAndProcessItems(maxEvents) {
|
|
29
|
+
const savedItems = this._getSavedItems();
|
|
30
|
+
const { data } = await this.getData();
|
|
31
|
+
data
|
|
32
|
+
?.filter(({ id }) => !savedItems.includes(id))
|
|
33
|
+
.reverse()
|
|
34
|
+
.forEach((item, index) => {
|
|
35
|
+
if (!maxEvents || index < maxEvents) {
|
|
36
|
+
this.$emit(item, this.getMeta(item));
|
|
37
|
+
}
|
|
38
|
+
savedItems.push(item.id);
|
|
39
|
+
});
|
|
40
|
+
this._setSavedItems(savedItems);
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
hooks: {
|
|
44
|
+
async deploy() {
|
|
45
|
+
await this.getAndProcessItems(10);
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
async run() {
|
|
49
|
+
await this.getAndProcessItems();
|
|
50
|
+
},
|
|
51
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import openai from "../../openai.app.mjs";
|
|
2
|
+
import common from "../common.mjs";
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
...common,
|
|
6
|
+
key: "openai-new-file-created",
|
|
7
|
+
name: "New File Created",
|
|
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",
|
|
10
|
+
type: "source",
|
|
11
|
+
dedupe: "unique",
|
|
12
|
+
props: {
|
|
13
|
+
...common.props,
|
|
14
|
+
purpose: {
|
|
15
|
+
propDefinition: [
|
|
16
|
+
openai,
|
|
17
|
+
"purpose",
|
|
18
|
+
],
|
|
19
|
+
description: "If specified, events will only be emitted for files with the specified purpose.",
|
|
20
|
+
optional: true,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
methods: {
|
|
24
|
+
...common.methods,
|
|
25
|
+
async getData() {
|
|
26
|
+
return this.openai.listFiles({
|
|
27
|
+
purpose: this.purpose,
|
|
28
|
+
});
|
|
29
|
+
},
|
|
30
|
+
getMeta(item) {
|
|
31
|
+
return {
|
|
32
|
+
id: item.id,
|
|
33
|
+
summary: `New File: ${item.filename}`,
|
|
34
|
+
ts: item.created_at * 1000,
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import common from "../common.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
...common,
|
|
5
|
+
key: "openai-new-fine-tuning-job-created",
|
|
6
|
+
name: "New Fine Tuning Job Created",
|
|
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",
|
|
9
|
+
type: "source",
|
|
10
|
+
dedupe: "unique",
|
|
11
|
+
methods: {
|
|
12
|
+
...common.methods,
|
|
13
|
+
async getData() {
|
|
14
|
+
return this.openai.listFineTuningJobs();
|
|
15
|
+
},
|
|
16
|
+
getMeta(item) {
|
|
17
|
+
return {
|
|
18
|
+
id: item.id,
|
|
19
|
+
summary: `New Fine Tuning Job: ${item.id}`,
|
|
20
|
+
ts: item.created_at * 1000,
|
|
21
|
+
};
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
};
|