Skip to content

[Components] speak_ai - new components #16256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions components/speak_ai/actions/analyze-text/analyze-text.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import app from "../../speak_ai.app.mjs";

export default {
key: "speak_ai-analyze-text",
name: "Analyze Text",
description: "Analyzes a block of text for key insights, sentiment, and keyword extraction using Speak Ai's NLP engine. [See the documentation](https://docs.speakai.co/#d65573c9-98ad-4089-93ad-9d0a173fdeea).",
version: "0.0.1",
type: "action",
props: {
app,
folderId: {
propDefinition: [
app,
"folderId",
],
},
mediaId: {
propDefinition: [
app,
"mediaId",
({ folderId }) => ({
folderId,
mediaType: "text",
}),
],
},
},
async run({ $ }) {
const {
app,
mediaId,
} = this;

const response = await app.getTextInsight({
$,
mediaId,
});

$.export("$summary", `Successfully analyzed text with ID \`${response.data.mediaId}\`.`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import app from "../../speak_ai.app.mjs";

export default {
key: "speak_ai-get-transcription",
name: "Get Transcription",
description: "Retrieve the full transcription of a processed media file. [See the documentation](https://docs.speakai.co/#0b586e5b-6e0a-4b79-b440-e6889a803ccd).",
version: "0.0.1",
type: "action",
props: {
app,
folderId: {
propDefinition: [
app,
"folderId",
],
},
mediaId: {
propDefinition: [
app,
"mediaId",
({ folderId }) => ({
folderId,
}),
],
},
},
async run({ $ }) {
const {
app,
mediaId,
} = this;

const response = await app.getInsight({
$,
mediaId,
});

$.export("$summary", `Successfully retrieved transcription for media ID \`${response.data.mediaId}\`.`);
return response.data.insight.transcript;
},
};
82 changes: 82 additions & 0 deletions components/speak_ai/actions/upload-media/upload-media.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import app from "../../speak_ai.app.mjs";

export default {
key: "speak_ai-upload-media",
name: "Upload Media",
description: "Upload an audio or video file for transcription and natural language processing into Speak AI. [See the documentation](https://docs.speakai.co/#c6106a66-6a3d-4b05-b4a2-4a68a4c1e95d).",
version: "0.0.1",
type: "action",
props: {
app,
name: {
type: "string",
label: "Name",
description: "Name of the media file",
},
url: {
type: "string",
label: "URL",
description: "Public URL or AWS signed URL",
},
mediaType: {
propDefinition: [
app,
"mediaType",
],
},
folderId: {
propDefinition: [
app,
"folderId",
],
},
description: {
type: "string",
label: "Description",
description: "Description of the media file",
optional: true,
},
tags: {
type: "string[]",
label: "Tags",
description: "Optional metadata tags for the media file upload",
optional: true,
},
},
methods: {
uploadMedia(args = {}) {
return this.app.post({
path: "/media/upload",
...args,
});
},
},
async run({ $ }) {
const {
uploadMedia,
name,
url,
mediaType,
folderId,
description,
tags,
} = this;

const response = await uploadMedia({
$,
data: {
name,
url,
mediaType,
folderId,
description,
tags: Array.isArray(tags)
? tags.join(",")
: tags,
},
});

$.export("$summary", `Successfully uploaded media with ID \`${response.data.mediaId}\`.`);
return response;
},
};
13 changes: 13 additions & 0 deletions components/speak_ai/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const BASE_URL = "https://api.speakai.co";
const VERSION_PATH = "/v1";

const DEFAULT_LIMIT = 50;

const WEBHOOK_ID = "webhookId";

export default {
BASE_URL,
VERSION_PATH,
DEFAULT_LIMIT,
WEBHOOK_ID,
};
7 changes: 5 additions & 2 deletions components/speak_ai/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/speak_ai",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Speak AI Components",
"main": "speak_ai.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.3"
}
}
}
18 changes: 18 additions & 0 deletions components/speak_ai/sources/common/events.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export default {
MEDIA_CREATED: "media.created",
MEDIA_ANALYZED: "media.analyzed",
MEDIA_REANALYZED: "media.reanalyzed",
MEDIA_FAILED: "media.failed",
TEXT_CREATED: "text.created",
TEXT_ANALYZED: "text.analyzed",
TEXT_REANALYZED: "text.reanalyzed",
TEXT_FAILED: "text.failed",
TEXT_DELETED: "text.deleted",
EMBED_RECORDER_CREATED: "embed_recorder.created",
EMBED_RECORDER_DELETED: "embed_recorder.deleted",
EMBED_RECORDER_RECORDING_RECEIVED: "embed_recorder.recording_received",
MEETING_ASSISTANT_STATUS: "meeting_assistant.status",
CHAT_STATUS: "chat.status",
CSV_UPLOADED: "csv.uploaded",
CSV_FAILED: "csv.failed",
};
87 changes: 87 additions & 0 deletions components/speak_ai/sources/common/webhook.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import { ConfigurationError } from "@pipedream/platform";
import app from "../../speak_ai.app.mjs";
import constants from "../../common/constants.mjs";

export default {
props: {
app,
db: "$.service.db",
http: "$.interface.http",
},
hooks: {
async activate() {
const {
http: { endpoint: callbackUrl },
createWebhook,
getEvents,
setWebhookId,
} = this;

const response =
await createWebhook({
data: {
callbackUrl,
events: getEvents(),
},
});

setWebhookId(response.data.webhookId);
},
async deactivate() {
const {
deleteWebhook,
getWebhookId,
} = this;

const webhookId = getWebhookId();
if (webhookId) {
await deleteWebhook({
webhookId,
});
}
},
},
methods: {
generateMeta() {
throw new ConfigurationError("generateMeta is not implemented");
},
setWebhookId(value) {
this.db.set(constants.WEBHOOK_ID, value);
},
getWebhookId() {
return this.db.get(constants.WEBHOOK_ID);
},
getEvents() {
throw new ConfigurationError("getEvents is not implemented");
},
async getData(resource) {
return resource;
},
async processResource(resource) {
const data = await this.getData(resource);
this.$emit({
...resource,
data,
}, this.generateMeta(resource));
},
createWebhook(args = {}) {
return this.app.post({
debug: true,
path: "/webhook",
...args,
});
},
deleteWebhook({
webhookId, ...args
} = {}) {
return this.app.delete({
debug: true,
path: `/webhook/${webhookId}`,
...args,
});
},
},
async run({ body }) {
await this.processResource(body);
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import common from "../common/webhook.mjs";
import events from "../common/events.mjs";
import sampleEmit from "./test-event.mjs";

export default {
...common,
key: "speak_ai-new-media-created-instant",
name: "New Media Created (Instant)",
description: "Emit new event when a new media file is created. Useful for initiating workflows based on new media intake. [See the documentation](https://docs.speakai.co/#5777a89c-a6c3-4d0e-aab1-d33fdec5cbe8).",
version: "0.0.1",
type: "source",
dedupe: "unique",
methods: {
...common.methods,
getEvents() {
return [
events.MEDIA_CREATED,
];
},
async getData(resource) {
const { data } = await this.app.getInsight({
mediaId: resource.mediaId,
});
return data;
},
generateMeta(resource) {
return {
id: resource.mediaId,
summary: `New Media Created: ${resource.mediaId}`,
ts: Date.now(),
};
},
},
sampleEmit,
};
Loading
Loading