Skip to content
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

[Components] Easy Peasy AI: Added new action components #14190

Merged
merged 1 commit into from
Oct 3, 2024
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import app from "../../easy_peasy_ai.app.mjs";

export default {
key: "easy_peasy_ai-create-transcription",
name: "Create Transcription",
description: "Generates AI transcription for a given audio URL. [See the documentation](https://easy-peasy.ai/audios)",
version: "0.0.1",
type: "action",
props: {
app,
url: {
type: "string",
label: "Audio URL",
description: "The URL of the audio file to transcribe.",
},
audioType: {
type: "string",
label: "Audio Type",
description: "The type of the audio file. Eg. `podcast`, `meeting`.",
optional: true,
},
GTFalcao marked this conversation as resolved.
Show resolved Hide resolved
language: {
description: "The language of the audio E.g. `English`, `Chinese`, `French`.",
propDefinition: [
app,
"language",
],
},
GTFalcao marked this conversation as resolved.
Show resolved Hide resolved
name: {
type: "string",
label: "Name",
description: "The name of the transcription.",
optional: true,
},
detectSpeakers: {
type: "boolean",
label: "Detect Speakers",
description: "Whether to detect multiple speakers.",
optional: true,
},
enhanceQuality: {
type: "boolean",
label: "Enhance Quality",
description: "Whether to use enhanced quality for transcription.",
optional: true,
},
},
methods: {
generateTranscription(args = {}) {
return this.app.post({
path: "/transcriptions",
...args,
});
},
},
async run({ $ }) {
const {
generateTranscription,
url,
audioType,
language,
name,
detectSpeakers,
enhanceQuality,
} = this;

const response = await generateTranscription({
$,
data: {
url,
audio_type: audioType,
language,
name,
detect_speakers: detectSpeakers,
enhance_quality: enhanceQuality,
},
});
$.export("$summary", `Successfully created a transcription with ID \`${response.uuid}\`.`);
return response;
},
GTFalcao marked this conversation as resolved.
Show resolved Hide resolved
};
93 changes: 93 additions & 0 deletions components/easy_peasy_ai/actions/generate-image/generate-image.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import app from "../../easy_peasy_ai.app.mjs";

export default {
key: "easy_peasy_ai-generate-image",
name: "Generate Image",
description: "Generates an AI image based on the given prompt. [See the documentation](https://easy-peasy.ai/ai-images)",
version: "0.0.1",
type: "action",
props: {
app,
prompt: {
type: "string",
label: "Prompt",
description: "The textual description of the image to be generated. Eg. `A cat sitting on a chair`.",
},
model: {
type: "string",
label: "Model",
description: "The model to use for image generation.",
options: [
"DALL-E 3",
"Stable Diffusion XL",
"Stable Diffusion 3.0",
],
},
style: {
type: "string",
label: "Style",
description: "The style of the generated image.",
optional: true,
},
artist: {
type: "string",
label: "Artist",
description: "The artist of the generated image.",
optional: true,
},
dimensions: {
type: "string",
label: "Dimensions",
description: "The dimensions of the generated image. Eg. `512x512`.",
optional: true,
},
GTFalcao marked this conversation as resolved.
Show resolved Hide resolved
useHD: {
type: "boolean",
label: "Use HD",
description: "Use high-definition image generation?",
optional: true,
},
image: {
type: "string",
label: "Image",
description: "Image URL for Image-to-Image generations.",
optional: true,
},
},
methods: {
generateImage(args = {}) {
return this.app.post({
path: "/generate-image",
...args,
});
},
},
async run({ $ }) {
const {
generateImage,
prompt,
model,
style,
artist,
dimensions,
useHD,
image,
} = this;

const response = await generateImage({
$,
data: {
prompt,
model,
style,
artist,
dimensions,
useHD,
image,
},
});
GTFalcao marked this conversation as resolved.
Show resolved Hide resolved

$.export("$summary", "Successfully generated an image.");
return response;
},
GTFalcao marked this conversation as resolved.
Show resolved Hide resolved
};
GTFalcao marked this conversation as resolved.
Show resolved Hide resolved
105 changes: 105 additions & 0 deletions components/easy_peasy_ai/actions/generate-text/generate-text.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import app from "../../easy_peasy_ai.app.mjs";
import constants from "../../common/constants.mjs";

