Skip to content

Commit 3f13dc0

Browse files
committed
accept audio input
1 parent 4feefb4 commit 3f13dc0

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

components/openai/actions/chat/chat.mjs

Lines changed: 8 additions & 2 deletions
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.2.0",
8+
version: "0.2.1",
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",
@@ -38,7 +38,13 @@ export default {
3838
images: {
3939
label: "Images",
4040
type: "string[]",
41-
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`",
41+
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",
42+
optional: true,
43+
},
44+
audio: {
45+
type: "string",
46+
label: "Audio",
47+
description: "Provide the file path to an audio file in the `/tmp` directory. Compatible with the `gpt-4o-audio-preview` model. Currently supports `wav` and `mp3` files.",
4248
optional: true,
4349
},
4450
responseFormat: {

components/openai/actions/common/common.mjs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { ConfigurationError } from "@pipedream/platform";
22
import constants from "../../common/constants.mjs";
33
import { parse } from "../../common/helpers.mjs";
4+
import fs from "fs";
45

56
const CHAT_DOCS_MESSAGE_FORMAT_URL = "https://platform.openai.com/docs/guides/chat/introduction";
67

@@ -92,6 +93,20 @@ export default {
9293
}
9394
}
9495

96+
if (this.audio) {
97+
const fileContent = fs.readFileSync(this.audio.includes("tmp/")
98+
? this.audio
99+
: `/tmp/${this.audio}`).toString("base64");
100+
const extension = this.audio.match(/\.(\w+)$/)?.[1];
101+
content.push({
102+
type: "input_audio",
103+
input_audio: {
104+
data: fileContent,
105+
format: extension,
106+
},
107+
});
108+
}
109+
95110
content.push({
96111
"type": "text",
97112
"text": this.userMessage,

components/openai/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/openai",
3-
"version": "0.6.0",
3+
"version": "0.6.1",
44
"description": "Pipedream OpenAI Components",
55
"main": "openai.app.mjs",
66
"keywords": [

0 commit comments

Comments
 (0)