From 3f58591704f6dda52d2f47418ec0762c8cc0529c Mon Sep 17 00:00:00 2001 From: Andrew Chuang Date: Tue, 11 Mar 2025 16:11:12 -0300 Subject: [PATCH 01/16] initial chat with tools action --- .../chat-with-tools/chat-with-tools.mjs | 168 ++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 components/openai/actions/chat-with-tools/chat-with-tools.mjs diff --git a/components/openai/actions/chat-with-tools/chat-with-tools.mjs b/components/openai/actions/chat-with-tools/chat-with-tools.mjs new file mode 100644 index 0000000000000..62602ddc333f7 --- /dev/null +++ b/components/openai/actions/chat-with-tools/chat-with-tools.mjs @@ -0,0 +1,168 @@ +import openai from "../../openai.app.mjs"; +import common from "../common/common.mjs"; +import constants from "../../common/constants.mjs"; +import { ConfigurationError } from "@pipedream/platform"; + +export default { + ...common, + name: "Chat with Tools (Responses API)", + version: "0.0.1", + key: "openai-chat-with-tools", + description: "Chat, using the Responses API. [See the documentation](https://platform.openai.com/docs/api-reference/responses)", + type: "action", + props: { + openai, + modelId: { + propDefinition: [ + openai, + "chatCompletionModelId", + ], + }, + userMessage: { + label: "User Message", + type: "string", + description: "The user messages provide instructions to the assistant. They can be generated by the end users of an application, or set by a developer as an instruction.", + }, + ...common.props, + systemInstructions: { + label: "System Instructions", + type: "string", + description: "The system message helps set the behavior of the assistant. For example: \"You are a helpful assistant.\" [See these docs](https://platform.openai.com/docs/guides/chat/instructing-chat-models) for tips on writing good instructions.", + optional: true, + }, + messages: { + label: "Prior Message History", + type: "string[]", + 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.", + optional: true, + }, + images: { + label: "Images", + type: "string[]", + 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", + optional: true, + }, + audio: { + type: "string", + label: "Audio", + description: "Provide the file path to an audio file in the `/tmp` directory. For use with the `gpt-4o-audio-preview` model. Currently supports `wav` and `mp3` files.", + optional: true, + }, + responseFormat: { + type: "string", + label: "Response Format", + description: "Specify the format that the model must output. \n- **Text** (default): Returns unstructured text output.\n- **JSON Object**: Ensures the model's output is a valid JSON object.\n- **JSON Schema** (GPT-4o and later): Enables you to define a specific structure for the model's output using a JSON schema. Supported with models `gpt-4o-2024-08-06` and later, and `gpt-4o-mini-2024-07-18` and later.", + options: Object.values(constants.CHAT_RESPONSE_FORMAT), + default: constants.CHAT_RESPONSE_FORMAT.TEXT.value, + optional: true, + reloadProps: true, + }, + toolTypes: { + type: "string[]", + label: "Tool Types", + description: "The types of tools to enable on the assistant", + options: constants.TOOL_TYPES.filter((toolType) => toolType === "function"), + optional: true, + reloadProps: true, + }, + }, + additionalProps() { + const { + responseFormat, + toolTypes, + numberOfFunctions, + } = this; + const props = {}; + + if (responseFormat === constants.CHAT_RESPONSE_FORMAT.JSON_SCHEMA.value) { + props.jsonSchema = { + type: "string", + label: "JSON Schema", + description: "Define the schema that the model's output must adhere to. [See the documentation here](https://platform.openai.com/docs/guides/structured-outputs/supported-schemas).", + }; + } + + if (toolTypes?.includes("function")) { + props.numberOfFunctions = { + type: "integer", + label: "Number of Functions", + description: "The number of functions to define", + optional: true, + reloadProps: true, + default: 1, + }; + + for (let i = 0; i < (numberOfFunctions || 1); i++) { + props[`functionName_${i}`] = { + type: "string", + label: `Function Name ${i + 1}`, + description: "The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.", + }; + props[`functionDescription_${i}`] = { + type: "string", + label: `Function Description ${i + 1}`, + description: "A description of what the function does, used by the model to choose when and how to call the function.", + optional: true, + }; + props[`functionParameters_${i}`] = { + type: "object", + label: `Function Parameters ${i + 1}`, + description: "The parameters the functions accepts, described as a JSON Schema object. See the [guide](https://platform.openai.com/docs/guides/text-generation/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format.", + optional: true, + }; + } + } + + return props; + }, + methods: { + ...common.methods, + _buildTools() { + const tools = this.toolTypes?.filter((toolType) => toolType !== "function")?.map((toolType) => ({ + type: toolType, + })) || []; + if (this.toolTypes?.includes("function")) { + const numberOfFunctions = this.numberOfFunctions || 1; + for (let i = 0; i < numberOfFunctions; i++) { + tools.push({ + type: "function", + function: { + name: this[`functionName_${i}`], + description: this[`functionDescription_${i}`], + parameters: this[`functionParameters_${i}`], + }, + }); + } + } + return tools.length + ? tools + : undefined; + }, + }, + async run({ $ }) { + if (this.audio && !this.modelId.includes("gpt-4o-audio-preview")) { + throw new ConfigurationError("Use of audio files requires using the `gpt-4o-audio-preview` model."); + } + + const args = this._getChatArgs(); + + const response = await this.openai.createChatCompletion({ + $, + data: { + ...args, + tools: this._buildTools(), + }, + }); + + if (response) { + $.export("$summary", `Successfully sent chat with id ${response.id}`); + } + + const { messages } = args; + return { + original_messages: messages, + original_messages_with_assistant_response: messages.concat(response.choices[0]?.message), + ...response, + }; + }, +}; From f43c08568e15b8c04a7d00a6b8de7e08f21ad15a Mon Sep 17 00:00:00 2001 From: Andrew Chuang Date: Wed, 12 Mar 2025 08:39:42 -0300 Subject: [PATCH 02/16] add app responses method --- components/openai/openai.app.mjs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/components/openai/openai.app.mjs b/components/openai/openai.app.mjs index c7d6c16ed4488..a4542a6dea974 100644 --- a/components/openai/openai.app.mjs +++ b/components/openai/openai.app.mjs @@ -764,6 +764,13 @@ export default { ...args, }); }, + responses(args = {}) { + return this._makeRequest({ + path: "/responses", + method: "POST", + ...args, + }); + }, async *paginate({ resourceFn, args = {}, From 663bddeeccdb8f60b69718d74a3735b1a8e9a4f2 Mon Sep 17 00:00:00 2001 From: Andrew Chuang Date: Wed, 12 Mar 2025 08:39:58 -0300 Subject: [PATCH 03/16] add chat using web search action --- .../chat-web-search/chat-web-search.mjs | 174 ++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 components/openai/actions/chat-web-search/chat-web-search.mjs diff --git a/components/openai/actions/chat-web-search/chat-web-search.mjs b/components/openai/actions/chat-web-search/chat-web-search.mjs new file mode 100644 index 0000000000000..94de284cc548e --- /dev/null +++ b/components/openai/actions/chat-web-search/chat-web-search.mjs @@ -0,0 +1,174 @@ +import openai from "../../openai.app.mjs"; +import common from "../common/common.mjs"; +import constants from "../../common/constants.mjs"; + +export default { + ...common, + name: "Chat using Web Search", + version: "0.0.1", + key: "openai-chat-web-search", + description: "Chat using the web search tool. [See the documentation](https://platform.openai.com/docs/guides/tools-web-search)", + type: "action", + props: { + openai, + modelId: { + type: "string", + label: "Model", + description: "Model used to generate the response", + default: "gpt-4o", + options: [ + "gpt-4o", + "gpt-4o-mini", + ], + }, + input: { + type: "string", + label: "Chat Input", + description: "Text, image, or file inputs to the model, used to generate a response", + }, + instructions: { + type: "string", + label: "Instructions", + description: "Inserts a system (or developer) message as the first item in the model's context", + optional: true, + }, + previousResponseId: { + type: "string", + label: "Previous Response ID", + description: "The unique ID of the previous response to the model. Use this to create multi-turn conversations", + optional: true, + }, + truncation: { + type: "string", + label: "Truncation", + description: "Specifies the truncation mode for the response if it's larger than the context window size", + optional: true, + default: "auto", + options: [ + "auto", + "disabled", + ], + }, + userLocation: { + type: "string[]", + label: "User Location", + description: "Additional configuration for approximate location parameters for the search", + optional: true, + options: [ + "City", + "Region", + "Country", + "Timezone", + ], + }, + searchContextSize: { + type: "string", + label: "Search Context Size", + description: "Determines the amount of context to use during the web search", + optional: true, + default: "medium", + options: [ + "low", + "medium", + "high", + ], + }, + responseFormat: { + type: "string", + label: "Response Format", + 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).", + options: [ + "text", + "json_schema", + ], + default: "text", + optional: true, + reloadProps: true, + }, + }, + additionalProps() { + const { + responseFormat, + userLocation, + } = this; + const props = {}; + + if (userLocation?.includes("City")) { + props.city = { + type: "string", + label: "City", + description: "Free text input for the city of the user, e.g. `San Francisco`", + }; + } + + if (userLocation?.includes("Region")) { + props.region = { + type: "string", + label: "Region", + description: "Free text input for the region of the user, e.g. `California`", + }; + } + + if (userLocation?.includes("Country")) { + props.country = { + type: "string", + label: "Country", + description: "The two-letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1) of the user, e.g. `US`", + }; + } + + if (userLocation?.includes("Timezone")) { + props.timezone = { + type: "string", + label: "Timezone", + description: "The [IANA timezone](https://timeapi.io/documentation/iana-timezones) of the user, e.g. `America/Los_Angeles`", + }; + } + + if (responseFormat === constants.CHAT_RESPONSE_FORMAT.JSON_SCHEMA.value) { + props.jsonSchema = { + type: "string", + label: "JSON Schema", + description: "Define the schema that the model's output must adhere to. [See the documentation here](https://platform.openai.com/docs/guides/structured-outputs/supported-schemas).", + }; + } + + return props; + }, + methods: { + ...common.methods, + }, + async run({ $ }) { + const data = { + model: this.modelId, + input: this.input, + instructions: this.instructions, + previous_response_id: this.previousResponseId, + truncation: this.truncation, + tools: [ + { + type: "web_search_preview", + user_location: { + type: "approximate", + city: this.city, + country: this.country, + region: this.region, + timezone: this.timezone, + }, + search_context_size: this.searchContextSize, + }, + ], + }; + + const response = await this.openai.responses({ + $, + data, + }); + + if (response) { + $.export("$summary", `Successfully sent chat with id ${response.id}`); + } + + return response; + }, +}; From f7f210a0924b4eca8ce012a89f8301ee50467d1e Mon Sep 17 00:00:00 2001 From: Andrew Chuang Date: Wed, 12 Mar 2025 09:30:28 -0300 Subject: [PATCH 04/16] add chat file search action --- .../chat-file-search/chat-file-search.mjs | 203 ++++++++++++++++++ 1 file changed, 203 insertions(+) create mode 100644 components/openai/actions/chat-file-search/chat-file-search.mjs diff --git a/components/openai/actions/chat-file-search/chat-file-search.mjs b/components/openai/actions/chat-file-search/chat-file-search.mjs new file mode 100644 index 0000000000000..c38f4b3aa4559 --- /dev/null +++ b/components/openai/actions/chat-file-search/chat-file-search.mjs @@ -0,0 +1,203 @@ +import openai from "../../openai.app.mjs"; +import common from "../common/common.mjs"; +import constants from "../../common/constants.mjs"; + +export default { + ...common, + name: "Chat using File Search", + version: "0.0.1", + key: "openai-chat-file-search", + description: "Chat with your files knowledge base (vector stores). [See the documentation](https://platform.openai.com/docs/guides/tools-file-search)", + type: "action", + props: { + openai, + alert: { + type: "alert", + alertType: "info", + 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).", + }, + modelId: { + propDefinition: [ + openai, + "chatCompletionModelId", + ], + }, + vectorStoreId: { + propDefinition: [ + openai, + "vectorStoreId", + ], + description: "The identifier of a vector store. Currently supports only one vector store at a time", + }, + input: { + type: "string", + label: "Chat Input", + description: "Text, image, or file inputs to the model, used to generate a response", + }, + instructions: { + type: "string", + label: "Instructions", + description: "Inserts a system (or developer) message as the first item in the model's context", + optional: true, + }, + includeSearchResults: { + type: "boolean", + label: "Include Search Results", + description: "Include the search results in the response", + default: false, + optional: true, + }, + maxNumResults: { + type: "integer", + label: "Max Number of Results", + description: "Customize the number of results you want to retrieve from the vector store", + optional: true, + }, + metadataFiltering: { + type: "boolean", + label: "Metadata Filtering", + description: "Configure how the search results are filtered based on file metadata", + optional: true, + reloadProps: true, + }, + previousResponseId: { + type: "string", + label: "Previous Response ID", + description: "The unique ID of the previous response to the model. Use this to create multi-turn conversations", + optional: true, + }, + truncation: { + type: "string", + label: "Truncation", + description: "Specifies the truncation mode for the response if it's larger than the context window size", + optional: true, + default: "auto", + options: [ + "auto", + "disabled", + ], + }, + responseFormat: { + type: "string", + label: "Response Format", + 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).", + options: [ + "text", + "json_schema", + ], + default: "text", + optional: true, + reloadProps: true, + }, + }, + additionalProps() { + const { + modelId, + metadataFiltering, + responseFormat, + } = this; + const props = {}; + + if (this.openai.isReasoningModel(modelId)) { + props.reasoningEffort = { + type: "string", + label: "Reasoning Effort", + description: "Constrains effort on reasoning for reasoning models", + optional: true, + options: [ + "low", + "medium", + "high", + ], + }; + + // aparrently not supported yet as of 12/march/2025 + // props.generateSummary = { + // type: "string", + // label: "Generate Reasoning Summary", + // description: "A summary of the reasoning performed by the model", + // optional: true, + // options: [ + // "concise", + // "detailed", + // ], + // }; + } + + // TODO: make this configuration user-friendly + // https://platform.openai.com/docs/guides/retrieval?attributes-filter-example=region#attribute-filtering + if (metadataFiltering) { + props.filters = { + type: "object", + label: "Filters", + description: "Filter the search results based on file metadata. [See the documentation here](https://platform.openai.com/docs/guides/retrieval#attribute-filtering)", + }; + } + + if (responseFormat === constants.CHAT_RESPONSE_FORMAT.JSON_SCHEMA.value) { + props.jsonSchema = { + type: "string", + label: "JSON Schema", + description: "Define the schema that the model's output must adhere to. [See the documentation here](https://platform.openai.com/docs/guides/structured-outputs/supported-schemas).", + }; + } + + return props; + }, + methods: { + ...common.methods, + }, + async run({ $ }) { + const data = { + model: this.modelId, + input: this.input, + instructions: this.instructions, + previous_response_id: this.previousResponseId, + truncation: this.truncation, + tools: [ + { + type: "file_search", + vector_store_ids: [ + this.vectorStoreId, + ], + max_num_results: this.maxNumResults, + }, + ], + }; + + if (this.includeSearchResults) { + data.include = [ + "output[*].file_search_call.search_results", + ]; + } + + if (this.filters) { + data.tools[0].filters = this.filters; + } + + if (this.openai.isReasoningModel(this.modelId) && this.reasoningEffort) { + data.reasoning = { + ...data.reasoning, + effort: this.reasoningEffort, + }; + } + + if (this.openai.isReasoningModel(this.modelId) && this.generateSummary) { + data.reasoning = { + ...data.reasoning, + generate_summary: this.generateSummary, + }; + } + + const response = await this.openai.responses({ + $, + data, + }); + + if (response) { + $.export("$summary", `Successfully sent chat with id ${response.id}`); + } + + return response; + }, +}; From 10f33b73b7dc87c7681b06edb463c6c62861705a Mon Sep 17 00:00:00 2001 From: Andrew Chuang Date: Wed, 12 Mar 2025 10:57:50 -0300 Subject: [PATCH 05/16] add chat functions action --- .../actions/chat-functions/chat-functions.mjs | 229 ++++++++++++++++++ 1 file changed, 229 insertions(+) create mode 100644 components/openai/actions/chat-functions/chat-functions.mjs diff --git a/components/openai/actions/chat-functions/chat-functions.mjs b/components/openai/actions/chat-functions/chat-functions.mjs new file mode 100644 index 0000000000000..d4d21ac17ca62 --- /dev/null +++ b/components/openai/actions/chat-functions/chat-functions.mjs @@ -0,0 +1,229 @@ +import openai from "../../openai.app.mjs"; +import common from "../common/common.mjs"; +import constants from "../../common/constants.mjs"; + +export default { + ...common, + name: "Chat using Functions", + version: "0.0.1", + key: "openai-chat-functions", + 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)", + type: "action", + props: { + openai, + alert: { + type: "alert", + alertType: "info", + 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).", + }, + modelId: { + propDefinition: [ + openai, + "chatCompletionModelId", + ], + }, + input: { + type: "string", + label: "Chat Input", + description: "Text, image, or file inputs to the model, used to generate a response", + }, + functions: { + type: "string", + label: "Functions", + 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).", + default: +`[ + { + "type": "function", + "name": "your_function_name", + "description": "Details on when and how to use the function", + "strict": true, + "parameters": { + "type": "object", + "properties": { + "property_name": { + "type": "property_type", + "description": "A description for this property" + }, + "another_property_name": { + "type": "property_type", + "description": "A description for this property" + } + }, + "required": [ + "list", + "of", + "required", + "properties", + "for", + "this", + "object" + ], + "additionalProperties": false + } + } +]`, + }, + instructions: { + type: "string", + label: "Instructions", + description: "Inserts a system (or developer) message as the first item in the model's context", + optional: true, + }, + toolChoice: { + type: "string", + label: "Tool Choice", + // TODO: fix markdown display + description: `Determines how the model will use tools: + - **auto**: The model decides whether and how many tools to call. + - **required**: The model must call one or more tools. + - **function_name**: Write the function name as a custom expression to force the model call this function.`, + optional: true, + default: "auto", + options: [ + "auto", + "required", + ], + }, + parallelToolCalls: { + type: "boolean", + label: "Parallel Function Calling", + description: "Allow or prevent the model to call multiple functions in a single turn", + optional: true, + default: true, + }, + previousResponseId: { + type: "string", + label: "Previous Response ID", + description: "The unique ID of the previous response to the model. Use this to create multi-turn conversations", + optional: true, + }, + truncation: { + type: "string", + label: "Truncation", + description: "Specifies the truncation mode for the response if it's larger than the context window size", + optional: true, + default: "auto", + options: [ + "auto", + "disabled", + ], + }, + responseFormat: { + type: "string", + label: "Response Format", + 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).", + options: [ + "text", + "json_schema", + ], + default: "text", + optional: true, + reloadProps: true, + }, + }, + additionalProps() { + const { + modelId, + responseFormat, + } = this; + const props = {}; + + if (this.openai.isReasoningModel(modelId)) { + props.reasoningEffort = { + type: "string", + label: "Reasoning Effort", + description: "Constrains effort on reasoning for reasoning models", + optional: true, + options: [ + "low", + "medium", + "high", + ], + }; + + // aparrently not supported yet as of 12/march/2025 + // props.generateSummary = { + // type: "string", + // label: "Generate Reasoning Summary", + // description: "A summary of the reasoning performed by the model", + // optional: true, + // options: [ + // "concise", + // "detailed", + // ], + // }; + } + + if (responseFormat === constants.CHAT_RESPONSE_FORMAT.JSON_SCHEMA.value) { + props.jsonSchema = { + type: "string", + label: "JSON Schema", + description: "Define the schema that the model's output must adhere to. [See the documentation here](https://platform.openai.com/docs/guides/structured-outputs/supported-schemas).", + }; + } + + return props; + }, + methods: { + ...common.methods, + }, + async run({ $ }) { + const data = { + model: this.modelId, + input: this.input, + instructions: this.instructions, + previous_response_id: this.previousResponseId, + truncation: this.truncation, + parallel_tool_calls: this.parallelToolCalls, + tools: [], + }; + + let functions = this.functions; + if (typeof functions === "string") { + functions = JSON.parse(functions); + } + + if (Array.isArray(functions)) { + data.tools.push(...functions); + } else { + data.tools.push(functions); + } + + if (this.toolChoice) { + if (this.toolChoice === "auto" || this.toolChoice === "required") { + data.tool_choice = this.toolChoice; + } else { + data.tool_choice = { + type: "function", + name: this.toolChoice, + }; + } + } + + if (this.openai.isReasoningModel(this.modelId) && this.reasoningEffort) { + data.reasoning = { + ...data.reasoning, + effort: this.reasoningEffort, + }; + } + + if (this.openai.isReasoningModel(this.modelId) && this.generateSummary) { + data.reasoning = { + ...data.reasoning, + generate_summary: this.generateSummary, + }; + } + + const response = await this.openai.responses({ + $, + data, + }); + + if (response) { + $.export("$summary", `Successfully sent chat with id ${response.id}`); + } + + return response; + }, +}; From 37ba7a7e15788cace2ee5b831294ba6756903382 Mon Sep 17 00:00:00 2001 From: Andrew Chuang Date: Wed, 12 Mar 2025 10:58:38 -0300 Subject: [PATCH 06/16] method for checking if reasoning model --- components/openai/openai.app.mjs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/components/openai/openai.app.mjs b/components/openai/openai.app.mjs index a4542a6dea974..5851c920158a3 100644 --- a/components/openai/openai.app.mjs +++ b/components/openai/openai.app.mjs @@ -338,6 +338,9 @@ export default { maxBodyLength: Infinity, }); }, + isReasoningModel(model) { + return model.match(/^o[1-9]/gi)?.length; + }, async models({ $ }) { const { data: models } = await this._makeRequest({ $, From 9693a651ebc987600921cda325363c870009f410 Mon Sep 17 00:00:00 2001 From: Andrew Chuang Date: Wed, 12 Mar 2025 11:04:39 -0300 Subject: [PATCH 07/16] add skip step execution --- .../actions/chat-file-search/chat-file-search.mjs | 12 ++++++++++++ .../openai/actions/chat-functions/chat-functions.mjs | 12 ++++++++++++ .../actions/chat-web-search/chat-web-search.mjs | 12 ++++++++++++ 3 files changed, 36 insertions(+) diff --git a/components/openai/actions/chat-file-search/chat-file-search.mjs b/components/openai/actions/chat-file-search/chat-file-search.mjs index c38f4b3aa4559..5bb783d19f1f7 100644 --- a/components/openai/actions/chat-file-search/chat-file-search.mjs +++ b/components/openai/actions/chat-file-search/chat-file-search.mjs @@ -89,6 +89,13 @@ export default { optional: true, reloadProps: true, }, + skipThisStep: { + type: "boolean", + label: "Skip This Step", + description: "Pass in a boolean custom expression to skip this step's execution at runtime", + optional: true, + default: false, + }, }, additionalProps() { const { @@ -148,6 +155,11 @@ export default { ...common.methods, }, async run({ $ }) { + if (this.skipThisStep) { + $.export("$summary", "Step execution skipped"); + return; + } + const data = { model: this.modelId, input: this.input, diff --git a/components/openai/actions/chat-functions/chat-functions.mjs b/components/openai/actions/chat-functions/chat-functions.mjs index d4d21ac17ca62..24e9995012c1f 100644 --- a/components/openai/actions/chat-functions/chat-functions.mjs +++ b/components/openai/actions/chat-functions/chat-functions.mjs @@ -121,6 +121,13 @@ export default { optional: true, reloadProps: true, }, + skipThisStep: { + type: "boolean", + label: "Skip This Step", + description: "Pass in a boolean custom expression to skip this step's execution at runtime", + optional: true, + default: false, + }, }, additionalProps() { const { @@ -169,6 +176,11 @@ export default { ...common.methods, }, async run({ $ }) { + if (this.skipThisStep) { + $.export("$summary", "Step execution skipped"); + return; + } + const data = { model: this.modelId, input: this.input, diff --git a/components/openai/actions/chat-web-search/chat-web-search.mjs b/components/openai/actions/chat-web-search/chat-web-search.mjs index 94de284cc548e..783b6de505c78 100644 --- a/components/openai/actions/chat-web-search/chat-web-search.mjs +++ b/components/openai/actions/chat-web-search/chat-web-search.mjs @@ -85,6 +85,13 @@ export default { optional: true, reloadProps: true, }, + skipThisStep: { + type: "boolean", + label: "Skip This Step", + description: "Pass in a boolean custom expression to skip this step's execution at runtime", + optional: true, + default: false, + }, }, additionalProps() { const { @@ -139,6 +146,11 @@ export default { ...common.methods, }, async run({ $ }) { + if (this.skipThisStep) { + $.export("$summary", "Step execution skipped"); + return; + } + const data = { model: this.modelId, input: this.input, From 1e1dfcc8367aa0f5c9983a52c1fa1457fdc2fbfe Mon Sep 17 00:00:00 2001 From: Andrew Chuang Date: Wed, 12 Mar 2025 11:09:25 -0300 Subject: [PATCH 08/16] rename actions --- .../chat-using-file-search.mjs} | 2 +- .../chat-using-functions.mjs} | 2 +- .../chat-using-web-search.mjs} | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename components/openai/actions/{chat-file-search/chat-file-search.mjs => chat-using-file-search/chat-using-file-search.mjs} (99%) rename components/openai/actions/{chat-functions/chat-functions.mjs => chat-using-functions/chat-using-functions.mjs} (99%) rename components/openai/actions/{chat-web-search/chat-web-search.mjs => chat-using-web-search/chat-using-web-search.mjs} (99%) diff --git a/components/openai/actions/chat-file-search/chat-file-search.mjs b/components/openai/actions/chat-using-file-search/chat-using-file-search.mjs similarity index 99% rename from components/openai/actions/chat-file-search/chat-file-search.mjs rename to components/openai/actions/chat-using-file-search/chat-using-file-search.mjs index 5bb783d19f1f7..5c9b249bb7eb1 100644 --- a/components/openai/actions/chat-file-search/chat-file-search.mjs +++ b/components/openai/actions/chat-using-file-search/chat-using-file-search.mjs @@ -6,7 +6,7 @@ export default { ...common, name: "Chat using File Search", version: "0.0.1", - key: "openai-chat-file-search", + key: "openai-chat-using-file-search", description: "Chat with your files knowledge base (vector stores). [See the documentation](https://platform.openai.com/docs/guides/tools-file-search)", type: "action", props: { diff --git a/components/openai/actions/chat-functions/chat-functions.mjs b/components/openai/actions/chat-using-functions/chat-using-functions.mjs similarity index 99% rename from components/openai/actions/chat-functions/chat-functions.mjs rename to components/openai/actions/chat-using-functions/chat-using-functions.mjs index 24e9995012c1f..e7aa008492181 100644 --- a/components/openai/actions/chat-functions/chat-functions.mjs +++ b/components/openai/actions/chat-using-functions/chat-using-functions.mjs @@ -6,7 +6,7 @@ export default { ...common, name: "Chat using Functions", version: "0.0.1", - key: "openai-chat-functions", + key: "openai-chat-using-functions", 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)", type: "action", props: { diff --git a/components/openai/actions/chat-web-search/chat-web-search.mjs b/components/openai/actions/chat-using-web-search/chat-using-web-search.mjs similarity index 99% rename from components/openai/actions/chat-web-search/chat-web-search.mjs rename to components/openai/actions/chat-using-web-search/chat-using-web-search.mjs index 783b6de505c78..5ec38d592b6f4 100644 --- a/components/openai/actions/chat-web-search/chat-web-search.mjs +++ b/components/openai/actions/chat-using-web-search/chat-using-web-search.mjs @@ -6,7 +6,7 @@ export default { ...common, name: "Chat using Web Search", version: "0.0.1", - key: "openai-chat-web-search", + key: "openai-chat-using-web-search", description: "Chat using the web search tool. [See the documentation](https://platform.openai.com/docs/guides/tools-web-search)", type: "action", props: { From e164d5b3ec3588c2b2965e037fd924d12161cef8 Mon Sep 17 00:00:00 2001 From: Andrew Chuang Date: Wed, 12 Mar 2025 11:09:57 -0300 Subject: [PATCH 09/16] delete chat with tools action --- .../chat-with-tools/chat-with-tools.mjs | 168 ------------------ 1 file changed, 168 deletions(-) delete mode 100644 components/openai/actions/chat-with-tools/chat-with-tools.mjs diff --git a/components/openai/actions/chat-with-tools/chat-with-tools.mjs b/components/openai/actions/chat-with-tools/chat-with-tools.mjs deleted file mode 100644 index 62602ddc333f7..0000000000000 --- a/components/openai/actions/chat-with-tools/chat-with-tools.mjs +++ /dev/null @@ -1,168 +0,0 @@ -import openai from "../../openai.app.mjs"; -import common from "../common/common.mjs"; -import constants from "../../common/constants.mjs"; -import { ConfigurationError } from "@pipedream/platform"; - -export default { - ...common, - name: "Chat with Tools (Responses API)", - version: "0.0.1", - key: "openai-chat-with-tools", - description: "Chat, using the Responses API. [See the documentation](https://platform.openai.com/docs/api-reference/responses)", - type: "action", - props: { - openai, - modelId: { - propDefinition: [ - openai, - "chatCompletionModelId", - ], - }, - userMessage: { - label: "User Message", - type: "string", - description: "The user messages provide instructions to the assistant. They can be generated by the end users of an application, or set by a developer as an instruction.", - }, - ...common.props, - systemInstructions: { - label: "System Instructions", - type: "string", - description: "The system message helps set the behavior of the assistant. For example: \"You are a helpful assistant.\" [See these docs](https://platform.openai.com/docs/guides/chat/instructing-chat-models) for tips on writing good instructions.", - optional: true, - }, - messages: { - label: "Prior Message History", - type: "string[]", - 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.", - optional: true, - }, - images: { - label: "Images", - type: "string[]", - 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", - optional: true, - }, - audio: { - type: "string", - label: "Audio", - description: "Provide the file path to an audio file in the `/tmp` directory. For use with the `gpt-4o-audio-preview` model. Currently supports `wav` and `mp3` files.", - optional: true, - }, - responseFormat: { - type: "string", - label: "Response Format", - description: "Specify the format that the model must output. \n- **Text** (default): Returns unstructured text output.\n- **JSON Object**: Ensures the model's output is a valid JSON object.\n- **JSON Schema** (GPT-4o and later): Enables you to define a specific structure for the model's output using a JSON schema. Supported with models `gpt-4o-2024-08-06` and later, and `gpt-4o-mini-2024-07-18` and later.", - options: Object.values(constants.CHAT_RESPONSE_FORMAT), - default: constants.CHAT_RESPONSE_FORMAT.TEXT.value, - optional: true, - reloadProps: true, - }, - toolTypes: { - type: "string[]", - label: "Tool Types", - description: "The types of tools to enable on the assistant", - options: constants.TOOL_TYPES.filter((toolType) => toolType === "function"), - optional: true, - reloadProps: true, - }, - }, - additionalProps() { - const { - responseFormat, - toolTypes, - numberOfFunctions, - } = this; - const props = {}; - - if (responseFormat === constants.CHAT_RESPONSE_FORMAT.JSON_SCHEMA.value) { - props.jsonSchema = { - type: "string", - label: "JSON Schema", - description: "Define the schema that the model's output must adhere to. [See the documentation here](https://platform.openai.com/docs/guides/structured-outputs/supported-schemas).", - }; - } - - if (toolTypes?.includes("function")) { - props.numberOfFunctions = { - type: "integer", - label: "Number of Functions", - description: "The number of functions to define", - optional: true, - reloadProps: true, - default: 1, - }; - - for (let i = 0; i < (numberOfFunctions || 1); i++) { - props[`functionName_${i}`] = { - type: "string", - label: `Function Name ${i + 1}`, - description: "The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.", - }; - props[`functionDescription_${i}`] = { - type: "string", - label: `Function Description ${i + 1}`, - description: "A description of what the function does, used by the model to choose when and how to call the function.", - optional: true, - }; - props[`functionParameters_${i}`] = { - type: "object", - label: `Function Parameters ${i + 1}`, - description: "The parameters the functions accepts, described as a JSON Schema object. See the [guide](https://platform.openai.com/docs/guides/text-generation/function-calling) for examples, and the [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for documentation about the format.", - optional: true, - }; - } - } - - return props; - }, - methods: { - ...common.methods, - _buildTools() { - const tools = this.toolTypes?.filter((toolType) => toolType !== "function")?.map((toolType) => ({ - type: toolType, - })) || []; - if (this.toolTypes?.includes("function")) { - const numberOfFunctions = this.numberOfFunctions || 1; - for (let i = 0; i < numberOfFunctions; i++) { - tools.push({ - type: "function", - function: { - name: this[`functionName_${i}`], - description: this[`functionDescription_${i}`], - parameters: this[`functionParameters_${i}`], - }, - }); - } - } - return tools.length - ? tools - : undefined; - }, - }, - async run({ $ }) { - if (this.audio && !this.modelId.includes("gpt-4o-audio-preview")) { - throw new ConfigurationError("Use of audio files requires using the `gpt-4o-audio-preview` model."); - } - - const args = this._getChatArgs(); - - const response = await this.openai.createChatCompletion({ - $, - data: { - ...args, - tools: this._buildTools(), - }, - }); - - if (response) { - $.export("$summary", `Successfully sent chat with id ${response.id}`); - } - - const { messages } = args; - return { - original_messages: messages, - original_messages_with_assistant_response: messages.concat(response.choices[0]?.message), - ...response, - }; - }, -}; From a62828e9126164ab4864917ed9621029d86b4191 Mon Sep 17 00:00:00 2001 From: Andrew Chuang Date: Wed, 12 Mar 2025 11:13:30 -0300 Subject: [PATCH 10/16] add alert for chat actions --- .../actions/chat-with-assistant/chat-with-assistant.mjs | 5 +++++ components/openai/actions/chat/chat.mjs | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/components/openai/actions/chat-with-assistant/chat-with-assistant.mjs b/components/openai/actions/chat-with-assistant/chat-with-assistant.mjs index 1cd63b709a694..aeb33d32bae09 100644 --- a/components/openai/actions/chat-with-assistant/chat-with-assistant.mjs +++ b/components/openai/actions/chat-with-assistant/chat-with-assistant.mjs @@ -10,6 +10,11 @@ export default { type: "action", props: { openai, + alert: { + type: "alert", + alertType: "info", + 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).", + }, message: { type: "string", label: "Message", diff --git a/components/openai/actions/chat/chat.mjs b/components/openai/actions/chat/chat.mjs index 7d6ec0786aa3a..59069946b5a61 100644 --- a/components/openai/actions/chat/chat.mjs +++ b/components/openai/actions/chat/chat.mjs @@ -12,6 +12,11 @@ export default { type: "action", props: { openai, + alert: { + type: "alert", + alertType: "info", + 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).", + }, modelId: { propDefinition: [ openai, From 979e99775488cbb319340217d04b1c157204f359 Mon Sep 17 00:00:00 2001 From: Andrew Chuang Date: Wed, 12 Mar 2025 11:14:33 -0300 Subject: [PATCH 11/16] pnpm --- pnpm-lock.yaml | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2bda7de837f26..d59dda7799ea1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2343,8 +2343,7 @@ importers: components/claris_filemaker_server_odata_api: {} - components/classmarker: - specifiers: {} + components/classmarker: {} components/clear_books: dependencies: @@ -4159,8 +4158,7 @@ importers: specifier: ^3.0.3 version: 3.0.3 - components/evernote: - specifiers: {} + components/evernote: {} components/eversign: dependencies: @@ -5374,8 +5372,7 @@ importers: specifier: ^3.0.3 version: 3.0.3 - components/google_marketplace: - specifiers: {} + components/google_marketplace: {} components/google_meet: dependencies: @@ -7247,8 +7244,7 @@ importers: specifier: ^1.6.0 version: 1.6.6 - components/livespace: - specifiers: {} + components/livespace: {} components/livestorm: dependencies: @@ -7554,8 +7550,7 @@ importers: specifier: ^3.0.0 version: 3.0.3 - components/mailsoftly: - specifiers: {} + components/mailsoftly: {} components/mailtrap: {} @@ -12601,8 +12596,7 @@ importers: components/test_apps_for_checking_something_001: {} - components/test_apps_for_switching_appslug_009: - specifiers: {} + components/test_apps_for_switching_appslug_009: {} components/testmo: dependencies: From 11dc862245a992c208946c4ad104de22fd027244 Mon Sep 17 00:00:00 2001 From: Andrew Chuang Date: Wed, 12 Mar 2025 11:19:19 -0300 Subject: [PATCH 12/16] bump versions --- .../actions/analyze-image-content/analyze-image-content.mjs | 2 +- components/openai/actions/cancel-run/cancel-run.mjs | 2 +- .../openai/actions/chat-with-assistant/chat-with-assistant.mjs | 2 +- components/openai/actions/chat/chat.mjs | 2 +- .../classify-items-into-categories.mjs | 2 +- .../actions/convert-text-to-speech/convert-text-to-speech.mjs | 2 +- components/openai/actions/create-assistant/create-assistant.mjs | 2 +- components/openai/actions/create-batch/create-batch.mjs | 2 +- .../openai/actions/create-embeddings/create-embeddings.mjs | 2 +- .../actions/create-fine-tuning-job/create-fine-tuning-job.mjs | 2 +- components/openai/actions/create-image/create-image.mjs | 2 +- .../openai/actions/create-moderation/create-moderation.mjs | 2 +- components/openai/actions/create-thread/create-thread.mjs | 2 +- .../create-vector-store-file/create-vector-store-file.mjs | 2 +- .../openai/actions/create-vector-store/create-vector-store.mjs | 2 +- components/openai/actions/delete-file/delete-file.mjs | 2 +- .../delete-vector-store-file/delete-vector-store-file.mjs | 2 +- .../openai/actions/delete-vector-store/delete-vector-store.mjs | 2 +- components/openai/actions/list-files/list-files.mjs | 2 +- components/openai/actions/list-messages/list-messages.mjs | 2 +- components/openai/actions/list-run-steps/list-run-steps.mjs | 2 +- components/openai/actions/list-runs/list-runs.mjs | 2 +- .../actions/list-vector-store-files/list-vector-store-files.mjs | 2 +- .../openai/actions/list-vector-stores/list-vector-stores.mjs | 2 +- components/openai/actions/modify-assistant/modify-assistant.mjs | 2 +- .../actions/retrieve-file-content/retrieve-file-content.mjs | 2 +- components/openai/actions/retrieve-file/retrieve-file.mjs | 2 +- .../openai/actions/retrieve-run-step/retrieve-run-step.mjs | 2 +- components/openai/actions/retrieve-run/retrieve-run.mjs | 2 +- .../retrieve-vector-store-file/retrieve-vector-store-file.mjs | 2 +- .../actions/retrieve-vector-store/retrieve-vector-store.mjs | 2 +- components/openai/actions/send-prompt/send-prompt.mjs | 2 +- .../submit-tool-outputs-to-run/submit-tool-outputs-to-run.mjs | 2 +- components/openai/actions/summarize/summarize.mjs | 2 +- components/openai/actions/translate-text/translate-text.mjs | 2 +- components/openai/actions/upload-file/upload-file.mjs | 2 +- components/openai/package.json | 2 +- .../openai/sources/new-batch-completed/new-batch-completed.mjs | 2 +- components/openai/sources/new-file-created/new-file-created.mjs | 2 +- .../new-fine-tuning-job-created/new-fine-tuning-job-created.mjs | 2 +- .../sources/new-run-state-changed/new-run-state-changed.mjs | 2 +- 41 files changed, 41 insertions(+), 41 deletions(-) diff --git a/components/openai/actions/analyze-image-content/analyze-image-content.mjs b/components/openai/actions/analyze-image-content/analyze-image-content.mjs index f656b37f7da1e..8301a65a3ae57 100644 --- a/components/openai/actions/analyze-image-content/analyze-image-content.mjs +++ b/components/openai/actions/analyze-image-content/analyze-image-content.mjs @@ -8,7 +8,7 @@ export default { key: "openai-analyze-image-content", name: "Analyze Image Content", 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)", - version: "0.1.4", + version: "0.1.5", type: "action", props: { openai, diff --git a/components/openai/actions/cancel-run/cancel-run.mjs b/components/openai/actions/cancel-run/cancel-run.mjs index 54050850537d6..7d803eae3fb43 100644 --- a/components/openai/actions/cancel-run/cancel-run.mjs +++ b/components/openai/actions/cancel-run/cancel-run.mjs @@ -4,7 +4,7 @@ export default { key: "openai-cancel-run", name: "Cancel Run (Assistants)", description: "Cancels a run that is in progress. [See the documentation](https://platform.openai.com/docs/api-reference/runs/cancelRun)", - version: "0.0.13", + version: "0.0.14", type: "action", props: { openai, diff --git a/components/openai/actions/chat-with-assistant/chat-with-assistant.mjs b/components/openai/actions/chat-with-assistant/chat-with-assistant.mjs index aeb33d32bae09..ee0598fda3a01 100644 --- a/components/openai/actions/chat-with-assistant/chat-with-assistant.mjs +++ b/components/openai/actions/chat-with-assistant/chat-with-assistant.mjs @@ -6,7 +6,7 @@ export default { key: "openai-chat-with-assistant", name: "Chat with Assistant", 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)", - version: "0.0.9", + version: "0.0.10", type: "action", props: { openai, diff --git a/components/openai/actions/chat/chat.mjs b/components/openai/actions/chat/chat.mjs index 59069946b5a61..0b79fa2e26840 100644 --- a/components/openai/actions/chat/chat.mjs +++ b/components/openai/actions/chat/chat.mjs @@ -6,7 +6,7 @@ import { ConfigurationError } from "@pipedream/platform"; export default { ...common, name: "Chat", - version: "0.2.5", + version: "0.2.6", key: "openai-chat", 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)", type: "action", diff --git a/components/openai/actions/classify-items-into-categories/classify-items-into-categories.mjs b/components/openai/actions/classify-items-into-categories/classify-items-into-categories.mjs index b1edf09015f78..2f93c93298041 100644 --- a/components/openai/actions/classify-items-into-categories/classify-items-into-categories.mjs +++ b/components/openai/actions/classify-items-into-categories/classify-items-into-categories.mjs @@ -3,7 +3,7 @@ import common from "../common/common-helper.mjs"; export default { ...common, name: "Classify Items into Categories", - version: "0.1.4", + version: "0.1.5", key: "openai-classify-items-into-categories", description: "Classify items into specific categories using the Chat API. [See the documentation](https://platform.openai.com/docs/api-reference/chat)", type: "action", diff --git a/components/openai/actions/convert-text-to-speech/convert-text-to-speech.mjs b/components/openai/actions/convert-text-to-speech/convert-text-to-speech.mjs index 376e3e3c13cd7..7f7b6c9a96979 100644 --- a/components/openai/actions/convert-text-to-speech/convert-text-to-speech.mjs +++ b/components/openai/actions/convert-text-to-speech/convert-text-to-speech.mjs @@ -5,7 +5,7 @@ export default { key: "openai-convert-text-to-speech", name: "Convert Text to Speech (TTS)", description: "Generates audio from the input text. [See the documentation](https://platform.openai.com/docs/api-reference/audio/createSpeech)", - version: "0.0.12", + version: "0.0.13", type: "action", props: { openai, diff --git a/components/openai/actions/create-assistant/create-assistant.mjs b/components/openai/actions/create-assistant/create-assistant.mjs index b3d2227a95f56..41f32cb2eb79a 100644 --- a/components/openai/actions/create-assistant/create-assistant.mjs +++ b/components/openai/actions/create-assistant/create-assistant.mjs @@ -6,7 +6,7 @@ export default { key: "openai-create-assistant", name: "Create Assistant", description: "Creates an assistant with a model and instructions. [See the documentation](https://platform.openai.com/docs/api-reference/assistants/createAssistant)", - version: "0.1.11", + version: "0.1.12", type: "action", props: { openai, diff --git a/components/openai/actions/create-batch/create-batch.mjs b/components/openai/actions/create-batch/create-batch.mjs index 6277dfca0ed35..a48ed425497a6 100644 --- a/components/openai/actions/create-batch/create-batch.mjs +++ b/components/openai/actions/create-batch/create-batch.mjs @@ -8,7 +8,7 @@ export default { key: "openai-create-batch", name: "Create Batch", description: "Creates and executes a batch from an uploaded file of requests. [See the documentation](https://platform.openai.com/docs/api-reference/batch/create)", - version: "0.0.7", + version: "0.0.8", type: "action", props: { openai, diff --git a/components/openai/actions/create-embeddings/create-embeddings.mjs b/components/openai/actions/create-embeddings/create-embeddings.mjs index fdc3e30305f76..db0bc89ad9a08 100644 --- a/components/openai/actions/create-embeddings/create-embeddings.mjs +++ b/components/openai/actions/create-embeddings/create-embeddings.mjs @@ -4,7 +4,7 @@ import common from "../common/common.mjs"; export default { name: "Create Embeddings", - version: "0.0.16", + version: "0.0.17", key: "openai-create-embeddings", 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)", type: "action", diff --git a/components/openai/actions/create-fine-tuning-job/create-fine-tuning-job.mjs b/components/openai/actions/create-fine-tuning-job/create-fine-tuning-job.mjs index d80be648e8aee..2a48596edc461 100644 --- a/components/openai/actions/create-fine-tuning-job/create-fine-tuning-job.mjs +++ b/components/openai/actions/create-fine-tuning-job/create-fine-tuning-job.mjs @@ -4,7 +4,7 @@ export default { key: "openai-create-fine-tuning-job", name: "Create Fine Tuning Job", 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)", - version: "0.0.12", + version: "0.0.13", type: "action", props: { openai, diff --git a/components/openai/actions/create-image/create-image.mjs b/components/openai/actions/create-image/create-image.mjs index 9e875bea571f6..cbb2d45fb0d5a 100644 --- a/components/openai/actions/create-image/create-image.mjs +++ b/components/openai/actions/create-image/create-image.mjs @@ -4,7 +4,7 @@ import fs from "fs"; export default { name: "Create Image (Dall-E)", - version: "0.1.20", + version: "0.1.21", key: "openai-create-image", description: "Creates an image given a prompt returning a URL to the image. [See the documentation](https://platform.openai.com/docs/api-reference/images)", type: "action", diff --git a/components/openai/actions/create-moderation/create-moderation.mjs b/components/openai/actions/create-moderation/create-moderation.mjs index 8b09cea1ff4ce..e7561691934e4 100644 --- a/components/openai/actions/create-moderation/create-moderation.mjs +++ b/components/openai/actions/create-moderation/create-moderation.mjs @@ -5,7 +5,7 @@ export default { key: "openai-create-moderation", name: "Create Moderation", description: "Classifies if text is potentially harmful. [See the documentation](https://platform.openai.com/docs/api-reference/moderations/create)", - version: "0.0.7", + version: "0.0.8", type: "action", props: { openai, diff --git a/components/openai/actions/create-thread/create-thread.mjs b/components/openai/actions/create-thread/create-thread.mjs index 2e43d3ba1b1ba..e5653c9fec7e4 100644 --- a/components/openai/actions/create-thread/create-thread.mjs +++ b/components/openai/actions/create-thread/create-thread.mjs @@ -6,7 +6,7 @@ export default { key: "openai-create-thread", name: "Create Thread (Assistants)", 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)", - version: "0.0.13", + version: "0.0.14", type: "action", props: { openai, diff --git a/components/openai/actions/create-vector-store-file/create-vector-store-file.mjs b/components/openai/actions/create-vector-store-file/create-vector-store-file.mjs index b6b1d4ee79a93..0fc6592f0a4f3 100644 --- a/components/openai/actions/create-vector-store-file/create-vector-store-file.mjs +++ b/components/openai/actions/create-vector-store-file/create-vector-store-file.mjs @@ -4,7 +4,7 @@ export default { key: "openai-create-vector-store-file", name: "Create Vector Store File", description: "Create a vector store file. [See the documentation](https://platform.openai.com/docs/api-reference/vector-stores-files/createFile)", - version: "0.0.3", + version: "0.0.4", type: "action", props: { openai, diff --git a/components/openai/actions/create-vector-store/create-vector-store.mjs b/components/openai/actions/create-vector-store/create-vector-store.mjs index 5310772519f77..951c55c8435e2 100644 --- a/components/openai/actions/create-vector-store/create-vector-store.mjs +++ b/components/openai/actions/create-vector-store/create-vector-store.mjs @@ -4,7 +4,7 @@ export default { key: "openai-create-vector-store", name: "Create Vector Store", description: "Create a vector store. [See the documentation](https://platform.openai.com/docs/api-reference/vector-stores/create)", - version: "0.0.3", + version: "0.0.4", type: "action", props: { openai, diff --git a/components/openai/actions/delete-file/delete-file.mjs b/components/openai/actions/delete-file/delete-file.mjs index 5aadc79614b40..39134cf69281f 100644 --- a/components/openai/actions/delete-file/delete-file.mjs +++ b/components/openai/actions/delete-file/delete-file.mjs @@ -4,7 +4,7 @@ export default { key: "openai-delete-file", name: "Delete File", description: "Deletes a specified file from OpenAI. [See the documentation](https://platform.openai.com/docs/api-reference/files/delete)", - version: "0.0.13", + version: "0.0.14", type: "action", props: { openai, diff --git a/components/openai/actions/delete-vector-store-file/delete-vector-store-file.mjs b/components/openai/actions/delete-vector-store-file/delete-vector-store-file.mjs index 44ee5a7ba7d45..7ce90f7be2185 100644 --- a/components/openai/actions/delete-vector-store-file/delete-vector-store-file.mjs +++ b/components/openai/actions/delete-vector-store-file/delete-vector-store-file.mjs @@ -4,7 +4,7 @@ export default { key: "openai-delete-vector-store-file", name: "Delete Vector Store File", description: "Deletes a vector store file. [See the documentation](https://platform.openai.com/docs/api-reference/vector-stores-files/deleteFile)", - version: "0.0.3", + version: "0.0.4", type: "action", props: { openai, diff --git a/components/openai/actions/delete-vector-store/delete-vector-store.mjs b/components/openai/actions/delete-vector-store/delete-vector-store.mjs index 6e2183928501f..e715c31e63621 100644 --- a/components/openai/actions/delete-vector-store/delete-vector-store.mjs +++ b/components/openai/actions/delete-vector-store/delete-vector-store.mjs @@ -4,7 +4,7 @@ export default { key: "openai-delete-vector-store", name: "Delete Vector Store", description: "Delete a vector store. [See the documentation](https://platform.openai.com/docs/api-reference/vector-stores/delete)", - version: "0.0.3", + version: "0.0.4", type: "action", props: { openai, diff --git a/components/openai/actions/list-files/list-files.mjs b/components/openai/actions/list-files/list-files.mjs index 07b8b74ca954d..eec681371f49b 100644 --- a/components/openai/actions/list-files/list-files.mjs +++ b/components/openai/actions/list-files/list-files.mjs @@ -4,7 +4,7 @@ export default { key: "openai-list-files", name: "List Files", 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)", - version: "0.0.13", + version: "0.0.14", type: "action", props: { openai, diff --git a/components/openai/actions/list-messages/list-messages.mjs b/components/openai/actions/list-messages/list-messages.mjs index 6e8ce277246fa..53cf1608dc703 100644 --- a/components/openai/actions/list-messages/list-messages.mjs +++ b/components/openai/actions/list-messages/list-messages.mjs @@ -4,7 +4,7 @@ export default { key: "openai-list-messages", name: "List Messages (Assistants)", description: "Lists the messages for a given thread. [See the documentation](https://platform.openai.com/docs/api-reference/messages/listMessages)", - version: "0.0.14", + version: "0.0.15", type: "action", props: { openai, diff --git a/components/openai/actions/list-run-steps/list-run-steps.mjs b/components/openai/actions/list-run-steps/list-run-steps.mjs index 604de4c8b692f..daa54aafb94d0 100644 --- a/components/openai/actions/list-run-steps/list-run-steps.mjs +++ b/components/openai/actions/list-run-steps/list-run-steps.mjs @@ -4,7 +4,7 @@ export default { key: "openai-list-run-steps", name: "List Run Steps (Assistants)", 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)", - version: "0.0.13", + version: "0.0.14", type: "action", props: { openai, diff --git a/components/openai/actions/list-runs/list-runs.mjs b/components/openai/actions/list-runs/list-runs.mjs index 1ed17dd1860b3..e4362d8fce27f 100644 --- a/components/openai/actions/list-runs/list-runs.mjs +++ b/components/openai/actions/list-runs/list-runs.mjs @@ -4,7 +4,7 @@ export default { key: "openai-list-runs", name: "List Runs (Assistants)", description: "Returns a list of runs belonging to a thread. [See the documentation](https://platform.openai.com/docs/api-reference/runs/list)", - version: "0.0.14", + version: "0.0.15", type: "action", props: { openai, diff --git a/components/openai/actions/list-vector-store-files/list-vector-store-files.mjs b/components/openai/actions/list-vector-store-files/list-vector-store-files.mjs index daff6a616cba9..aed4fbeadbdfb 100644 --- a/components/openai/actions/list-vector-store-files/list-vector-store-files.mjs +++ b/components/openai/actions/list-vector-store-files/list-vector-store-files.mjs @@ -4,7 +4,7 @@ export default { key: "openai-list-vector-store-files", name: "List Vector Store Files", description: "Returns a list of vector store file. [See the documentation](https://platform.openai.com/docs/api-reference/vector-stores-files/listFiles)", - version: "0.0.3", + version: "0.0.4", type: "action", props: { openai, diff --git a/components/openai/actions/list-vector-stores/list-vector-stores.mjs b/components/openai/actions/list-vector-stores/list-vector-stores.mjs index 27295b2eca338..f2d68712cbcd2 100644 --- a/components/openai/actions/list-vector-stores/list-vector-stores.mjs +++ b/components/openai/actions/list-vector-stores/list-vector-stores.mjs @@ -4,7 +4,7 @@ export default { key: "openai-list-vector-stores", name: "List Vector Stores", description: "Returns a list of vector stores. [See the documentation](https://platform.openai.com/docs/api-reference/vector-stores/list)", - version: "0.0.3", + version: "0.0.4", type: "action", props: { openai, diff --git a/components/openai/actions/modify-assistant/modify-assistant.mjs b/components/openai/actions/modify-assistant/modify-assistant.mjs index 07f0f30415e63..d939ee30279f5 100644 --- a/components/openai/actions/modify-assistant/modify-assistant.mjs +++ b/components/openai/actions/modify-assistant/modify-assistant.mjs @@ -6,7 +6,7 @@ export default { key: "openai-modify-assistant", name: "Modify an Assistant", description: "Modifies an existing OpenAI assistant. [See the documentation](https://platform.openai.com/docs/api-reference/assistants/modifyAssistant)", - version: "0.1.11", + version: "0.1.12", type: "action", props: { openai, diff --git a/components/openai/actions/retrieve-file-content/retrieve-file-content.mjs b/components/openai/actions/retrieve-file-content/retrieve-file-content.mjs index 35adcf4d256bc..d967e1ccbe86d 100644 --- a/components/openai/actions/retrieve-file-content/retrieve-file-content.mjs +++ b/components/openai/actions/retrieve-file-content/retrieve-file-content.mjs @@ -5,7 +5,7 @@ export default { key: "openai-retrieve-file-content", name: "Retrieve File Content", description: "Retrieves the contents of the specified file. [See the documentation](https://platform.openai.com/docs/api-reference/files/retrieve-content)", - version: "0.0.13", + version: "0.0.14", type: "action", props: { openai, diff --git a/components/openai/actions/retrieve-file/retrieve-file.mjs b/components/openai/actions/retrieve-file/retrieve-file.mjs index f88994a6994a9..40a817c7a3520 100644 --- a/components/openai/actions/retrieve-file/retrieve-file.mjs +++ b/components/openai/actions/retrieve-file/retrieve-file.mjs @@ -4,7 +4,7 @@ export default { key: "openai-retrieve-file", name: "Retrieve File", description: "Retrieves a specific file from OpenAI. [See the documentation](https://platform.openai.com/docs/api-reference/files/retrieve)", - version: "0.0.13", + version: "0.0.14", type: "action", props: { openai, diff --git a/components/openai/actions/retrieve-run-step/retrieve-run-step.mjs b/components/openai/actions/retrieve-run-step/retrieve-run-step.mjs index 3397c3f080218..ff3e744fd5393 100644 --- a/components/openai/actions/retrieve-run-step/retrieve-run-step.mjs +++ b/components/openai/actions/retrieve-run-step/retrieve-run-step.mjs @@ -4,7 +4,7 @@ export default { key: "openai-retrieve-run-step", name: "Retrieve Run Step (Assistants)", description: "Retrieve a specific run step in a thread. [See the documentation](https://platform.openai.com/docs/api-reference/runs/getRunStep)", - version: "0.0.13", + version: "0.0.14", type: "action", props: { openai, diff --git a/components/openai/actions/retrieve-run/retrieve-run.mjs b/components/openai/actions/retrieve-run/retrieve-run.mjs index 4f26c51a18876..5b225299973fd 100644 --- a/components/openai/actions/retrieve-run/retrieve-run.mjs +++ b/components/openai/actions/retrieve-run/retrieve-run.mjs @@ -4,7 +4,7 @@ export default { key: "openai-retrieve-run", name: "Retrieve Run (Assistants)", description: "Retrieves a specific run within a thread. [See the documentation](https://platform.openai.com/docs/api-reference/runs/getRun)", - version: "0.0.13", + version: "0.0.14", type: "action", props: { openai, diff --git a/components/openai/actions/retrieve-vector-store-file/retrieve-vector-store-file.mjs b/components/openai/actions/retrieve-vector-store-file/retrieve-vector-store-file.mjs index d9b0ee491f0f2..69a9b17f792b8 100644 --- a/components/openai/actions/retrieve-vector-store-file/retrieve-vector-store-file.mjs +++ b/components/openai/actions/retrieve-vector-store-file/retrieve-vector-store-file.mjs @@ -4,7 +4,7 @@ export default { key: "openai-retrieve-vector-store-file", name: "Retrieve Vector Store File", description: "Retrieve a vector store file. [See the documentation](https://platform.openai.com/docs/api-reference/vector-stores-files/getFile)", - version: "0.0.3", + version: "0.0.4", type: "action", props: { openai, diff --git a/components/openai/actions/retrieve-vector-store/retrieve-vector-store.mjs b/components/openai/actions/retrieve-vector-store/retrieve-vector-store.mjs index 3330dd9242812..9c412c4db0bed 100644 --- a/components/openai/actions/retrieve-vector-store/retrieve-vector-store.mjs +++ b/components/openai/actions/retrieve-vector-store/retrieve-vector-store.mjs @@ -4,7 +4,7 @@ export default { key: "openai-retrieve-vector-store", name: "Retrieve Vector Store", description: "Retrieve a vector store. [See the documentation](https://platform.openai.com/docs/api-reference/vector-stores/retrieve)", - version: "0.0.3", + version: "0.0.4", type: "action", props: { openai, diff --git a/components/openai/actions/send-prompt/send-prompt.mjs b/components/openai/actions/send-prompt/send-prompt.mjs index 561a2b1a594e6..f08cbfa4beb53 100644 --- a/components/openai/actions/send-prompt/send-prompt.mjs +++ b/components/openai/actions/send-prompt/send-prompt.mjs @@ -4,7 +4,7 @@ import common from "../common/common.mjs"; export default { ...common, name: "Create Completion (Send Prompt)", - version: "0.1.15", + version: "0.1.16", key: "openai-send-prompt", 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)", type: "action", diff --git a/components/openai/actions/submit-tool-outputs-to-run/submit-tool-outputs-to-run.mjs b/components/openai/actions/submit-tool-outputs-to-run/submit-tool-outputs-to-run.mjs index 88d5fa38085fb..7c4fca7b0cd8c 100644 --- a/components/openai/actions/submit-tool-outputs-to-run/submit-tool-outputs-to-run.mjs +++ b/components/openai/actions/submit-tool-outputs-to-run/submit-tool-outputs-to-run.mjs @@ -5,7 +5,7 @@ export default { key: "openai-submit-tool-outputs-to-run", name: "Submit Tool Outputs to Run (Assistants)", description: "Submits tool outputs to a run that requires action. [See the documentation](https://platform.openai.com/docs/api-reference/runs/submitToolOutputs)", - version: "0.0.13", + version: "0.0.14", type: "action", props: { openai, diff --git a/components/openai/actions/summarize/summarize.mjs b/components/openai/actions/summarize/summarize.mjs index 7b27e33e278e2..54a4a6754c6a9 100644 --- a/components/openai/actions/summarize/summarize.mjs +++ b/components/openai/actions/summarize/summarize.mjs @@ -4,7 +4,7 @@ import constants from "../../common/constants.mjs"; export default { ...common, name: "Summarize Text", - version: "0.1.4", + version: "0.1.5", key: "openai-summarize", description: "Summarizes text using the Chat API. [See the documentation](https://platform.openai.com/docs/api-reference/chat)", type: "action", diff --git a/components/openai/actions/translate-text/translate-text.mjs b/components/openai/actions/translate-text/translate-text.mjs index 406d8901d777e..fbc48f3e7fdbf 100644 --- a/components/openai/actions/translate-text/translate-text.mjs +++ b/components/openai/actions/translate-text/translate-text.mjs @@ -9,7 +9,7 @@ const langOptions = lang.LANGUAGES.map((l) => ({ export default { ...common, name: "Translate Text (Whisper)", - version: "0.1.4", + version: "0.1.5", key: "openai-translate-text", description: "Translate text from one language to another using the Chat API. [See the documentation](https://platform.openai.com/docs/api-reference/chat)", type: "action", diff --git a/components/openai/actions/upload-file/upload-file.mjs b/components/openai/actions/upload-file/upload-file.mjs index fc7d68bdd7b0d..a200766871842 100644 --- a/components/openai/actions/upload-file/upload-file.mjs +++ b/components/openai/actions/upload-file/upload-file.mjs @@ -6,7 +6,7 @@ export default { key: "openai-upload-file", name: "Upload File", 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)", - version: "0.0.16", + version: "0.0.17", type: "action", props: { openai, diff --git a/components/openai/package.json b/components/openai/package.json index 12c47625d4832..4531001c3f437 100644 --- a/components/openai/package.json +++ b/components/openai/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/openai", - "version": "0.8.1", + "version": "0.9.0", "description": "Pipedream OpenAI Components", "main": "openai.app.mjs", "keywords": [ diff --git a/components/openai/sources/new-batch-completed/new-batch-completed.mjs b/components/openai/sources/new-batch-completed/new-batch-completed.mjs index b644f4e6d9678..97270cf42f502 100644 --- a/components/openai/sources/new-batch-completed/new-batch-completed.mjs +++ b/components/openai/sources/new-batch-completed/new-batch-completed.mjs @@ -6,7 +6,7 @@ export default { key: "openai-new-batch-completed", name: "New Batch Completed", description: "Emit new event when a new batch is completed in OpenAI. [See the documentation](https://platform.openai.com/docs/api-reference/batch/list)", - version: "0.0.7", + version: "0.0.8", type: "source", dedupe: "unique", methods: { diff --git a/components/openai/sources/new-file-created/new-file-created.mjs b/components/openai/sources/new-file-created/new-file-created.mjs index 069f8409e265e..42800ca5e77cd 100644 --- a/components/openai/sources/new-file-created/new-file-created.mjs +++ b/components/openai/sources/new-file-created/new-file-created.mjs @@ -6,7 +6,7 @@ export default { key: "openai-new-file-created", name: "New File Created", description: "Emit new event when a new file is created in OpenAI. [See the documentation](https://platform.openai.com/docs/api-reference/files/list)", - version: "0.0.12", + version: "0.0.13", type: "source", dedupe: "unique", props: { diff --git a/components/openai/sources/new-fine-tuning-job-created/new-fine-tuning-job-created.mjs b/components/openai/sources/new-fine-tuning-job-created/new-fine-tuning-job-created.mjs index 8c0649f1a5729..0933ed88ae49f 100644 --- a/components/openai/sources/new-fine-tuning-job-created/new-fine-tuning-job-created.mjs +++ b/components/openai/sources/new-fine-tuning-job-created/new-fine-tuning-job-created.mjs @@ -6,7 +6,7 @@ export default { key: "openai-new-fine-tuning-job-created", name: "New Fine Tuning Job Created", 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)", - version: "0.0.12", + version: "0.0.13", type: "source", dedupe: "unique", methods: { diff --git a/components/openai/sources/new-run-state-changed/new-run-state-changed.mjs b/components/openai/sources/new-run-state-changed/new-run-state-changed.mjs index add3270a5b8b2..cc688d31c7430 100644 --- a/components/openai/sources/new-run-state-changed/new-run-state-changed.mjs +++ b/components/openai/sources/new-run-state-changed/new-run-state-changed.mjs @@ -6,7 +6,7 @@ export default { key: "openai-new-run-state-changed", name: "New Run State Changed", description: "Emit new event every time a run changes its status. [See the documentation](https://platform.openai.com/docs/api-reference/runs/listRuns)", - version: "0.0.8", + version: "0.0.9", type: "source", dedupe: "unique", props: { From ff384b2c736b77e35307896e09df073899564644 Mon Sep 17 00:00:00 2001 From: Andrew Chuang Date: Wed, 12 Mar 2025 11:50:34 -0300 Subject: [PATCH 13/16] add json schema to request --- .../chat-using-file-search/chat-using-file-search.mjs | 11 ++++++++++- .../chat-using-functions/chat-using-functions.mjs | 11 ++++++++++- .../chat-using-web-search/chat-using-web-search.mjs | 11 ++++++++++- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/components/openai/actions/chat-using-file-search/chat-using-file-search.mjs b/components/openai/actions/chat-using-file-search/chat-using-file-search.mjs index 5c9b249bb7eb1..6d62791623fae 100644 --- a/components/openai/actions/chat-using-file-search/chat-using-file-search.mjs +++ b/components/openai/actions/chat-using-file-search/chat-using-file-search.mjs @@ -145,7 +145,7 @@ export default { props.jsonSchema = { type: "string", label: "JSON Schema", - description: "Define the schema that the model's output must adhere to. [See the documentation here](https://platform.openai.com/docs/guides/structured-outputs/supported-schemas).", + 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).", }; } @@ -201,6 +201,15 @@ export default { }; } + if (this.responseFormat === constants.CHAT_RESPONSE_FORMAT.JSON_SCHEMA.value) { + data.text = { + format: { + type: this.responseFormat, + ...JSON.parse(this.jsonSchema), + }, + }; + } + const response = await this.openai.responses({ $, data, diff --git a/components/openai/actions/chat-using-functions/chat-using-functions.mjs b/components/openai/actions/chat-using-functions/chat-using-functions.mjs index e7aa008492181..30300b1b3751b 100644 --- a/components/openai/actions/chat-using-functions/chat-using-functions.mjs +++ b/components/openai/actions/chat-using-functions/chat-using-functions.mjs @@ -166,7 +166,7 @@ export default { props.jsonSchema = { type: "string", label: "JSON Schema", - description: "Define the schema that the model's output must adhere to. [See the documentation here](https://platform.openai.com/docs/guides/structured-outputs/supported-schemas).", + 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).", }; } @@ -227,6 +227,15 @@ export default { }; } + if (this.responseFormat === constants.CHAT_RESPONSE_FORMAT.JSON_SCHEMA.value) { + data.text = { + format: { + type: this.responseFormat, + ...JSON.parse(this.jsonSchema), + }, + }; + } + const response = await this.openai.responses({ $, data, diff --git a/components/openai/actions/chat-using-web-search/chat-using-web-search.mjs b/components/openai/actions/chat-using-web-search/chat-using-web-search.mjs index 5ec38d592b6f4..687481c1410ea 100644 --- a/components/openai/actions/chat-using-web-search/chat-using-web-search.mjs +++ b/components/openai/actions/chat-using-web-search/chat-using-web-search.mjs @@ -136,7 +136,7 @@ export default { props.jsonSchema = { type: "string", label: "JSON Schema", - description: "Define the schema that the model's output must adhere to. [See the documentation here](https://platform.openai.com/docs/guides/structured-outputs/supported-schemas).", + 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).", }; } @@ -172,6 +172,15 @@ export default { ], }; + if (this.responseFormat === constants.CHAT_RESPONSE_FORMAT.JSON_SCHEMA.value) { + data.text = { + format: { + type: this.responseFormat, + ...JSON.parse(this.jsonSchema), + }, + }; + } + const response = await this.openai.responses({ $, data, From 3523ba08a1fcaad516f5fa42817f9b7518ecb4bc Mon Sep 17 00:00:00 2001 From: Andrew Chuang Date: Wed, 12 Mar 2025 11:58:23 -0300 Subject: [PATCH 14/16] fix description --- .../actions/chat-using-functions/chat-using-functions.mjs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/components/openai/actions/chat-using-functions/chat-using-functions.mjs b/components/openai/actions/chat-using-functions/chat-using-functions.mjs index 30300b1b3751b..5d6ab79128e99 100644 --- a/components/openai/actions/chat-using-functions/chat-using-functions.mjs +++ b/components/openai/actions/chat-using-functions/chat-using-functions.mjs @@ -73,11 +73,7 @@ export default { toolChoice: { type: "string", label: "Tool Choice", - // TODO: fix markdown display - description: `Determines how the model will use tools: - - **auto**: The model decides whether and how many tools to call. - - **required**: The model must call one or more tools. - - **function_name**: Write the function name as a custom expression to force the model call this function.`, + 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.", optional: true, default: "auto", options: [ From 35d1467f966c8bbe7e503fbce7b1297254fda616 Mon Sep 17 00:00:00 2001 From: Andrew Chuang Date: Wed, 12 Mar 2025 12:05:12 -0300 Subject: [PATCH 15/16] add try catch to json parse --- .../chat-using-file-search.mjs | 16 +++++++++----- .../chat-using-functions.mjs | 22 +++++++++++++------ .../chat-using-web-search.mjs | 16 +++++++++----- 3 files changed, 35 insertions(+), 19 deletions(-) diff --git a/components/openai/actions/chat-using-file-search/chat-using-file-search.mjs b/components/openai/actions/chat-using-file-search/chat-using-file-search.mjs index 6d62791623fae..f949d930b41e8 100644 --- a/components/openai/actions/chat-using-file-search/chat-using-file-search.mjs +++ b/components/openai/actions/chat-using-file-search/chat-using-file-search.mjs @@ -202,12 +202,16 @@ export default { } if (this.responseFormat === constants.CHAT_RESPONSE_FORMAT.JSON_SCHEMA.value) { - data.text = { - format: { - type: this.responseFormat, - ...JSON.parse(this.jsonSchema), - }, - }; + try { + data.text = { + format: { + type: this.responseFormat, + ...JSON.parse(this.jsonSchema), + }, + }; + } catch (error) { + throw new Error("Invalid JSON format in the provided JSON Schema"); + } } const response = await this.openai.responses({ diff --git a/components/openai/actions/chat-using-functions/chat-using-functions.mjs b/components/openai/actions/chat-using-functions/chat-using-functions.mjs index 5d6ab79128e99..b38674ef95f0f 100644 --- a/components/openai/actions/chat-using-functions/chat-using-functions.mjs +++ b/components/openai/actions/chat-using-functions/chat-using-functions.mjs @@ -189,7 +189,11 @@ export default { let functions = this.functions; if (typeof functions === "string") { - functions = JSON.parse(functions); + try { + functions = JSON.parse(functions); + } catch (error) { + throw new Error("Invalid JSON format in the provided Functions Schema"); + } } if (Array.isArray(functions)) { @@ -224,12 +228,16 @@ export default { } if (this.responseFormat === constants.CHAT_RESPONSE_FORMAT.JSON_SCHEMA.value) { - data.text = { - format: { - type: this.responseFormat, - ...JSON.parse(this.jsonSchema), - }, - }; + try { + data.text = { + format: { + type: this.responseFormat, + ...JSON.parse(this.jsonSchema), + }, + }; + } catch (error) { + throw new Error("Invalid JSON format in the provided JSON Schema"); + } } const response = await this.openai.responses({ diff --git a/components/openai/actions/chat-using-web-search/chat-using-web-search.mjs b/components/openai/actions/chat-using-web-search/chat-using-web-search.mjs index 687481c1410ea..50028bf3c558d 100644 --- a/components/openai/actions/chat-using-web-search/chat-using-web-search.mjs +++ b/components/openai/actions/chat-using-web-search/chat-using-web-search.mjs @@ -173,12 +173,16 @@ export default { }; if (this.responseFormat === constants.CHAT_RESPONSE_FORMAT.JSON_SCHEMA.value) { - data.text = { - format: { - type: this.responseFormat, - ...JSON.parse(this.jsonSchema), - }, - }; + try { + data.text = { + format: { + type: this.responseFormat, + ...JSON.parse(this.jsonSchema), + }, + }; + } catch (error) { + throw new Error("Invalid JSON format in the provided JSON Schema"); + } } const response = await this.openai.responses({ From 82c914db65f95d8c10779bd7b5dca7d1f92c5882 Mon Sep 17 00:00:00 2001 From: Andrew Chuang Date: Wed, 12 Mar 2025 12:17:04 -0300 Subject: [PATCH 16/16] add chat_responses output --- .../actions/chat-using-file-search/chat-using-file-search.mjs | 1 + .../openai/actions/chat-using-functions/chat-using-functions.mjs | 1 + .../actions/chat-using-web-search/chat-using-web-search.mjs | 1 + 3 files changed, 3 insertions(+) diff --git a/components/openai/actions/chat-using-file-search/chat-using-file-search.mjs b/components/openai/actions/chat-using-file-search/chat-using-file-search.mjs index f949d930b41e8..25f92202a5ca5 100644 --- a/components/openai/actions/chat-using-file-search/chat-using-file-search.mjs +++ b/components/openai/actions/chat-using-file-search/chat-using-file-search.mjs @@ -221,6 +221,7 @@ export default { if (response) { $.export("$summary", `Successfully sent chat with id ${response.id}`); + $.export("chat_responses", response.output); } return response; diff --git a/components/openai/actions/chat-using-functions/chat-using-functions.mjs b/components/openai/actions/chat-using-functions/chat-using-functions.mjs index b38674ef95f0f..5a8ee3091f9bc 100644 --- a/components/openai/actions/chat-using-functions/chat-using-functions.mjs +++ b/components/openai/actions/chat-using-functions/chat-using-functions.mjs @@ -247,6 +247,7 @@ export default { if (response) { $.export("$summary", `Successfully sent chat with id ${response.id}`); + $.export("chat_responses", response.output); } return response; diff --git a/components/openai/actions/chat-using-web-search/chat-using-web-search.mjs b/components/openai/actions/chat-using-web-search/chat-using-web-search.mjs index 50028bf3c558d..b05befd915d9e 100644 --- a/components/openai/actions/chat-using-web-search/chat-using-web-search.mjs +++ b/components/openai/actions/chat-using-web-search/chat-using-web-search.mjs @@ -192,6 +192,7 @@ export default { if (response) { $.export("$summary", `Successfully sent chat with id ${response.id}`); + $.export("chat_responses", response.output); } return response;