@pipedream/openai 1.0.1 → 1.1.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/analyze-image-content/analyze-image-content.mjs +7 -1
- package/actions/chat/chat.mjs +1 -1
- package/actions/chat-using-file-search/chat-using-file-search.mjs +1 -1
- package/actions/chat-using-functions/chat-using-functions.mjs +1 -1
- package/actions/chat-using-web-search/chat-using-web-search.mjs +1 -1
- package/actions/chat-with-responses-api/chat-with-responses-api.mjs +171 -0
- package/actions/classify-items-into-categories/classify-items-into-categories.mjs +1 -1
- package/actions/convert-text-to-speech/convert-text-to-speech.mjs +8 -3
- package/actions/create-batch/create-batch.mjs +7 -1
- package/actions/create-embeddings/create-embeddings.mjs +1 -1
- package/actions/create-image/create-image.mjs +7 -2
- package/actions/create-transcription/create-transcription.mjs +7 -1
- package/actions/retrieve-file-content/retrieve-file-content.mjs +6 -1
- package/actions/send-prompt/send-prompt.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 +7 -1
- package/common/helpers.mjs +49 -0
- package/package.json +1 -2
|
@@ -8,7 +8,7 @@ export default {
|
|
|
8
8
|
key: "openai-analyze-image-content",
|
|
9
9
|
name: "Analyze Image Content",
|
|
10
10
|
description: "Send a message or question about an image and receive a response. [See the documentation](https://platform.openai.com/docs/api-reference/runs/createThreadAndRun)",
|
|
11
|
-
version: "1.0.
|
|
11
|
+
version: "1.0.1",
|
|
12
12
|
type: "action",
|
|
13
13
|
props: {
|
|
14
14
|
openai,
|
|
@@ -33,6 +33,12 @@ export default {
|
|
|
33
33
|
description: "The image to process. Provide either a file URL or a path to a file in the `/tmp` directory (for example, `/tmp/myFile.jpg`). Supported image types: jpeg, jpg, png, gif, webp",
|
|
34
34
|
optional: true,
|
|
35
35
|
},
|
|
36
|
+
syncDir: {
|
|
37
|
+
type: "dir",
|
|
38
|
+
accessMode: "read",
|
|
39
|
+
sync: true,
|
|
40
|
+
optional: true,
|
|
41
|
+
},
|
|
36
42
|
},
|
|
37
43
|
async run({ $ }) {
|
|
38
44
|
const { id: assistantId } = await this.openai.createAssistant({
|
package/actions/chat/chat.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import constants from "../../common/constants.mjs";
|
|
|
5
5
|
export default {
|
|
6
6
|
...common,
|
|
7
7
|
name: "Chat",
|
|
8
|
-
version: "0.3.
|
|
8
|
+
version: "0.3.2",
|
|
9
9
|
key: "openai-chat",
|
|
10
10
|
description: "The Chat API, using the `gpt-3.5-turbo` or `gpt-4` model. [See the documentation](https://platform.openai.com/docs/api-reference/chat)",
|
|
11
11
|
type: "action",
|
|
@@ -5,7 +5,7 @@ import constants from "../../common/constants.mjs";
|
|
|
5
5
|
export default {
|
|
6
6
|
...common,
|
|
7
7
|
name: "Chat using File Search",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.6",
|
|
9
9
|
key: "openai-chat-using-file-search",
|
|
10
10
|
description: "Chat with your files knowledge base (vector stores). [See the documentation](https://platform.openai.com/docs/guides/tools-file-search)",
|
|
11
11
|
type: "action",
|
|
@@ -5,7 +5,7 @@ import constants from "../../common/constants.mjs";
|
|
|
5
5
|
export default {
|
|
6
6
|
...common,
|
|
7
7
|
name: "Chat using Functions",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.7",
|
|
9
9
|
key: "openai-chat-using-functions",
|
|
10
10
|
description: "Chat with your models and allow them to invoke functions. Optionally, you can build and invoke workflows as functions. [See the documentation](https://platform.openai.com/docs/guides/function-calling)",
|
|
11
11
|
type: "action",
|
|
@@ -5,7 +5,7 @@ import constants from "../../common/constants.mjs";
|
|
|
5
5
|
export default {
|
|
6
6
|
...common,
|
|
7
7
|
name: "Chat using Web Search",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.6",
|
|
9
9
|
key: "openai-chat-using-web-search",
|
|
10
10
|
description: "Chat using the web search tool. [See the documentation](https://platform.openai.com/docs/guides/tools-web-search)",
|
|
11
11
|
type: "action",
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import openai from "../../openai.app.mjs";
|
|
2
|
+
import common from "../common/common.mjs";
|
|
3
|
+
import constants from "../../common/constants.mjs";
|
|
4
|
+
import {
|
|
5
|
+
parseArray,
|
|
6
|
+
parseJson,
|
|
7
|
+
} from "../../common/helpers.mjs";
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
...common,
|
|
11
|
+
key: "openai-chat-with-responses-api",
|
|
12
|
+
name: "Chat With Responses API",
|
|
13
|
+
version: "0.0.1",
|
|
14
|
+
description: "Send a chat via the Responses API, mixing built-in tools and MCP server tools. [See the documentation](https://platform.openai.com/docs/guides/tools?api-mode=responses).",
|
|
15
|
+
type: "action",
|
|
16
|
+
props: {
|
|
17
|
+
openai,
|
|
18
|
+
modelId: {
|
|
19
|
+
description: "Model used to generate the response",
|
|
20
|
+
propDefinition: [
|
|
21
|
+
openai,
|
|
22
|
+
"chatCompletionModelId",
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
input: {
|
|
26
|
+
description: "Text input to the model used to generate a response",
|
|
27
|
+
propDefinition: [
|
|
28
|
+
openai,
|
|
29
|
+
"input",
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
instructions: {
|
|
33
|
+
description: "Inserts a system (or developer) message as the first item in the model's context",
|
|
34
|
+
propDefinition: [
|
|
35
|
+
openai,
|
|
36
|
+
"instructions",
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
previousResponseId: {
|
|
40
|
+
type: "string",
|
|
41
|
+
label: "Previous Response ID",
|
|
42
|
+
description: "The unique ID of the previous response to the model. Use this to create multi-turn conversations",
|
|
43
|
+
optional: true,
|
|
44
|
+
},
|
|
45
|
+
truncation: {
|
|
46
|
+
type: "string",
|
|
47
|
+
label: "Truncation",
|
|
48
|
+
description:
|
|
49
|
+
"Specifies the truncation mode for the response if it exceeds the context window",
|
|
50
|
+
default: "auto",
|
|
51
|
+
options: [
|
|
52
|
+
"auto",
|
|
53
|
+
"disabled",
|
|
54
|
+
],
|
|
55
|
+
optional: true,
|
|
56
|
+
},
|
|
57
|
+
responseFormat: {
|
|
58
|
+
type: "string",
|
|
59
|
+
label: "Response Format",
|
|
60
|
+
description: "- `text`: Returns unstructured text output.\n- `json_schema`: Enforces a specific structure using a JSON schema.",
|
|
61
|
+
options: [
|
|
62
|
+
"text",
|
|
63
|
+
"json_schema",
|
|
64
|
+
],
|
|
65
|
+
default: "text",
|
|
66
|
+
optional: true,
|
|
67
|
+
reloadProps: true,
|
|
68
|
+
},
|
|
69
|
+
builtInTools: {
|
|
70
|
+
type: "string[]",
|
|
71
|
+
label: "Built-In Tools",
|
|
72
|
+
description: "Which of OpenAI's first-party tools to enable (web search, file search, code interpreter).",
|
|
73
|
+
options: [
|
|
74
|
+
{
|
|
75
|
+
label: "Web Search",
|
|
76
|
+
value: "web_search_preview",
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
label: "File Search",
|
|
80
|
+
value: "file_search",
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
label: "Code Interpreter",
|
|
84
|
+
value: "code_interpreter",
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
default: [],
|
|
88
|
+
},
|
|
89
|
+
otherTools: {
|
|
90
|
+
type: "string[]",
|
|
91
|
+
label: "Other Tools",
|
|
92
|
+
description: "Other tools to include in the chat. [See the documentation](https://platform.openai.com/docs/guides/tools-remote-mcp). Example: `{ type: \"mcp\", server_label: \"gmail\", server_url: \"https://remote.mcp.pipedream.net\", headers: {}, require_approval: \"never\" }`",
|
|
93
|
+
optional: true,
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
additionalProps() {
|
|
97
|
+
if (this.responseFormat === constants.CHAT_RESPONSE_FORMAT.JSON_SCHEMA.value) {
|
|
98
|
+
return {
|
|
99
|
+
schemaName: {
|
|
100
|
+
type: "string",
|
|
101
|
+
label: "Name",
|
|
102
|
+
description: "The name of the schema.",
|
|
103
|
+
},
|
|
104
|
+
schema: {
|
|
105
|
+
type: "string",
|
|
106
|
+
label: "JSON Schema",
|
|
107
|
+
description: "Define the schema that the model's output must adhere to. Only supported models are `gpt-4o-mini`, `gpt-4o-mini-2024-07-18`, `gpt-4o-2024-08-06` and later.",
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
return {};
|
|
112
|
+
},
|
|
113
|
+
async run({ $ }) {
|
|
114
|
+
const {
|
|
115
|
+
builtInTools,
|
|
116
|
+
otherTools,
|
|
117
|
+
modelId,
|
|
118
|
+
input,
|
|
119
|
+
instructions,
|
|
120
|
+
previousResponseId,
|
|
121
|
+
truncation,
|
|
122
|
+
responseFormat,
|
|
123
|
+
schemaName,
|
|
124
|
+
schema,
|
|
125
|
+
} = this;
|
|
126
|
+
|
|
127
|
+
const tools = builtInTools.map((tool) => ({
|
|
128
|
+
type: tool,
|
|
129
|
+
}));
|
|
130
|
+
|
|
131
|
+
if (otherTools) {
|
|
132
|
+
tools.push(...parseArray(otherTools));
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const data = {
|
|
136
|
+
model: modelId,
|
|
137
|
+
input,
|
|
138
|
+
instructions,
|
|
139
|
+
previous_response_id: previousResponseId,
|
|
140
|
+
truncation,
|
|
141
|
+
tools,
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
if (responseFormat === constants.CHAT_RESPONSE_FORMAT.JSON_SCHEMA.value) {
|
|
145
|
+
try {
|
|
146
|
+
data.text = {
|
|
147
|
+
format: {
|
|
148
|
+
type: responseFormat,
|
|
149
|
+
name: schemaName,
|
|
150
|
+
schema: parseJson(schema),
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
} catch {
|
|
154
|
+
throw new Error("Invalid JSON format in the provided JSON Schema");
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const response = await this.openai.responses({
|
|
159
|
+
$,
|
|
160
|
+
data,
|
|
161
|
+
debug: true,
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
if (response) {
|
|
165
|
+
$.export("$summary", `Successfully sent chat to OpenAI Responses API with ID \`${response.id}\`.`);
|
|
166
|
+
$.export("chat_responses", response.output);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return response;
|
|
170
|
+
},
|
|
171
|
+
};
|
|
@@ -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.1.
|
|
6
|
+
version: "0.1.8",
|
|
7
7
|
key: "openai-classify-items-into-categories",
|
|
8
8
|
description: "Classify items into specific categories using the Chat API. [See the documentation](https://platform.openai.com/docs/api-reference/chat)",
|
|
9
9
|
type: "action",
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
key: "openai-convert-text-to-speech",
|
|
6
6
|
name: "Convert Text to 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.
|
|
8
|
+
version: "0.0.15",
|
|
9
9
|
type: "action",
|
|
10
10
|
props: {
|
|
11
11
|
openai,
|
|
@@ -42,7 +42,12 @@ export default {
|
|
|
42
42
|
outputFile: {
|
|
43
43
|
type: "string",
|
|
44
44
|
label: "Output Filename",
|
|
45
|
-
description: "The filename of the output audio file that will be written to the `/tmp` folder, e.g.
|
|
45
|
+
description: "The filename of the output audio file that will be written to the `/tmp` folder, e.g. `myFile.mp3`",
|
|
46
|
+
},
|
|
47
|
+
syncDir: {
|
|
48
|
+
type: "dir",
|
|
49
|
+
accessMode: "write",
|
|
50
|
+
sync: true,
|
|
46
51
|
},
|
|
47
52
|
},
|
|
48
53
|
async run({ $ }) {
|
|
@@ -60,7 +65,7 @@ export default {
|
|
|
60
65
|
|
|
61
66
|
const outputFilePath = this.outputFile.includes("tmp/")
|
|
62
67
|
? this.outputFile
|
|
63
|
-
:
|
|
68
|
+
: `${process.env.STASH_DIR || "/tmp"}/${this.outputFile}`;
|
|
64
69
|
|
|
65
70
|
await fs.promises.writeFile(outputFilePath, Buffer.from(response));
|
|
66
71
|
|
|
@@ -9,7 +9,7 @@ export default {
|
|
|
9
9
|
key: "openai-create-batch",
|
|
10
10
|
name: "Create Batch",
|
|
11
11
|
description: "Creates and executes a batch from an uploaded file of requests. [See the documentation](https://platform.openai.com/docs/api-reference/batch/create)",
|
|
12
|
-
version: "0.1.
|
|
12
|
+
version: "0.1.1",
|
|
13
13
|
type: "action",
|
|
14
14
|
props: {
|
|
15
15
|
openai,
|
|
@@ -41,6 +41,12 @@ export default {
|
|
|
41
41
|
"metadata",
|
|
42
42
|
],
|
|
43
43
|
},
|
|
44
|
+
syncDir: {
|
|
45
|
+
type: "dir",
|
|
46
|
+
accessMode: "read",
|
|
47
|
+
sync: true,
|
|
48
|
+
optional: true,
|
|
49
|
+
},
|
|
44
50
|
},
|
|
45
51
|
async run({ $ }) {
|
|
46
52
|
if (!this.fileId && !this.filePath) {
|
|
@@ -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.
|
|
7
|
+
version: "0.0.20",
|
|
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 documentation](https://platform.openai.com/docs/api-reference/embeddings)",
|
|
10
10
|
type: "action",
|
|
@@ -4,7 +4,7 @@ import fs from "fs";
|
|
|
4
4
|
|
|
5
5
|
export default {
|
|
6
6
|
name: "Create Image (Dall-E)",
|
|
7
|
-
version: "0.1.
|
|
7
|
+
version: "0.1.23",
|
|
8
8
|
key: "openai-create-image",
|
|
9
9
|
description: "Creates an image given a prompt returning a URL to the image. [See the documentation](https://platform.openai.com/docs/api-reference/images)",
|
|
10
10
|
type: "action",
|
|
@@ -39,6 +39,11 @@ export default {
|
|
|
39
39
|
options: constants.IMAGE_SIZES,
|
|
40
40
|
default: "1024x1024",
|
|
41
41
|
},
|
|
42
|
+
syncDir: {
|
|
43
|
+
type: "dir",
|
|
44
|
+
accessMode: "write",
|
|
45
|
+
sync: true,
|
|
46
|
+
},
|
|
42
47
|
},
|
|
43
48
|
async additionalProps() {
|
|
44
49
|
const props = {};
|
|
@@ -106,7 +111,7 @@ export default {
|
|
|
106
111
|
: this.filename.replace(/(\.[^/.]+)$/, `_${i}$1`);
|
|
107
112
|
const outputFilePath = filename.includes("tmp/")
|
|
108
113
|
? filename
|
|
109
|
-
:
|
|
114
|
+
: `${process.env.STASH_DIR || "/tmp"}/${filename}`;
|
|
110
115
|
await fs.writeFileSync(outputFilePath, Buffer.from(response.data[0].b64_json.toString(), "base64"));
|
|
111
116
|
fileData.push({
|
|
112
117
|
tmp: [
|
|
@@ -6,7 +6,7 @@ export default {
|
|
|
6
6
|
key: "openai-create-transcription",
|
|
7
7
|
name: "Create Transcription",
|
|
8
8
|
description: "Transcribes audio into the input language. [See the documentation](https://platform.openai.com/docs/api-reference/audio/createTranscription)",
|
|
9
|
-
version: "0.3.
|
|
9
|
+
version: "0.3.1",
|
|
10
10
|
type: "action",
|
|
11
11
|
props: {
|
|
12
12
|
openai,
|
|
@@ -70,6 +70,12 @@ export default {
|
|
|
70
70
|
description: "The timestamp granularities to populate for this transcription. `response_format` must be set `verbose_json` to use timestamp granularities. Either or both of these options are supported: `word`, or `segment`. Note: There is no additional latency for segment timestamps, but generating word timestamps incurs additional latency.",
|
|
71
71
|
optional: true,
|
|
72
72
|
},
|
|
73
|
+
syncDir: {
|
|
74
|
+
type: "dir",
|
|
75
|
+
accessMode: "read",
|
|
76
|
+
sync: true,
|
|
77
|
+
optional: true,
|
|
78
|
+
},
|
|
73
79
|
},
|
|
74
80
|
methods: {
|
|
75
81
|
createTranscription(opts = {}) {
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
key: "openai-retrieve-file-content",
|
|
6
6
|
name: "Retrieve File Content",
|
|
7
7
|
description: "Retrieves the contents of the specified file. [See the documentation](https://platform.openai.com/docs/api-reference/files/retrieve-content)",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.16",
|
|
9
9
|
type: "action",
|
|
10
10
|
props: {
|
|
11
11
|
openai,
|
|
@@ -21,6 +21,11 @@ export default {
|
|
|
21
21
|
description: "Optionally, download the file to the `/tmp` directory using the given filename",
|
|
22
22
|
optional: true,
|
|
23
23
|
},
|
|
24
|
+
syncDir: {
|
|
25
|
+
type: "dir",
|
|
26
|
+
accessMode: "write",
|
|
27
|
+
sync: true,
|
|
28
|
+
},
|
|
24
29
|
},
|
|
25
30
|
async run({ $ }) {
|
|
26
31
|
const response = await this.openai.retrieveFileContent({
|
|
@@ -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.19",
|
|
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 the documentation](https://beta.openai.com/docs/api-reference/completions/create)",
|
|
10
10
|
type: "action",
|
|
@@ -4,7 +4,7 @@ import constants from "../../common/constants.mjs";
|
|
|
4
4
|
export default {
|
|
5
5
|
...common,
|
|
6
6
|
name: "Summarize Text",
|
|
7
|
-
version: "0.1.
|
|
7
|
+
version: "0.1.8",
|
|
8
8
|
key: "openai-summarize",
|
|
9
9
|
description: "Summarizes text using the Chat API. [See the documentation](https://platform.openai.com/docs/api-reference/chat)",
|
|
10
10
|
type: "action",
|
|
@@ -9,7 +9,7 @@ const langOptions = lang.LANGUAGES.map((l) => ({
|
|
|
9
9
|
export default {
|
|
10
10
|
...common,
|
|
11
11
|
name: "Translate Text (Whisper)",
|
|
12
|
-
version: "0.1.
|
|
12
|
+
version: "0.1.8",
|
|
13
13
|
key: "openai-translate-text",
|
|
14
14
|
description: "Translate text from one language to another using the Chat API. [See the documentation](https://platform.openai.com/docs/api-reference/chat)",
|
|
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.1.
|
|
9
|
+
version: "0.1.1",
|
|
10
10
|
type: "action",
|
|
11
11
|
props: {
|
|
12
12
|
openai,
|
|
@@ -22,6 +22,12 @@ export default {
|
|
|
22
22
|
"purpose",
|
|
23
23
|
],
|
|
24
24
|
},
|
|
25
|
+
syncDir: {
|
|
26
|
+
type: "dir",
|
|
27
|
+
accessMode: "read",
|
|
28
|
+
sync: true,
|
|
29
|
+
optional: true,
|
|
30
|
+
},
|
|
25
31
|
},
|
|
26
32
|
async run({ $ }) {
|
|
27
33
|
const {
|
package/common/helpers.mjs
CHANGED
|
@@ -37,3 +37,52 @@ export function parse(value) {
|
|
|
37
37
|
throw new ConfigurationError("Make sure the schema contains a valid JSON object.");
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
+
|
|
41
|
+
export const parseJson = (input, maxDepth = 100) => {
|
|
42
|
+
const seen = new WeakSet();
|
|
43
|
+
const parse = (value) => {
|
|
44
|
+
if (maxDepth <= 0) {
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
if (typeof(value) === "string") {
|
|
48
|
+
// Only parse if the string looks like a JSON object or array
|
|
49
|
+
const trimmed = value.trim();
|
|
50
|
+
if (
|
|
51
|
+
(trimmed.startsWith("{") && trimmed.endsWith("}")) ||
|
|
52
|
+
(trimmed.startsWith("[") && trimmed.endsWith("]"))
|
|
53
|
+
) {
|
|
54
|
+
try {
|
|
55
|
+
return parseJson(JSON.parse(value), maxDepth - 1);
|
|
56
|
+
} catch (e) {
|
|
57
|
+
return value;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return value;
|
|
61
|
+
} else if (typeof(value) === "object" && value !== null && !Array.isArray(value)) {
|
|
62
|
+
if (seen.has(value)) {
|
|
63
|
+
return value;
|
|
64
|
+
}
|
|
65
|
+
seen.add(value);
|
|
66
|
+
return Object.entries(value)
|
|
67
|
+
.reduce((acc, [
|
|
68
|
+
key,
|
|
69
|
+
val,
|
|
70
|
+
]) => Object.assign(acc, {
|
|
71
|
+
[key]: parse(val),
|
|
72
|
+
}), {});
|
|
73
|
+
} else if (Array.isArray(value)) {
|
|
74
|
+
return value.map((item) => parse(item));
|
|
75
|
+
}
|
|
76
|
+
return value;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
return parse(input);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export function parseArray (input, maxDepth = 100) {
|
|
83
|
+
if (!Array.isArray(input)) {
|
|
84
|
+
return input;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return input.map((item) => parseJson(item, maxDepth));
|
|
88
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipedream/openai",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Pipedream OpenAI Components",
|
|
5
5
|
"main": "openai.app.mjs",
|
|
6
6
|
"keywords": [
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@pipedream/platform": "^3.1.0",
|
|
18
18
|
"@pipedream/types": "^0.1.4",
|
|
19
|
-
"axios": "^1.6.2",
|
|
20
19
|
"bottleneck": "^2.19.5",
|
|
21
20
|
"form-data": "^4.0.0",
|
|
22
21
|
"got": "^12.6.0",
|