export default {
key: "easy_peasy_ai-generate-text",
name: "Generate Text",
description: "Generates text outputs for the templates. [See the documentation](https://easy-peasy.ai/presets)",
version: "0.0.1",
type: "action",
props: {
app,
preset: {
type: "string",
label: "Template",
description: "The template name to use for generating content.",
options: constants.TEMPLATES,
},
keywords: {
type: "string",
label: "Keywords",
description: "Keywords to use for generating content. Eg. `Write an email to potential investors about my startup`. (maxlength: 1000)",
},
jcortes marked this conversation as resolved.
Show resolved Hide resolved
tone: {
type: "string",
label: "Tone",
description: "The tone of the generated content. Eg. `friendly, funny, cheerful`.",
optional: true,
},
extra1: {
type: "string",
label: "Extra 1",
description: "Background Information (maxlength: 1000). Eg. `I am a software engineer`.",
optional: true,
},
extra2: {
type: "string",
label: "Extra 2",
description: "Background Information (maxlength: 1000). Eg. `I am starting a new business`.",
optional: true,
},
extra3: {
type: "string",
label: "Extra 3",
description: "Background Information (maxlength: 1000). Eg. `I am a student`.",
optional: true,
},
outputs: {
type: "integer",
label: "Outputs",
description: "The number of outputs to generate. Eg. `1`.",
optional: true,
},
language: {
propDefinition: [
app,
"language",
],
},
shouldUseGPT4: {
type: "boolean",
label: "Use GPT-4",
description: "Use advanced AI model? Use the GPT-4 model for generating content.",
optional: true,
},
},
methods: {
generateText(args = {}) {
return this.app.post({
path: "/generate",
...args,
});
},
},
async run({ $ }) {
const {
generateText,
preset,
keywords,
tone,
extra1,
extra2,
extra3,
outputs,
language,
shouldUseGPT4,
} = this;

const response = await generateText({
$,
data: {
preset,
keywords,
tone,
extra1,
extra2,
extra3,
outputs,
language,
shouldUseGPT4,
},
});
jcortes marked this conversation as resolved.
Show resolved Hide resolved
$.export("$summary", "Successfully generated text content.");
return response;
},
};
89 changes: 89 additions & 0 deletions components/easy_peasy_ai/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
const TEMPLATES = [
"custom-generator",
"paragraph-writer",
"instagram-post-caption",
"linkedin-post-generator",
"full-blog-post",
"blog-post",
"aida-framework",
"before-after-bridge-framework",
"problem-agitate-solution-framework",
"sentence-expander",
"content-rewriter",
"content-summarizer",
"grammar-corrector",
"native-speaker",
"clickbait-title-generator",
"reply-to-messsage",
"reply-to-email",
"email-generation",
"email-subject-line-generation",
"resume-headline-generator",
"linkedin-bio-generator",
"linkedin-recommendation-generator",
"linkedin-headline-generator",
"performance-review-generator",
"smart-goal-generator",
"testimonial-and-review-generator",
"press-release-generator",
"catchy-tagline",
"headline-generator",
"amazon-product-description-paragraph",
"amazon-product-bullets",
"resume-objective-generator",
"job-description-generator",
"job-summary-generator",
"job-qualifications-generator",
"job-responsibilities-generator",
"interview-questions-generator",
"interview-feedback-generator",
"blog-post-title",
"blog-post-outline",
"blog-post-intro",
"blog-post-conclusion",
"startup-ideas",
"user-story",
"acceptance-criteria",
"translate-to-singlish",
"eli5",
"business-name",
"fill-the-gaps",
"youtube-video-title",
"youtube-video-description",
"youtube-video-ideas",
"youtube-video-script-outline",
"tiktok-video-caption",
"tiktok-hashtags-generator",
"quora-answers",
"about-me-generator",
"google-ads-headlines",
"google-ads-descriptions",
"facebook-ads-headlines",
"facebook-ads-primary-text",
"seo-title-meta-descriptions",
"cover-letter-generator",
"twitter-post",
"twitter-thread",
"twitter-bio-generator",
"song-idea-generator",
"song-lyrics-generator",
"album-title-generator",
"product-descriptions",
"ai-story-generator",
"poem-title-generator",
"poem-generator",
"quote-generator",
"ai-joke-generator",
"greetings-generator",
"tinder-bio",
"pick-up-line-generator",
"instagram-bio",
"podcast-episode-title-generator",
"podcast-episode-description-generator",
"podcast-show-notes-generator",
"real-estate-listing-generator",
];

export default {
TEMPLATES,
};
Comment on lines +87 to +89
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider simplifying the export statement

The current export statement is correct, but it might be unnecessarily verbose for a single constant. Since TEMPLATES is the only export from this file, you could simplify it to a default export of the array itself.

Consider replacing the current export with:

export default TEMPLATES;

This change would make imports slightly simpler in other files:

import TEMPLATES from './constants.mjs';

instead of:

import { TEMPLATES } from './constants.mjs';

This modification doesn't change the functionality but might make the code slightly more concise and easier to use.

Loading
Loading