Skip to content

Commit 478ab4e

Browse files
jeevikasirwanijcortes
authored andcommitted
solves issue #17031
1 parent 4a4c5a2 commit 478ab4e

File tree

13 files changed

+244
-34
lines changed

13 files changed

+244
-34
lines changed

components/openai/actions/chat-using-file-search/chat-using-file-search.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import constants from "../../common/constants.mjs";
55
export default {
66
...common,
77
name: "Chat using File Search",
8-
version: "0.0.5",
8+
version: "0.0.6",
99
key: "openai-chat-using-file-search",
1010
description: "Chat with your files knowledge base (vector stores). [See the documentation](https://platform.openai.com/docs/guides/tools-file-search)",
1111
type: "action",

components/openai/actions/chat-using-functions/chat-using-functions.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import constants from "../../common/constants.mjs";
55
export default {
66
...common,
77
name: "Chat using Functions",
8-
version: "0.0.6",
8+
version: "0.0.7",
99
key: "openai-chat-using-functions",
1010
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)",
1111
type: "action",

components/openai/actions/chat-using-web-search/chat-using-web-search.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import constants from "../../common/constants.mjs";
55
export default {
66
...common,
77
name: "Chat using Web Search",
8-
version: "0.0.5",
8+
version: "0.0.6",
99
key: "openai-chat-using-web-search",
1010
description: "Chat using the web search tool. [See the documentation](https://platform.openai.com/docs/guides/tools-web-search)",
1111
type: "action",
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
import openai from "../../openai.app.mjs";
2+
import common from "../common/common.mjs";
3+
import constants from "../../common/constants.mjs";
4+
import { parseArray } from "../../common/helpers.mjs";
5+
6+
export default {
7+
...common,
8+
key: "openai-chat-with-responses-api",
9+
name: "Chat With Responses API",
10+
version: "0.0.1",
11+
description: "Send a chat via the Responses API, mixing built-in tools and MCP server tools. [See the documentation](https://platform.openai.com/docs/guides/tools?api-mode=responses).",
12+
type: "action",
13+
props: {
14+
openai,
15+
modelId: {
16+
description: "Model used to generate the response",
17+
propDefinition: [
18+
openai,
19+
"chatCompletionModelId",
20+
],
21+
},
22+
input: {
23+
description: "Text input to the model used to generate a response",
24+
propDefinition: [
25+
openai,
26+
"input",
27+
],
28+
},
29+
instructions: {
30+
description: "Inserts a system (or developer) message as the first item in the model's context",
31+
propDefinition: [
32+
openai,
33+
"instructions",
34+
],
35+
},
36+
previousResponseId: {
37+
type: "string",
38+
label: "Previous Response ID",
39+
description: "The unique ID of the previous response to the model. Use this to create multi-turn conversations",
40+
optional: true,
41+
},
42+
truncation: {
43+
type: "string",
44+
label: "Truncation",
45+
description:
46+
"Specifies the truncation mode for the response if it exceeds the context window",
47+
default: "auto",
48+
options: [
49+
"auto",
50+
"disabled",
51+
],
52+
optional: true,
53+
},
54+
responseFormat: {
55+
type: "string",
56+
label: "Response Format",
57+
description: "- `text`: Returns unstructured text output.\n- `json_schema`: Enforces a specific structure using a JSON schema.",
58+
options: [
59+
"text",
60+
"json_schema",
61+
],
62+
default: "text",
63+
optional: true,
64+
reloadProps: true,
65+
},
66+
builtInTools: {
67+
type: "string[]",
68+
label: "Built-In Tools",
69+
description: "Which of OpenAI's first-party tools to enable (web search, file search, code interpreter).",
70+
options: [
71+
{
72+
label: "Web Search",
73+
value: "web_search_preview",
74+
},
75+
{
76+
label: "File Search",
77+
value: "file_search",
78+
},
79+
{
80+
label: "Code Interpreter",
81+
value: "code_interpreter",
82+
},
83+
],
84+
default: [],
85+
},
86+
otherTools: {
87+
type: "string[]",
88+
label: "Other Tools",
89+
description: "Other tools to include in the chat. [See the documentation](https://platform.openai.com/docs/guides/tools-remote-mcp). Example: `{ type: \"mcp\", server_label: \"gmail\", server_url: \"https://remote.mcp.pipedream.net\", headers: {}, require_approval: \"never\" }`",
90+
optional: true,
91+
},
92+
},
93+
additionalProps() {
94+
const props = {};
95+
if (this.responseFormat === constants.CHAT_RESPONSE_FORMAT.JSON_SCHEMA.value) {
96+
props.jsonSchema = {
97+
type: "string",
98+
label: "JSON Schema",
99+
description:
100+
"Define the schema that the model's output must adhere to.",
101+
};
102+
}
103+
return props;
104+
},
105+
async run({ $ }) {
106+
const {
107+
builtInTools,
108+
otherTools,
109+
modelId,
110+
input,
111+
instructions,
112+
previousResponseId,
113+
truncation,
114+
responseFormat,
115+
jsonSchema,
116+
} = this;
117+
118+
const tools = builtInTools.map((tool) => ({
119+
type: tool,
120+
}));
121+
122+
if (otherTools) {
123+
tools.push(...parseArray(otherTools));
124+
}
125+
126+
const data = {
127+
model: modelId,
128+
input,
129+
instructions,
130+
previous_response_id: previousResponseId,
131+
truncation,
132+
tools,
133+
};
134+
135+
if (responseFormat === constants.CHAT_RESPONSE_FORMAT.JSON_SCHEMA.value) {
136+
try {
137+
data.text = {
138+
format: {
139+
type: responseFormat,
140+
...JSON.parse(jsonSchema),
141+
},
142+
};
143+
} catch {
144+
throw new Error("Invalid JSON format in the provided JSON Schema");
145+
}
146+
}
147+
148+
const response = await this.openai.responses({
149+
$,
150+
data,
151+
debug: true,
152+
});
153+
154+
if (response) {
155+
$.export("$summary", `Successfully sent chat to OpenAI Responses API with ID \`${response.id}\`.`);
156+
$.export("chat_responses", response.output);
157+
}
158+
159+
return response;
160+
},
161+
};

components/openai/actions/chat/chat.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import constants from "../../common/constants.mjs";
55
export default {
66
...common,
77
name: "Chat",
8-
version: "0.3.1",
8+
version: "0.3.2",
99
key: "openai-chat",
1010
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)",
1111
type: "action",

components/openai/actions/classify-items-into-categories/classify-items-into-categories.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import common from "../common/common-helper.mjs";
33
export default {
44
...common,
55
name: "Classify Items into Categories",
6-
version: "0.1.7",
6+
version: "0.1.8",
77
key: "openai-classify-items-into-categories",
88
description: "Classify items into specific categories using the Chat API. [See the documentation](https://platform.openai.com/docs/api-reference/chat)",
99
type: "action",

components/openai/actions/create-embeddings/create-embeddings.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import common from "../common/common.mjs";
44

55
export default {
66
name: "Create Embeddings",
7-
version: "0.0.19",
7+
version: "0.0.20",
88
key: "openai-create-embeddings",
99
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)",
1010
type: "action",

components/openai/actions/send-prompt/send-prompt.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import common from "../common/common.mjs";
44
export default {
55
...common,
66
name: "Create Completion (Send Prompt)",
7-
version: "0.1.18",
7+
version: "0.1.19",
88
key: "openai-send-prompt",
99
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)",
1010
type: "action",

components/openai/actions/summarize/summarize.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import constants from "../../common/constants.mjs";
44
export default {
55
...common,
66
name: "Summarize Text",
7-
version: "0.1.7",
7+
version: "0.1.8",
88
key: "openai-summarize",
99
description: "Summarizes text using the Chat API. [See the documentation](https://platform.openai.com/docs/api-reference/chat)",
1010
type: "action",

components/openai/actions/translate-text/translate-text.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const langOptions = lang.LANGUAGES.map((l) => ({
99
export default {
1010
...common,
1111
name: "Translate Text (Whisper)",
12-
version: "0.1.7",
12+
version: "0.1.8",
1313
key: "openai-translate-text",
1414
description: "Translate text from one language to another using the Chat API. [See the documentation](https://platform.openai.com/docs/api-reference/chat)",
1515
type: "action",

0 commit comments

Comments
 (0)