@pipedream/openai 0.1.9 → 0.2.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 +33 -0
- package/actions/chat/chat.mjs +9 -2
- package/actions/classify-items-into-categories/classify-items-into-categories.mjs +1 -1
- package/actions/common/common-helper.mjs +1 -1
- package/actions/common/common.mjs +25 -11
- package/actions/common/lang.mjs +16 -16
- package/actions/create-assistant/create-assistant.mjs +71 -0
- package/actions/create-embeddings/create-embeddings.mjs +2 -2
- package/actions/create-image/create-image.mjs +55 -2
- package/actions/create-message/create-message.mjs +64 -0
- package/actions/create-run/create-run.mjs +64 -0
- package/actions/create-thread/create-thread.mjs +36 -0
- package/actions/create-thread-and-run/create-thread-and-run.mjs +61 -0
- package/actions/create-transcription/create-transcription.mjs +2 -3
- package/actions/delete-file/delete-file.mjs +26 -0
- package/actions/list-files/list-files.mjs +26 -0
- package/actions/list-messages/list-messages.mjs +54 -0
- package/actions/list-run-steps/list-run-steps.mjs +65 -0
- package/actions/list-runs/list-runs.mjs +68 -0
- package/actions/modify-assistant/modify-assistant.mjs +82 -0
- package/actions/modify-message/modify-message.mjs +42 -0
- package/actions/modify-run/modify-run.mjs +42 -0
- package/actions/retrieve-file/retrieve-file.mjs +26 -0
- package/actions/retrieve-file-content/retrieve-file-content.mjs +25 -0
- package/actions/retrieve-run/retrieve-run.mjs +33 -0
- package/actions/retrieve-run-step/retrieve-run-step.mjs +40 -0
- package/actions/send-prompt/send-prompt.mjs +2 -2
- package/actions/submit-tool-outputs-to-run/submit-tool-outputs-to-run.mjs +41 -0
- package/actions/summarize/summarize.mjs +1 -1
- package/actions/translate-text/translate-text.mjs +1 -1
- package/actions/upload-file/upload-file.mjs +41 -0
- package/openai.app.mjs +627 -0
- package/package.json +1 -1
- package/app/openai.app.mjs +0 -180
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import openai from "../../openai.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
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.1",
|
|
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.cancelRun({
|
|
26
|
+
threadId: this.threadId,
|
|
27
|
+
runId: this.runId,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
$.export("$summary", `Successfully cancelled run ${this.runId} in thread ${this.threadId}`);
|
|
31
|
+
return response;
|
|
32
|
+
},
|
|
33
|
+
};
|
package/actions/chat/chat.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import openai from "../../
|
|
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: "Chat",
|
|
7
|
-
version: "0.1.
|
|
7
|
+
version: "0.1.3",
|
|
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",
|
|
@@ -33,10 +33,17 @@ export default {
|
|
|
33
33
|
description: "_Advanced_. Because [the models have no memory of past chat requests](https://platform.openai.com/docs/guides/chat/introduction), all relevant information must be supplied via the conversation. You can provide [an array of messages](https://platform.openai.com/docs/guides/chat/introduction) from prior conversations here. If this param is set, the action ignores the values passed to **System Instructions** and **Assistant Response**, appends the new **User Message** to the end of this array, and sends it to the API.",
|
|
34
34
|
optional: true,
|
|
35
35
|
},
|
|
36
|
+
images: {
|
|
37
|
+
label: "Images",
|
|
38
|
+
type: "string[]",
|
|
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
|
+
optional: true,
|
|
41
|
+
},
|
|
36
42
|
...common.props,
|
|
37
43
|
},
|
|
38
44
|
async run({ $ }) {
|
|
39
45
|
const args = this._getChatArgs();
|
|
46
|
+
|
|
40
47
|
const response = await this.openai.createChatCompletion({
|
|
41
48
|
$,
|
|
42
49
|
args,
|
|
@@ -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.5",
|
|
7
7
|
key: "openai-classify-items-into-categories",
|
|
8
8
|
description: "Classify items into specific categories using the Chat API",
|
|
9
9
|
type: "action",
|
|
@@ -77,6 +77,26 @@ export default {
|
|
|
77
77
|
user: this.user,
|
|
78
78
|
};
|
|
79
79
|
},
|
|
80
|
+
_getUserMessageContent() {
|
|
81
|
+
let content = [];
|
|
82
|
+
if (this.images) {
|
|
83
|
+
for (const image of this.images) {
|
|
84
|
+
content.push({
|
|
85
|
+
"type": "image_url",
|
|
86
|
+
"image_url": {
|
|
87
|
+
"url": image,
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
content.push({
|
|
94
|
+
"type": "text",
|
|
95
|
+
"text": this.userMessage,
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
return content;
|
|
99
|
+
},
|
|
80
100
|
_getChatArgs() {
|
|
81
101
|
if (this.messages && this.messages.length && !this.userMessage) {
|
|
82
102
|
throw new ConfigurationError(
|
|
@@ -112,13 +132,6 @@ export default {
|
|
|
112
132
|
}
|
|
113
133
|
messages.push(parsed);
|
|
114
134
|
}
|
|
115
|
-
// Finally, we want to append the user message to the end of the array
|
|
116
|
-
if (this.userMessage) {
|
|
117
|
-
messages.push({
|
|
118
|
-
"role": "user",
|
|
119
|
-
"content": this.userMessage,
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
135
|
} else {
|
|
123
136
|
if (this.systemInstructions) {
|
|
124
137
|
messages.push({
|
|
@@ -126,12 +139,13 @@ export default {
|
|
|
126
139
|
"content": this.systemInstructions,
|
|
127
140
|
});
|
|
128
141
|
}
|
|
129
|
-
messages.push({
|
|
130
|
-
"role": "user",
|
|
131
|
-
"content": this.userMessage,
|
|
132
|
-
});
|
|
133
142
|
}
|
|
134
143
|
|
|
144
|
+
messages.push({
|
|
145
|
+
"role": "user",
|
|
146
|
+
"content": this._getUserMessageContent(),
|
|
147
|
+
});
|
|
148
|
+
|
|
135
149
|
return {
|
|
136
150
|
...this._getCommonArgs(),
|
|
137
151
|
messages,
|
package/actions/common/lang.mjs
CHANGED
|
@@ -34,67 +34,67 @@ export default {
|
|
|
34
34
|
},
|
|
35
35
|
{
|
|
36
36
|
"label": "Arabic (Algeria)",
|
|
37
|
-
"value": "ar-dz"
|
|
37
|
+
"value": "ar-dz",
|
|
38
38
|
},
|
|
39
39
|
{
|
|
40
40
|
"label": "Arabic (Bahrain)",
|
|
41
|
-
"value": "ar-bh"
|
|
41
|
+
"value": "ar-bh",
|
|
42
42
|
},
|
|
43
43
|
{
|
|
44
44
|
"label": "Arabic (Egypt)",
|
|
45
|
-
"value": "ar-eg"
|
|
45
|
+
"value": "ar-eg",
|
|
46
46
|
},
|
|
47
47
|
{
|
|
48
48
|
"label": "Arabic (Iraq)",
|
|
49
|
-
"value": "ar-iq"
|
|
49
|
+
"value": "ar-iq",
|
|
50
50
|
},
|
|
51
51
|
{
|
|
52
52
|
"label": "Arabic (Jordan)",
|
|
53
|
-
"value": "ar-jo"
|
|
53
|
+
"value": "ar-jo",
|
|
54
54
|
},
|
|
55
55
|
{
|
|
56
56
|
"label": "Arabic (Kuwait)",
|
|
57
|
-
"value": "ar-kw"
|
|
57
|
+
"value": "ar-kw",
|
|
58
58
|
},
|
|
59
59
|
{
|
|
60
60
|
"label": "Arabic (Lebanon)",
|
|
61
|
-
"value": "ar-lb"
|
|
61
|
+
"value": "ar-lb",
|
|
62
62
|
},
|
|
63
63
|
{
|
|
64
64
|
"label": "Arabic (Libya)",
|
|
65
|
-
"value": "ar-ly"
|
|
65
|
+
"value": "ar-ly",
|
|
66
66
|
},
|
|
67
67
|
{
|
|
68
68
|
"label": "Arabic (Morocco)",
|
|
69
|
-
"value": "ar-ma"
|
|
69
|
+
"value": "ar-ma",
|
|
70
70
|
},
|
|
71
71
|
{
|
|
72
72
|
"label": "Arabic (Oman)",
|
|
73
|
-
"value": "ar-om"
|
|
73
|
+
"value": "ar-om",
|
|
74
74
|
},
|
|
75
75
|
{
|
|
76
76
|
"label": "Arabic (Qatar)",
|
|
77
|
-
"value": "ar-qa"
|
|
77
|
+
"value": "ar-qa",
|
|
78
78
|
},
|
|
79
79
|
{
|
|
80
80
|
"label": "Arabic (Saudi Arabia)",
|
|
81
|
-
"value": "ar-sa"
|
|
81
|
+
"value": "ar-sa",
|
|
82
82
|
},
|
|
83
83
|
{
|
|
84
84
|
"label": "Arabic (Syria)",
|
|
85
|
-
"value": "ar-sy"
|
|
85
|
+
"value": "ar-sy",
|
|
86
86
|
},
|
|
87
87
|
{
|
|
88
88
|
"label": "Arabic (Tunisia)",
|
|
89
|
-
"value": "ar-tn"
|
|
89
|
+
"value": "ar-tn",
|
|
90
90
|
},
|
|
91
91
|
{
|
|
92
92
|
"label": "Arabic (U.A.E.)",
|
|
93
|
-
"value": "ar-ae"
|
|
93
|
+
"value": "ar-ae",
|
|
94
94
|
},
|
|
95
95
|
{
|
|
96
96
|
"label": "Arabic (Yemen)",
|
|
97
|
-
"value": "ar-ye"
|
|
97
|
+
"value": "ar-ye",
|
|
98
98
|
},
|
|
99
99
|
{
|
|
100
100
|
"label": "Assamese",
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import openai from "../../openai.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "openai-create-assistant",
|
|
5
|
+
name: "Create Assistant",
|
|
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.{{ts}}",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
openai,
|
|
11
|
+
model: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
openai,
|
|
14
|
+
"assistantModel",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
name: {
|
|
18
|
+
propDefinition: [
|
|
19
|
+
openai,
|
|
20
|
+
"name",
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
description: {
|
|
24
|
+
propDefinition: [
|
|
25
|
+
openai,
|
|
26
|
+
"description",
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
instructions: {
|
|
30
|
+
propDefinition: [
|
|
31
|
+
openai,
|
|
32
|
+
"instructions",
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
tools: {
|
|
36
|
+
propDefinition: [
|
|
37
|
+
openai,
|
|
38
|
+
"tools",
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
file_ids: {
|
|
42
|
+
propDefinition: [
|
|
43
|
+
openai,
|
|
44
|
+
"file_ids",
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
metadata: {
|
|
48
|
+
propDefinition: [
|
|
49
|
+
openai,
|
|
50
|
+
"metadata",
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
async run({ $ }) {
|
|
55
|
+
const response = await this.openai.createAssistant({
|
|
56
|
+
$,
|
|
57
|
+
model: this.model,
|
|
58
|
+
name: this.name,
|
|
59
|
+
description: this.description,
|
|
60
|
+
instructions: this.instructions,
|
|
61
|
+
tools: (this.tools || []).map((tool) => ({
|
|
62
|
+
type: tool,
|
|
63
|
+
})),
|
|
64
|
+
file_ids: this.file_ids,
|
|
65
|
+
metadata: this.metadata,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
$.export("$summary", `Successfully created an assistant with ID: ${response.id}`);
|
|
69
|
+
return response;
|
|
70
|
+
},
|
|
71
|
+
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import openai from "../../
|
|
1
|
+
import openai from "../../openai.app.mjs";
|
|
2
2
|
import common from "../common/common.mjs";
|
|
3
3
|
import { ConfigurationError } from "@pipedream/platform";
|
|
4
4
|
|
|
5
5
|
export default {
|
|
6
6
|
name: "Create Embeddings",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.3",
|
|
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",
|
|
@@ -1,14 +1,30 @@
|
|
|
1
|
-
import openai from "../../
|
|
1
|
+
import openai from "../../openai.app.mjs";
|
|
2
2
|
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.4",
|
|
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",
|
|
10
10
|
props: {
|
|
11
11
|
openai,
|
|
12
|
+
model: {
|
|
13
|
+
label: "Model",
|
|
14
|
+
description: "Choose the DALL·E models to generate image(s) with.",
|
|
15
|
+
type: "string",
|
|
16
|
+
options: [
|
|
17
|
+
{
|
|
18
|
+
label: "dall-e-2",
|
|
19
|
+
value: "dall-e-2",
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
label: "dall-e-3",
|
|
23
|
+
value: "dall-e-3",
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
default: "dall-e-3",
|
|
27
|
+
},
|
|
12
28
|
prompt: {
|
|
13
29
|
label: "Prompt",
|
|
14
30
|
description: "A text description of the desired image(s). The maximum length is 1000 characters.",
|
|
@@ -29,6 +45,40 @@ export default {
|
|
|
29
45
|
options: constants.IMAGE_SIZES,
|
|
30
46
|
default: "1024x1024",
|
|
31
47
|
},
|
|
48
|
+
quality: {
|
|
49
|
+
label: "Quality",
|
|
50
|
+
description: "The quality of the image",
|
|
51
|
+
type: "string",
|
|
52
|
+
optional: true,
|
|
53
|
+
options: [
|
|
54
|
+
{
|
|
55
|
+
label: "Standard",
|
|
56
|
+
value: "standard",
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
label: "HD",
|
|
60
|
+
value: "HD",
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
default: "standard",
|
|
64
|
+
},
|
|
65
|
+
style: {
|
|
66
|
+
label: "Style",
|
|
67
|
+
description: "The style of the image",
|
|
68
|
+
type: "string",
|
|
69
|
+
optional: true,
|
|
70
|
+
options: [
|
|
71
|
+
{
|
|
72
|
+
label: "Natural",
|
|
73
|
+
value: "natural",
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
label: "Vivid",
|
|
77
|
+
value: "vivid",
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
default: "natural",
|
|
81
|
+
},
|
|
32
82
|
},
|
|
33
83
|
async run({ $ }) {
|
|
34
84
|
const response = await this.openai.createImage({
|
|
@@ -38,6 +88,9 @@ export default {
|
|
|
38
88
|
n: this.n,
|
|
39
89
|
size: this.size,
|
|
40
90
|
response_format: this.responseFormat,
|
|
91
|
+
model: this.model,
|
|
92
|
+
quality: this.quality,
|
|
93
|
+
style: this.style,
|
|
41
94
|
},
|
|
42
95
|
});
|
|
43
96
|
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import openai from "../../openai.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
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.2",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
openai,
|
|
11
|
+
threadId: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
openai,
|
|
14
|
+
"threadId",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
content: {
|
|
18
|
+
propDefinition: [
|
|
19
|
+
openai,
|
|
20
|
+
"content",
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
role: {
|
|
24
|
+
propDefinition: [
|
|
25
|
+
openai,
|
|
26
|
+
"role",
|
|
27
|
+
],
|
|
28
|
+
default: "user",
|
|
29
|
+
},
|
|
30
|
+
fileIds: {
|
|
31
|
+
propDefinition: [
|
|
32
|
+
openai,
|
|
33
|
+
"fileIds",
|
|
34
|
+
],
|
|
35
|
+
optional: true,
|
|
36
|
+
},
|
|
37
|
+
metadata: {
|
|
38
|
+
propDefinition: [
|
|
39
|
+
openai,
|
|
40
|
+
"metadata",
|
|
41
|
+
],
|
|
42
|
+
optional: true,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
async run({ $ }) {
|
|
46
|
+
const fileIdsArray = this.fileIds
|
|
47
|
+
? this.fileIds.map((fileId) => fileId.trim())
|
|
48
|
+
: undefined;
|
|
49
|
+
const metadataObject = this.metadata
|
|
50
|
+
? JSON.parse(this.metadata)
|
|
51
|
+
: undefined;
|
|
52
|
+
|
|
53
|
+
const response = await this.openai.createMessage({
|
|
54
|
+
threadId: this.threadId,
|
|
55
|
+
content: this.content,
|
|
56
|
+
role: this.role,
|
|
57
|
+
fileIds: fileIdsArray,
|
|
58
|
+
metadata: metadataObject,
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
$.export("$summary", `Successfully created a message in thread ${this.threadId}`);
|
|
62
|
+
return response;
|
|
63
|
+
},
|
|
64
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import openai from "../../openai.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "openai-create-run",
|
|
5
|
+
name: "Create Run",
|
|
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.2",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
openai,
|
|
11
|
+
threadId: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
openai,
|
|
14
|
+
"threadId",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
assistantId: {
|
|
18
|
+
propDefinition: [
|
|
19
|
+
openai,
|
|
20
|
+
"assistantId",
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
model: {
|
|
24
|
+
propDefinition: [
|
|
25
|
+
openai,
|
|
26
|
+
"model",
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
instructions: {
|
|
30
|
+
propDefinition: [
|
|
31
|
+
openai,
|
|
32
|
+
"instructions",
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
tools: {
|
|
36
|
+
propDefinition: [
|
|
37
|
+
openai,
|
|
38
|
+
"tools",
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
metadata: {
|
|
42
|
+
propDefinition: [
|
|
43
|
+
openai,
|
|
44
|
+
"metadata",
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
async run({ $ }) {
|
|
49
|
+
const response = await this.openai.createRun({
|
|
50
|
+
threadId: this.threadId,
|
|
51
|
+
assistantId: this.assistantId,
|
|
52
|
+
model: this.model,
|
|
53
|
+
instructions: this.instructions,
|
|
54
|
+
tools: this.tools,
|
|
55
|
+
metadata: this.metadata,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const summary = response.id
|
|
59
|
+
? `Successfully created a run with ID: ${response.id}`
|
|
60
|
+
: `Successfully created a run in thread ${this.threadId}`;
|
|
61
|
+
$.export("$summary", summary);
|
|
62
|
+
return response;
|
|
63
|
+
},
|
|
64
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import openai from "../../openai.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "openai-create-thread",
|
|
5
|
+
name: "Create Thread",
|
|
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.{{ts}}",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
openai,
|
|
11
|
+
messages: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
openai,
|
|
14
|
+
"messages",
|
|
15
|
+
],
|
|
16
|
+
optional: true,
|
|
17
|
+
},
|
|
18
|
+
metadata: {
|
|
19
|
+
propDefinition: [
|
|
20
|
+
openai,
|
|
21
|
+
"metadata",
|
|
22
|
+
],
|
|
23
|
+
optional: true,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
async run({ $ }) {
|
|
27
|
+
const response = await this.openai.createThread({
|
|
28
|
+
$,
|
|
29
|
+
messages: this.messages,
|
|
30
|
+
metadata: this.metadata,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
$.export("$summary", `Successfully created a thread with ID: ${response.id}`);
|
|
34
|
+
return response;
|
|
35
|
+
},
|
|
36
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import openai from "../../openai.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "openai-create-thread-and-run",
|
|
5
|
+
name: "Create Thread and Run",
|
|
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.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
props: {
|
|
10
|
+
openai,
|
|
11
|
+
assistantId: {
|
|
12
|
+
propDefinition: [
|
|
13
|
+
openai,
|
|
14
|
+
"assistantId",
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
thread: {
|
|
18
|
+
type: "object",
|
|
19
|
+
label: "Thread",
|
|
20
|
+
description: "The thread object containing messages and other optional properties.",
|
|
21
|
+
optional: true,
|
|
22
|
+
},
|
|
23
|
+
model: {
|
|
24
|
+
propDefinition: [
|
|
25
|
+
openai,
|
|
26
|
+
"model",
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
instructions: {
|
|
30
|
+
propDefinition: [
|
|
31
|
+
openai,
|
|
32
|
+
"instructions",
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
tools: {
|
|
36
|
+
propDefinition: [
|
|
37
|
+
openai,
|
|
38
|
+
"tools",
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
metadata: {
|
|
42
|
+
propDefinition: [
|
|
43
|
+
openai,
|
|
44
|
+
"metadata",
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
async run({ $ }) {
|
|
49
|
+
const response = await this.openai.createThreadAndRun({
|
|
50
|
+
assistant_id: this.assistantId,
|
|
51
|
+
thread: this.thread,
|
|
52
|
+
model: this.model,
|
|
53
|
+
instructions: this.instructions,
|
|
54
|
+
tools: this.tools,
|
|
55
|
+
metadata: this.metadata,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
$.export("$summary", `Successfully created thread and initiated run with ID: ${response.id}`);
|
|
59
|
+
return response;
|
|
60
|
+
},
|
|
61
|
+
};
|
|
@@ -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 "../../
|
|
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.
|
|
25
|
+
version: "0.1.1",
|
|
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.1",
|
|
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
|
+
};
|