Skip to content

Commit ecaedb2

Browse files
luancazarinecoderabbitai[bot]michelle0927
authored
New Components - hamsa (#16226)
* hamsa init * [Components] hamsa #16189 Actions - Transcribe Video - Create Content - Synthethize Voice * pnpm update * fix action key * some adjsuts and added List Jobs action * Update components/hamsa/actions/list-jobs/list-jobs.mjs Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * fix synthesize spelling * some adjusts * pnpm update --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: michelle0927 <[email protected]>
1 parent c81de5b commit ecaedb2

File tree

10 files changed

+409
-9
lines changed

10 files changed

+409
-9
lines changed

components/facebook_graph_api/facebook_graph_api.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};

components/gather/gather.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { AI_PARTS_OPTIONS } from "../../common/constants.mjs";
2+
import hamsa from "../../hamsa.app.mjs";
3+
4+
export default {
5+
key: "hamsa-create-content",
6+
name: "Create AI Content",
7+
description: "Transform transcribed content into various formats for content marketing. [See the documentation](https://docs.tryhamsa.com/api-reference/endpoint/post-ai-content)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
hamsa,
12+
jobId: {
13+
propDefinition: [
14+
hamsa,
15+
"jobId",
16+
],
17+
},
18+
aiParts: {
19+
type: "string[]",
20+
label: "AI Parts",
21+
description: "Parts for AI content in marketing.",
22+
options: AI_PARTS_OPTIONS,
23+
},
24+
},
25+
async run({ $ }) {
26+
const response = await this.hamsa.createAIContent({
27+
$,
28+
params: {
29+
jobId: this.jobId,
30+
},
31+
data: {
32+
aiParts: this.aiParts,
33+
},
34+
});
35+
36+
$.export("$summary", `AI content creation job created with ID: ${response.data.id}`);
37+
38+
return response;
39+
},
40+
};
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import hamsa from "../../hamsa.app.mjs";
2+
3+
export default {
4+
key: "hamsa-list-jobs",
5+
name: "List Jobs",
6+
description: "Fetch the list of jobs from Hamsa. [See the documentation](https://docs.tryhamsa.com/api-reference/endpoint/get-jobs-list)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
hamsa,
11+
},
12+
async run({ $ }) {
13+
const response = await this.hamsa.listJobs({
14+
$,
15+
});
16+
17+
$.export("$summary", `Successfully fetched ${response?.data?.jobs?.length} jobs.`);
18+
19+
return response;
20+
},
21+
};
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import hamsa from "../../hamsa.app.mjs";
2+
3+
export default {
4+
key: "hamsa-synthesize-voice",
5+
name: "Synthesize Voice",
6+
description: "Converts text input into artificial speech using Hamsa. [See the documentation](https://docs.tryhamsa.com/api-reference/endpoint/generate-tts)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
hamsa,
11+
voiceId: {
12+
propDefinition: [
13+
hamsa,
14+
"voiceId",
15+
],
16+
},
17+
text: {
18+
type: "string",
19+
label: "Text for TTS",
20+
description: "The text you want to convert to speech. Minimum 5 words required.",
21+
},
22+
webhookUrl: {
23+
propDefinition: [
24+
hamsa,
25+
"webhookUrl",
26+
],
27+
optional: true,
28+
},
29+
webhookAuthKey: {
30+
type: "string",
31+
label: "Webhook Auth Key",
32+
description: "Authorization key for the webhook notifications.",
33+
optional: true,
34+
},
35+
webhookAuthSecret: {
36+
type: "string",
37+
label: "Webhook Auth Secret",
38+
description: "Authorization secret for the webhook notifications.",
39+
optional: true,
40+
},
41+
},
42+
async run({ $ }) {
43+
const webhookAuth = {};
44+
if (this.webhookAuthKey) {
45+
webhookAuth.authKey = this.webhookAuthKey;
46+
}
47+
if (this.webhookAuthSecret) {
48+
webhookAuth.authSecret = this.webhookAuthSecret;
49+
}
50+
const data = {
51+
voiceId: this.voiceId,
52+
text: this.text,
53+
webhookUrl: this.webhookUrl,
54+
};
55+
if (Object.keys(webhookAuth).length) {
56+
data.webhookAuth = webhookAuth;
57+
}
58+
const response = await this.hamsa.generateTTS({
59+
$,
60+
data,
61+
});
62+
63+
$.export("$summary", `Text to speech job successfully created with ID ${response.data.id}`);
64+
return response;
65+
},
66+
};
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
import {
2+
LANGUAGE_OPTIONS,
3+
MODEL_OPTIONS,
4+
} from "../../common/constants.mjs";
5+
import hamsa from "../../hamsa.app.mjs";
6+
7+
export default {
8+
key: "hamsa-transcribe-video",
9+
name: "Transcribe Video",
10+
description: "Automatically transcribe Arabic videos from YouTube URLs or direct links. [See the documentation](https://docs.tryhamsa.com/api-reference/endpoint/transcribe)",
11+
version: "0.0.1",
12+
type: "action",
13+
props: {
14+
hamsa,
15+
mediaUrl: {
16+
type: "string",
17+
label: "Media URL",
18+
description: "The URL of the video to be transcribed.",
19+
},
20+
model: {
21+
type: "string",
22+
label: "Model",
23+
description: "The model you want to use to transcribe.",
24+
options: MODEL_OPTIONS,
25+
},
26+
webhookUrl: {
27+
propDefinition: [
28+
hamsa,
29+
"webhookUrl",
30+
],
31+
optional: true,
32+
},
33+
webhookAuthKey: {
34+
type: "string",
35+
label: "Webhook Auth Key",
36+
description: "The key to use for authenticating the webhook.",
37+
optional: true,
38+
},
39+
webhookAuthSecret: {
40+
type: "string",
41+
label: "Webhook Auth Secret",
42+
description: "The secret to use for authenticating the webhook.",
43+
secret: true,
44+
optional: true,
45+
},
46+
title: {
47+
type: "string",
48+
label: "Title",
49+
description: "The title of the transcription.",
50+
optional: true,
51+
},
52+
language: {
53+
type: "string",
54+
label: "Language",
55+
description: "The language of the transcription.",
56+
options: LANGUAGE_OPTIONS,
57+
optional: true,
58+
},
59+
},
60+
async run({ $ }) {
61+
const webhookAuth = {};
62+
if (this.webhookAuthKey) {
63+
webhookAuth.authKey = this.webhookAuthKey;
64+
}
65+
if (this.webhookAuthSecret) {
66+
webhookAuth.authSecret = this.webhookAuthSecret;
67+
}
68+
const data = {
69+
mediaUrl: this.mediaUrl,
70+
model: this.model,
71+
processingType: "async",
72+
webhookUrl: this.webhookUrl,
73+
title: this.title,
74+
language: this.language,
75+
};
76+
if (Object.keys(webhookAuth).length) {
77+
data.webhookAuth = webhookAuth;
78+
}
79+
80+
const response = await this.hamsa.transcribeVideo({
81+
$,
82+
data,
83+
});
84+
85+
$.export("$summary", "Transcription job started successfully.");
86+
return response;
87+
},
88+
};
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
export const LIMIT = 100;
2+
3+
export const MODEL_OPTIONS = [
4+
{
5+
label: "Hamsa-General-V2.0 - Our most advanced ASR model, optimized for high accuracy across podcasts, videos, and general audio.",
6+
value: "Hamsa-General-V2.0",
7+
},
8+
{
9+
label: "Hamsa-Conversational-V1.0 - Best suited for conversational use cases, optimized for accurately transcribing phone calls and meetings.",
10+
value: "Hamsa-Conversational-V1.0",
11+
},
12+
];
13+
14+
export const LANGUAGE_OPTIONS = [
15+
"ar",
16+
"en",
17+
];
18+
19+
export const AI_PARTS_OPTIONS = [
20+
{
21+
label: "Introduction",
22+
value: "introduction",
23+
},
24+
{
25+
label: "Titles",
26+
value: "titles",
27+
},
28+
{
29+
label: "Summary",
30+
value: "summary",
31+
},
32+
{
33+
label: "Web Article SEO Friendly",
34+
value: "webArticleSEOFriendly",
35+
},
36+
{
37+
label: "Key Topics With Bullets",
38+
value: "keyTopicsWithBullets",
39+
},
40+
{
41+
label: "Keywords",
42+
value: "keywords",
43+
},
44+
{
45+
label: "Threads By Instagram",
46+
value: "threadsByInstagram",
47+
},
48+
{
49+
label: "FAQ",
50+
value: "faq",
51+
},
52+
{
53+
label: "Facebook Post",
54+
value: "facebookPost",
55+
},
56+
{
57+
label: "YouTube Description",
58+
value: "youtubeDescription",
59+
},
60+
{
61+
label: "Twitter Thread",
62+
value: "twitterThread",
63+
},
64+
{
65+
label: "LinkedIn Post",
66+
value: "linkedInPost",
67+
},
68+
];

0 commit comments

Comments
 (0)