@pipedream/openai 0.8.1 → 0.9.1

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 (45) hide show
  1. package/actions/analyze-image-content/analyze-image-content.mjs +1 -1
  2. package/actions/cancel-run/cancel-run.mjs +1 -1
  3. package/actions/chat/chat.mjs +6 -1
  4. package/actions/chat-using-file-search/chat-using-file-search.mjs +229 -0
  5. package/actions/chat-using-functions/chat-using-functions.mjs +255 -0
  6. package/actions/chat-using-web-search/chat-using-web-search.mjs +200 -0
  7. package/actions/chat-with-assistant/chat-with-assistant.mjs +6 -1
  8. package/actions/classify-items-into-categories/classify-items-into-categories.mjs +1 -1
  9. package/actions/convert-text-to-speech/convert-text-to-speech.mjs +1 -1
  10. package/actions/create-assistant/create-assistant.mjs +1 -1
  11. package/actions/create-batch/create-batch.mjs +1 -1
  12. package/actions/create-embeddings/create-embeddings.mjs +1 -1
  13. package/actions/create-fine-tuning-job/create-fine-tuning-job.mjs +1 -1
  14. package/actions/create-image/create-image.mjs +1 -1
  15. package/actions/create-moderation/create-moderation.mjs +1 -1
  16. package/actions/create-thread/create-thread.mjs +1 -1
  17. package/actions/create-vector-store/create-vector-store.mjs +1 -1
  18. package/actions/create-vector-store-file/create-vector-store-file.mjs +1 -1
  19. package/actions/delete-file/delete-file.mjs +1 -1
  20. package/actions/delete-vector-store/delete-vector-store.mjs +1 -1
  21. package/actions/delete-vector-store-file/delete-vector-store-file.mjs +1 -1
  22. package/actions/list-files/list-files.mjs +1 -1
  23. package/actions/list-messages/list-messages.mjs +1 -1
  24. package/actions/list-run-steps/list-run-steps.mjs +1 -1
  25. package/actions/list-runs/list-runs.mjs +1 -1
  26. package/actions/list-vector-store-files/list-vector-store-files.mjs +1 -1
  27. package/actions/list-vector-stores/list-vector-stores.mjs +1 -1
  28. package/actions/modify-assistant/modify-assistant.mjs +1 -1
  29. package/actions/retrieve-file/retrieve-file.mjs +1 -1
  30. package/actions/retrieve-file-content/retrieve-file-content.mjs +1 -1
  31. package/actions/retrieve-run/retrieve-run.mjs +1 -1
  32. package/actions/retrieve-run-step/retrieve-run-step.mjs +1 -1
  33. package/actions/retrieve-vector-store/retrieve-vector-store.mjs +1 -1
  34. package/actions/retrieve-vector-store-file/retrieve-vector-store-file.mjs +1 -1
  35. package/actions/send-prompt/send-prompt.mjs +1 -1
  36. package/actions/submit-tool-outputs-to-run/submit-tool-outputs-to-run.mjs +1 -1
  37. package/actions/summarize/summarize.mjs +1 -1
  38. package/actions/translate-text/translate-text.mjs +1 -1
  39. package/actions/upload-file/upload-file.mjs +1 -1
  40. package/openai.app.mjs +10 -0
  41. package/package.json +1 -1
  42. package/sources/new-batch-completed/new-batch-completed.mjs +1 -1
  43. package/sources/new-file-created/new-file-created.mjs +1 -1
  44. package/sources/new-fine-tuning-job-created/new-fine-tuning-job-created.mjs +1 -1
  45. package/sources/new-run-state-changed/new-run-state-changed.mjs +1 -1
@@ -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: "0.1.4",
11
+ version: "0.1.5",
12
12
  type: "action",
13
13
  props: {
14
14
  openai,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "openai-cancel-run",
5
5
  name: "Cancel Run (Assistants)",
6
6
  description: "Cancels a run that is in progress. [See the documentation](https://platform.openai.com/docs/api-reference/runs/cancelRun)",
7
- version: "0.0.13",
7
+ version: "0.0.14",
8
8
  type: "action",
9
9
  props: {
10
10
  openai,
@@ -6,12 +6,17 @@ import { ConfigurationError } from "@pipedream/platform";
6
6
  export default {
7
7
  ...common,
8
8
  name: "Chat",
9
- version: "0.2.5",
9
+ version: "0.2.6",
10
10
  key: "openai-chat",
11
11
  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)",
12
12
  type: "action",
13
13
  props: {
14
14
  openai,
15
+ alert: {
16
+ type: "alert",
17
+ alertType: "info",
18
+ content: "Looking to chat with your tools? Check out our individual actions: [Chat using Web Search](https://pipedream.com/apps/openai/actions/chat-using-web-search), [Chat using File Search](https://pipedream.com/apps/openai/actions/chat-using-file-search), and [Chat using Functions](https://pipedream.com/apps/openai/actions/chat-using-functions).",
19
+ },
15
20
  modelId: {
16
21
  propDefinition: [
17
22
  openai,
@@ -0,0 +1,229 @@
1
+ import openai from "../../openai.app.mjs";
2
+ import common from "../common/common.mjs";
3
+ import constants from "../../common/constants.mjs";
4
+
5
+ export default {
6
+ ...common,
7
+ name: "Chat using File Search",
8
+ version: "0.0.2",
9
+ key: "openai-chat-using-file-search",
10
+ description: "Chat with your files knowledge base (vector stores). [See the documentation](https://platform.openai.com/docs/guides/tools-file-search)",
11
+ type: "action",
12
+ props: {
13
+ openai,
14
+ alert: {
15
+ type: "alert",
16
+ alertType: "info",
17
+ content: "To use this action, you need to have set up a knowledge base in a vector store and uploaded files to it. [More infomation here](https://platform.openai.com/docs/guides/tools-file-search?lang=javascript#overview).",
18
+ },
19
+ modelId: {
20
+ propDefinition: [
21
+ openai,
22
+ "chatCompletionModelId",
23
+ ],
24
+ },
25
+ vectorStoreId: {
26
+ propDefinition: [
27
+ openai,
28
+ "vectorStoreId",
29
+ ],
30
+ description: "The identifier of a vector store. Currently supports only one vector store at a time",
31
+ },
32
+ input: {
33
+ type: "string",
34
+ label: "Chat Input",
35
+ description: "Text inputs to the model used to generate a response",
36
+ },
37
+ instructions: {
38
+ type: "string",
39
+ label: "Instructions",
40
+ description: "Inserts a system (or developer) message as the first item in the model's context",
41
+ optional: true,
42
+ },
43
+ includeSearchResults: {
44
+ type: "boolean",
45
+ label: "Include Search Results",
46
+ description: "Include the search results in the response",
47
+ default: false,
48
+ optional: true,
49
+ },
50
+ maxNumResults: {
51
+ type: "integer",
52
+ label: "Max Number of Results",
53
+ description: "Customize the number of results you want to retrieve from the vector store",
54
+ optional: true,
55
+ },
56
+ metadataFiltering: {
57
+ type: "boolean",
58
+ label: "Metadata Filtering",
59
+ description: "Configure how the search results are filtered based on file metadata",
60
+ optional: true,
61
+ reloadProps: true,
62
+ },
63
+ previousResponseId: {
64
+ type: "string",
65
+ label: "Previous Response ID",
66
+ description: "The unique ID of the previous response to the model. Use this to create multi-turn conversations",
67
+ optional: true,
68
+ },
69
+ truncation: {
70
+ type: "string",
71
+ label: "Truncation",
72
+ description: "Specifies the truncation mode for the response if it's larger than the context window size",
73
+ optional: true,
74
+ default: "auto",
75
+ options: [
76
+ "auto",
77
+ "disabled",
78
+ ],
79
+ },
80
+ responseFormat: {
81
+ type: "string",
82
+ label: "Response Format",
83
+ description: "Specify the format that the model must output. \n- **Text**: Returns unstructured text output.\n- **JSON Schema**: Enables you to define a [specific structure for the model's output using a JSON schema](https://platform.openai.com/docs/guides/structured-outputs?api-mode=responses).",
84
+ options: [
85
+ "text",
86
+ "json_schema",
87
+ ],
88
+ default: "text",
89
+ optional: true,
90
+ reloadProps: true,
91
+ },
92
+ skipThisStep: {
93
+ type: "boolean",
94
+ label: "Skip This Step",
95
+ description: "Pass in a boolean custom expression to skip this step's execution at runtime",
96
+ optional: true,
97
+ default: false,
98
+ },
99
+ },
100
+ additionalProps() {
101
+ const {
102
+ modelId,
103
+ metadataFiltering,
104
+ responseFormat,
105
+ } = this;
106
+ const props = {};
107
+
108
+ if (this.openai.isReasoningModel(modelId)) {
109
+ props.reasoningEffort = {
110
+ type: "string",
111
+ label: "Reasoning Effort",
112
+ description: "Constrains effort on reasoning for reasoning models",
113
+ optional: true,
114
+ options: [
115
+ "low",
116
+ "medium",
117
+ "high",
118
+ ],
119
+ };
120
+
121
+ // aparrently not supported yet as of 12/march/2025
122
+ // props.generateSummary = {
123
+ // type: "string",
124
+ // label: "Generate Reasoning Summary",
125
+ // description: "A summary of the reasoning performed by the model",
126
+ // optional: true,
127
+ // options: [
128
+ // "concise",
129
+ // "detailed",
130
+ // ],
131
+ // };
132
+ }
133
+
134
+ // TODO: make this configuration user-friendly
135
+ // https://platform.openai.com/docs/guides/retrieval?attributes-filter-example=region#attribute-filtering
136
+ if (metadataFiltering) {
137
+ props.filters = {
138
+ type: "object",
139
+ label: "Filters",
140
+ description: "Filter the search results based on file metadata. [See the documentation here](https://platform.openai.com/docs/guides/retrieval#attribute-filtering)",
141
+ };
142
+ }
143
+
144
+ if (responseFormat === constants.CHAT_RESPONSE_FORMAT.JSON_SCHEMA.value) {
145
+ props.jsonSchema = {
146
+ type: "string",
147
+ label: "JSON Schema",
148
+ description: "Define the schema that the model's output must adhere to. [Generate one here](https://platform.openai.com/docs/guides/structured-outputs/supported-schemas).",
149
+ };
150
+ }
151
+
152
+ return props;
153
+ },
154
+ methods: {
155
+ ...common.methods,
156
+ },
157
+ async run({ $ }) {
158
+ if (this.skipThisStep) {
159
+ $.export("$summary", "Step execution skipped");
160
+ return;
161
+ }
162
+
163
+ const data = {
164
+ model: this.modelId,
165
+ input: this.input,
166
+ instructions: this.instructions,
167
+ previous_response_id: this.previousResponseId,
168
+ truncation: this.truncation,
169
+ tools: [
170
+ {
171
+ type: "file_search",
172
+ vector_store_ids: [
173
+ this.vectorStoreId,
174
+ ],
175
+ max_num_results: this.maxNumResults,
176
+ },
177
+ ],
178
+ };
179
+
180
+ if (this.includeSearchResults) {
181
+ data.include = [
182
+ "output[*].file_search_call.search_results",
183
+ ];
184
+ }
185
+
186
+ if (this.filters) {
187
+ data.tools[0].filters = this.filters;
188
+ }
189
+
190
+ if (this.openai.isReasoningModel(this.modelId) && this.reasoningEffort) {
191
+ data.reasoning = {
192
+ ...data.reasoning,
193
+ effort: this.reasoningEffort,
194
+ };
195
+ }
196
+
197
+ if (this.openai.isReasoningModel(this.modelId) && this.generateSummary) {
198
+ data.reasoning = {
199
+ ...data.reasoning,
200
+ generate_summary: this.generateSummary,
201
+ };
202
+ }
203
+
204
+ if (this.responseFormat === constants.CHAT_RESPONSE_FORMAT.JSON_SCHEMA.value) {
205
+ try {
206
+ data.text = {
207
+ format: {
208
+ type: this.responseFormat,
209
+ ...JSON.parse(this.jsonSchema),
210
+ },
211
+ };
212
+ } catch (error) {
213
+ throw new Error("Invalid JSON format in the provided JSON Schema");
214
+ }
215
+ }
216
+
217
+ const response = await this.openai.responses({
218
+ $,
219
+ data,
220
+ });
221
+
222
+ if (response) {
223
+ $.export("$summary", `Successfully sent chat with id ${response.id}`);
224
+ $.export("chat_responses", response.output);
225
+ }
226
+
227
+ return response;
228
+ },
229
+ };
@@ -0,0 +1,255 @@
1
+ import openai from "../../openai.app.mjs";
2
+ import common from "../common/common.mjs";
3
+ import constants from "../../common/constants.mjs";
4
+
5
+ export default {
6
+ ...common,
7
+ name: "Chat using Functions",
8
+ version: "0.0.2",
9
+ key: "openai-chat-using-functions",
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
+ type: "action",
12
+ props: {
13
+ openai,
14
+ alert: {
15
+ type: "alert",
16
+ alertType: "info",
17
+ content: "Provide function names and parameters, and the model will either answer the question directly or decide to invoke one of the functions, returning a function call that adheres to your specified schema. Add a custom code step that includes all available functions which can be invoked based on the model's response - [you can even build an entire workflow as a function](https://pipedream.com/docs/workflows/building-workflows/code/nodejs/#invoke-another-workflow)! Once the appropriate function or workflow is executed, continue the overall execution or pass the result back to the model for further analysis. For more details, [see this guide](https://platform.openai.com/docs/guides/function-calling?api-mode=responses#overview).",
18
+ },
19
+ modelId: {
20
+ propDefinition: [
21
+ openai,
22
+ "chatCompletionModelId",
23
+ ],
24
+ },
25
+ input: {
26
+ type: "string",
27
+ label: "Chat Input",
28
+ description: "Text inputs to the model used to generate a response",
29
+ },
30
+ functions: {
31
+ type: "string",
32
+ label: "Functions",
33
+ description: "A valid JSON array of functions using OpenAI's function schema definition. [See guide here](https://platform.openai.com/docs/guides/function-calling?api-mode=responses&example=search-knowledge-base#defining-functions).",
34
+ default:
35
+ `[
36
+ {
37
+ "type": "function",
38
+ "name": "your_function_name",
39
+ "description": "Details on when and how to use the function",
40
+ "strict": true,
41
+ "parameters": {
42
+ "type": "object",
43
+ "properties": {
44
+ "property_name": {
45
+ "type": "property_type",
46
+ "description": "A description for this property"
47
+ },
48
+ "another_property_name": {
49
+ "type": "property_type",
50
+ "description": "A description for this property"
51
+ }
52
+ },
53
+ "required": [
54
+ "list",
55
+ "of",
56
+ "required",
57
+ "properties",
58
+ "for",
59
+ "this",
60
+ "object"
61
+ ],
62
+ "additionalProperties": false
63
+ }
64
+ }
65
+ ]`,
66
+ },
67
+ instructions: {
68
+ type: "string",
69
+ label: "Instructions",
70
+ description: "Inserts a system (or developer) message as the first item in the model's context",
71
+ optional: true,
72
+ },
73
+ toolChoice: {
74
+ type: "string",
75
+ label: "Tool Choice",
76
+ description: "- **auto**: The model decides whether and how many functions to call.\n- **required**: The model must call one or more functions.\n- **function_name**: Enter a custom expression to force the model to call this specific function.",
77
+ optional: true,
78
+ default: "auto",
79
+ options: [
80
+ "auto",
81
+ "required",
82
+ ],
83
+ },
84
+ parallelToolCalls: {
85
+ type: "boolean",
86
+ label: "Parallel Function Calling",
87
+ description: "Allow or prevent the model to call multiple functions in a single turn",
88
+ optional: true,
89
+ default: true,
90
+ },
91
+ previousResponseId: {
92
+ type: "string",
93
+ label: "Previous Response ID",
94
+ description: "The unique ID of the previous response to the model. Use this to create multi-turn conversations",
95
+ optional: true,
96
+ },
97
+ truncation: {
98
+ type: "string",
99
+ label: "Truncation",
100
+ description: "Specifies the truncation mode for the response if it's larger than the context window size",
101
+ optional: true,
102
+ default: "auto",
103
+ options: [
104
+ "auto",
105
+ "disabled",
106
+ ],
107
+ },
108
+ responseFormat: {
109
+ type: "string",
110
+ label: "Response Format",
111
+ description: "Specify the format that the model must output. \n- **Text**: Returns unstructured text output.\n- **JSON Schema**: Enables you to define a [specific structure for the model's output using a JSON schema](https://platform.openai.com/docs/guides/structured-outputs?api-mode=responses).",
112
+ options: [
113
+ "text",
114
+ "json_schema",
115
+ ],
116
+ default: "text",
117
+ optional: true,
118
+ reloadProps: true,
119
+ },
120
+ skipThisStep: {
121
+ type: "boolean",
122
+ label: "Skip This Step",
123
+ description: "Pass in a boolean custom expression to skip this step's execution at runtime",
124
+ optional: true,
125
+ default: false,
126
+ },
127
+ },
128
+ additionalProps() {
129
+ const {
130
+ modelId,
131
+ responseFormat,
132
+ } = this;
133
+ const props = {};
134
+
135
+ if (this.openai.isReasoningModel(modelId)) {
136
+ props.reasoningEffort = {
137
+ type: "string",
138
+ label: "Reasoning Effort",
139
+ description: "Constrains effort on reasoning for reasoning models",
140
+ optional: true,
141
+ options: [
142
+ "low",
143
+ "medium",
144
+ "high",
145
+ ],
146
+ };
147
+
148
+ // aparrently not supported yet as of 12/march/2025
149
+ // props.generateSummary = {
150
+ // type: "string",
151
+ // label: "Generate Reasoning Summary",
152
+ // description: "A summary of the reasoning performed by the model",
153
+ // optional: true,
154
+ // options: [
155
+ // "concise",
156
+ // "detailed",
157
+ // ],
158
+ // };
159
+ }
160
+
161
+ if (responseFormat === constants.CHAT_RESPONSE_FORMAT.JSON_SCHEMA.value) {
162
+ props.jsonSchema = {
163
+ type: "string",
164
+ label: "JSON Schema",
165
+ description: "Define the schema that the model's output must adhere to. [Generate one here](https://platform.openai.com/docs/guides/structured-outputs/supported-schemas).",
166
+ };
167
+ }
168
+
169
+ return props;
170
+ },
171
+ methods: {
172
+ ...common.methods,
173
+ },
174
+ async run({ $ }) {
175
+ if (this.skipThisStep) {
176
+ $.export("$summary", "Step execution skipped");
177
+ return;
178
+ }
179
+
180
+ const data = {
181
+ model: this.modelId,
182
+ input: this.input,
183
+ instructions: this.instructions,
184
+ previous_response_id: this.previousResponseId,
185
+ truncation: this.truncation,
186
+ parallel_tool_calls: this.parallelToolCalls,
187
+ tools: [],
188
+ };
189
+
190
+ let functions = this.functions;
191
+ if (typeof functions === "string") {
192
+ try {
193
+ functions = JSON.parse(functions);
194
+ } catch (error) {
195
+ throw new Error("Invalid JSON format in the provided Functions Schema");
196
+ }
197
+ }
198
+
199
+ if (Array.isArray(functions)) {
200
+ data.tools.push(...functions);
201
+ } else {
202
+ data.tools.push(functions);
203
+ }
204
+
205
+ if (this.toolChoice) {
206
+ if (this.toolChoice === "auto" || this.toolChoice === "required") {
207
+ data.tool_choice = this.toolChoice;
208
+ } else {
209
+ data.tool_choice = {
210
+ type: "function",
211
+ name: this.toolChoice,
212
+ };
213
+ }
214
+ }
215
+
216
+ if (this.openai.isReasoningModel(this.modelId) && this.reasoningEffort) {
217
+ data.reasoning = {
218
+ ...data.reasoning,
219
+ effort: this.reasoningEffort,
220
+ };
221
+ }
222
+
223
+ if (this.openai.isReasoningModel(this.modelId) && this.generateSummary) {
224
+ data.reasoning = {
225
+ ...data.reasoning,
226
+ generate_summary: this.generateSummary,
227
+ };
228
+ }
229
+
230
+ if (this.responseFormat === constants.CHAT_RESPONSE_FORMAT.JSON_SCHEMA.value) {
231
+ try {
232
+ data.text = {
233
+ format: {
234
+ type: this.responseFormat,
235
+ ...JSON.parse(this.jsonSchema),
236
+ },
237
+ };
238
+ } catch (error) {
239
+ throw new Error("Invalid JSON format in the provided JSON Schema");
240
+ }
241
+ }
242
+
243
+ const response = await this.openai.responses({
244
+ $,
245
+ data,
246
+ });
247
+
248
+ if (response) {
249
+ $.export("$summary", `Successfully sent chat with id ${response.id}`);
250
+ $.export("chat_responses", response.output);
251
+ }
252
+
253
+ return response;
254
+ },
255
+ };
@@ -0,0 +1,200 @@
1
+ import openai from "../../openai.app.mjs";
2
+ import common from "../common/common.mjs";
3
+ import constants from "../../common/constants.mjs";
4
+
5
+ export default {
6
+ ...common,
7
+ name: "Chat using Web Search",
8
+ version: "0.0.2",
9
+ key: "openai-chat-using-web-search",
10
+ description: "Chat using the web search tool. [See the documentation](https://platform.openai.com/docs/guides/tools-web-search)",
11
+ type: "action",
12
+ props: {
13
+ openai,
14
+ modelId: {
15
+ type: "string",
16
+ label: "Model",
17
+ description: "Model used to generate the response",
18
+ default: "gpt-4o",
19
+ options: [
20
+ "gpt-4o",
21
+ "gpt-4o-mini",
22
+ ],
23
+ },
24
+ input: {
25
+ type: "string",
26
+ label: "Chat Input",
27
+ description: "Text inputs to the model used to generate a response",
28
+ },
29
+ instructions: {
30
+ type: "string",
31
+ label: "Instructions",
32
+ description: "Inserts a system (or developer) message as the first item in the model's context",
33
+ optional: true,
34
+ },
35
+ previousResponseId: {
36
+ type: "string",
37
+ label: "Previous Response ID",
38
+ description: "The unique ID of the previous response to the model. Use this to create multi-turn conversations",
39
+ optional: true,
40
+ },
41
+ truncation: {
42
+ type: "string",
43
+ label: "Truncation",
44
+ description: "Specifies the truncation mode for the response if it's larger than the context window size",
45
+ optional: true,
46
+ default: "auto",
47
+ options: [
48
+ "auto",
49
+ "disabled",
50
+ ],
51
+ },
52
+ userLocation: {
53
+ type: "string[]",
54
+ label: "User Location",
55
+ description: "Additional configuration for approximate location parameters for the search",
56
+ optional: true,
57
+ options: [
58
+ "City",
59
+ "Region",
60
+ "Country",
61
+ "Timezone",
62
+ ],
63
+ },
64
+ searchContextSize: {
65
+ type: "string",
66
+ label: "Search Context Size",
67
+ description: "Determines the amount of context to use during the web search",
68
+ optional: true,
69
+ default: "medium",
70
+ options: [
71
+ "low",
72
+ "medium",
73
+ "high",
74
+ ],
75
+ },
76
+ responseFormat: {
77
+ type: "string",
78
+ label: "Response Format",
79
+ description: "Specify the format that the model must output. \n- **Text**: Returns unstructured text output.\n- **JSON Schema**: Enables you to define a [specific structure for the model's output using a JSON schema](https://platform.openai.com/docs/guides/structured-outputs?api-mode=responses).",
80
+ options: [
81
+ "text",
82
+ "json_schema",
83
+ ],
84
+ default: "text",
85
+ optional: true,
86
+ reloadProps: true,
87
+ },
88
+ skipThisStep: {
89
+ type: "boolean",
90
+ label: "Skip This Step",
91
+ description: "Pass in a boolean custom expression to skip this step's execution at runtime",
92
+ optional: true,
93
+ default: false,
94
+ },
95
+ },
96
+ additionalProps() {
97
+ const {
98
+ responseFormat,
99
+ userLocation,
100
+ } = this;
101
+ const props = {};
102
+
103
+ if (userLocation?.includes("City")) {
104
+ props.city = {
105
+ type: "string",
106
+ label: "City",
107
+ description: "Free text input for the city of the user, e.g. `San Francisco`",
108
+ };
109
+ }
110
+
111
+ if (userLocation?.includes("Region")) {
112
+ props.region = {
113
+ type: "string",
114
+ label: "Region",
115
+ description: "Free text input for the region of the user, e.g. `California`",
116
+ };
117
+ }
118
+
119
+ if (userLocation?.includes("Country")) {
120
+ props.country = {
121
+ type: "string",
122
+ label: "Country",
123
+ description: "The two-letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1) of the user, e.g. `US`",
124
+ };
125
+ }
126
+
127
+ if (userLocation?.includes("Timezone")) {
128
+ props.timezone = {
129
+ type: "string",
130
+ label: "Timezone",
131
+ description: "The [IANA timezone](https://timeapi.io/documentation/iana-timezones) of the user, e.g. `America/Los_Angeles`",
132
+ };
133
+ }
134
+
135
+ if (responseFormat === constants.CHAT_RESPONSE_FORMAT.JSON_SCHEMA.value) {
136
+ props.jsonSchema = {
137
+ type: "string",
138
+ label: "JSON Schema",
139
+ description: "Define the schema that the model's output must adhere to. [Generate one here](https://platform.openai.com/docs/guides/structured-outputs/supported-schemas).",
140
+ };
141
+ }
142
+
143
+ return props;
144
+ },
145
+ methods: {
146
+ ...common.methods,
147
+ },
148
+ async run({ $ }) {
149
+ if (this.skipThisStep) {
150
+ $.export("$summary", "Step execution skipped");
151
+ return;
152
+ }
153
+
154
+ const data = {
155
+ model: this.modelId,
156
+ input: this.input,
157
+ instructions: this.instructions,
158
+ previous_response_id: this.previousResponseId,
159
+ truncation: this.truncation,
160
+ tools: [
161
+ {
162
+ type: "web_search_preview",
163
+ user_location: {
164
+ type: "approximate",
165
+ city: this.city,
166
+ country: this.country,
167
+ region: this.region,
168
+ timezone: this.timezone,
169
+ },
170
+ search_context_size: this.searchContextSize,
171
+ },
172
+ ],
173
+ };
174
+
175
+ if (this.responseFormat === constants.CHAT_RESPONSE_FORMAT.JSON_SCHEMA.value) {
176
+ try {
177
+ data.text = {
178
+ format: {
179
+ type: this.responseFormat,
180
+ ...JSON.parse(this.jsonSchema),
181
+ },
182
+ };
183
+ } catch (error) {
184
+ throw new Error("Invalid JSON format in the provided JSON Schema");
185
+ }
186
+ }
187
+
188
+ const response = await this.openai.responses({
189
+ $,
190
+ data,
191
+ });
192
+
193
+ if (response) {
194
+ $.export("$summary", `Successfully sent chat with id ${response.id}`);
195
+ $.export("chat_responses", response.output);
196
+ }
197
+
198
+ return response;
199
+ },
200
+ };
@@ -6,10 +6,15 @@ export default {
6
6
  key: "openai-chat-with-assistant",
7
7
  name: "Chat with Assistant",
8
8
  description: "Sends a message and generates a response, storing the message history for a continuous conversation. [See the documentation](https://platform.openai.com/docs/api-reference/runs/createThreadAndRun)",
9
- version: "0.0.9",
9
+ version: "0.0.10",
10
10
  type: "action",
11
11
  props: {
12
12
  openai,
13
+ alert: {
14
+ type: "alert",
15
+ alertType: "info",
16
+ content: "Looking to chat with your tools? Check out our individual actions: [Chat using Web Search](https://pipedream.com/apps/openai/actions/chat-using-web-search), [Chat using File Search](https://pipedream.com/apps/openai/actions/chat-using-file-search), and [Chat using Functions](https://pipedream.com/apps/openai/actions/chat-using-functions).",
17
+ },
13
18
  message: {
14
19
  type: "string",
15
20
  label: "Message",
@@ -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.4",
6
+ version: "0.1.5",
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.12",
8
+ version: "0.0.13",
9
9
  type: "action",
10
10
  props: {
11
11
  openai,
@@ -6,7 +6,7 @@ export default {
6
6
  key: "openai-create-assistant",
7
7
  name: "Create Assistant",
8
8
  description: "Creates an assistant with a model and instructions. [See the documentation](https://platform.openai.com/docs/api-reference/assistants/createAssistant)",
9
- version: "0.1.11",
9
+ version: "0.1.12",
10
10
  type: "action",
11
11
  props: {
12
12
  openai,
@@ -8,7 +8,7 @@ export default {
8
8
  key: "openai-create-batch",
9
9
  name: "Create Batch",
10
10
  description: "Creates and executes a batch from an uploaded file of requests. [See the documentation](https://platform.openai.com/docs/api-reference/batch/create)",
11
- version: "0.0.7",
11
+ version: "0.0.8",
12
12
  type: "action",
13
13
  props: {
14
14
  openai,
@@ -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.16",
7
+ version: "0.0.17",
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 @@ 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.12",
7
+ version: "0.0.13",
8
8
  type: "action",
9
9
  props: {
10
10
  openai,
@@ -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.20",
7
+ version: "0.1.21",
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",
@@ -5,7 +5,7 @@ export default {
5
5
  key: "openai-create-moderation",
6
6
  name: "Create Moderation",
7
7
  description: "Classifies if text is potentially harmful. [See the documentation](https://platform.openai.com/docs/api-reference/moderations/create)",
8
- version: "0.0.7",
8
+ version: "0.0.8",
9
9
  type: "action",
10
10
  props: {
11
11
  openai,
@@ -6,7 +6,7 @@ export default {
6
6
  key: "openai-create-thread",
7
7
  name: "Create Thread (Assistants)",
8
8
  description: "Creates a thread with optional messages and metadata, and optionally runs the thread using the specified assistant. [See the documentation](https://platform.openai.com/docs/api-reference/threads/createThread)",
9
- version: "0.0.13",
9
+ version: "0.0.14",
10
10
  type: "action",
11
11
  props: {
12
12
  openai,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "openai-create-vector-store",
5
5
  name: "Create Vector Store",
6
6
  description: "Create a vector store. [See the documentation](https://platform.openai.com/docs/api-reference/vector-stores/create)",
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-create-vector-store-file",
5
5
  name: "Create Vector Store File",
6
6
  description: "Create a vector store file. [See the documentation](https://platform.openai.com/docs/api-reference/vector-stores-files/createFile)",
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-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.13",
7
+ version: "0.0.14",
8
8
  type: "action",
9
9
  props: {
10
10
  openai,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "openai-delete-vector-store",
5
5
  name: "Delete Vector Store",
6
6
  description: "Delete a vector store. [See the documentation](https://platform.openai.com/docs/api-reference/vector-stores/delete)",
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-delete-vector-store-file",
5
5
  name: "Delete Vector Store File",
6
6
  description: "Deletes a vector store file. [See the documentation](https://platform.openai.com/docs/api-reference/vector-stores-files/deleteFile)",
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-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.13",
7
+ version: "0.0.14",
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 (Assistants)",
6
6
  description: "Lists the messages for a given thread. [See the documentation](https://platform.openai.com/docs/api-reference/messages/listMessages)",
7
- version: "0.0.14",
7
+ version: "0.0.15",
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 (Assistants)",
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.13",
7
+ version: "0.0.14",
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 (Assistants)",
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.14",
7
+ version: "0.0.15",
8
8
  type: "action",
9
9
  props: {
10
10
  openai,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "openai-list-vector-store-files",
5
5
  name: "List Vector Store Files",
6
6
  description: "Returns a list of vector store file. [See the documentation](https://platform.openai.com/docs/api-reference/vector-stores-files/listFiles)",
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-vector-stores",
5
5
  name: "List Vector Stores",
6
6
  description: "Returns a list of vector stores. [See the documentation](https://platform.openai.com/docs/api-reference/vector-stores/list)",
7
- version: "0.0.3",
7
+ version: "0.0.4",
8
8
  type: "action",
9
9
  props: {
10
10
  openai,
@@ -6,7 +6,7 @@ export default {
6
6
  key: "openai-modify-assistant",
7
7
  name: "Modify an Assistant",
8
8
  description: "Modifies an existing OpenAI assistant. [See the documentation](https://platform.openai.com/docs/api-reference/assistants/modifyAssistant)",
9
- version: "0.1.11",
9
+ version: "0.1.12",
10
10
  type: "action",
11
11
  props: {
12
12
  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.13",
7
+ version: "0.0.14",
8
8
  type: "action",
9
9
  props: {
10
10
  openai,
@@ -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.13",
8
+ version: "0.0.14",
9
9
  type: "action",
10
10
  props: {
11
11
  openai,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "openai-retrieve-run",
5
5
  name: "Retrieve Run (Assistants)",
6
6
  description: "Retrieves a specific run within a thread. [See the documentation](https://platform.openai.com/docs/api-reference/runs/getRun)",
7
- version: "0.0.13",
7
+ version: "0.0.14",
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 (Assistants)",
6
6
  description: "Retrieve a specific run step in a thread. [See the documentation](https://platform.openai.com/docs/api-reference/runs/getRunStep)",
7
- version: "0.0.13",
7
+ version: "0.0.14",
8
8
  type: "action",
9
9
  props: {
10
10
  openai,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "openai-retrieve-vector-store",
5
5
  name: "Retrieve Vector Store",
6
6
  description: "Retrieve a vector store. [See the documentation](https://platform.openai.com/docs/api-reference/vector-stores/retrieve)",
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-retrieve-vector-store-file",
5
5
  name: "Retrieve Vector Store File",
6
6
  description: "Retrieve a vector store file. [See the documentation](https://platform.openai.com/docs/api-reference/vector-stores-files/getFile)",
7
- version: "0.0.3",
7
+ version: "0.0.4",
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.15",
7
+ version: "0.1.16",
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",
@@ -5,7 +5,7 @@ export default {
5
5
  key: "openai-submit-tool-outputs-to-run",
6
6
  name: "Submit Tool Outputs to Run (Assistants)",
7
7
  description: "Submits tool outputs to a run that requires action. [See the documentation](https://platform.openai.com/docs/api-reference/runs/submitToolOutputs)",
8
- version: "0.0.13",
8
+ version: "0.0.14",
9
9
  type: "action",
10
10
  props: {
11
11
  openai,
@@ -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.4",
7
+ version: "0.1.5",
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.4",
12
+ version: "0.1.5",
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.0.16",
9
+ version: "0.0.17",
10
10
  type: "action",
11
11
  props: {
12
12
  openai,
package/openai.app.mjs CHANGED
@@ -338,6 +338,9 @@ export default {
338
338
  maxBodyLength: Infinity,
339
339
  });
340
340
  },
341
+ isReasoningModel(model) {
342
+ return model.match(/^o[1-9]/gi)?.length;
343
+ },
341
344
  async models({ $ }) {
342
345
  const { data: models } = await this._makeRequest({
343
346
  $,
@@ -764,6 +767,13 @@ export default {
764
767
  ...args,
765
768
  });
766
769
  },
770
+ responses(args = {}) {
771
+ return this._makeRequest({
772
+ path: "/responses",
773
+ method: "POST",
774
+ ...args,
775
+ });
776
+ },
767
777
  async *paginate({
768
778
  resourceFn,
769
779
  args = {},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/openai",
3
- "version": "0.8.1",
3
+ "version": "0.9.1",
4
4
  "description": "Pipedream OpenAI Components",
5
5
  "main": "openai.app.mjs",
6
6
  "keywords": [
@@ -6,7 +6,7 @@ export default {
6
6
  key: "openai-new-batch-completed",
7
7
  name: "New Batch Completed",
8
8
  description: "Emit new event when a new batch is completed in OpenAI. [See the documentation](https://platform.openai.com/docs/api-reference/batch/list)",
9
- version: "0.0.7",
9
+ version: "0.0.8",
10
10
  type: "source",
11
11
  dedupe: "unique",
12
12
  methods: {
@@ -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.12",
9
+ version: "0.0.13",
10
10
  type: "source",
11
11
  dedupe: "unique",
12
12
  props: {
@@ -6,7 +6,7 @@ export default {
6
6
  key: "openai-new-fine-tuning-job-created",
7
7
  name: "New Fine Tuning Job Created",
8
8
  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)",
9
- version: "0.0.12",
9
+ version: "0.0.13",
10
10
  type: "source",
11
11
  dedupe: "unique",
12
12
  methods: {
@@ -6,7 +6,7 @@ export default {
6
6
  key: "openai-new-run-state-changed",
7
7
  name: "New Run State Changed",
8
8
  description: "Emit new event every time a run changes its status. [See the documentation](https://platform.openai.com/docs/api-reference/runs/listRuns)",
9
- version: "0.0.8",
9
+ version: "0.0.9",
10
10
  type: "source",
11
11
  dedupe: "unique",
12
12
  props: {