From 179f54b38d1a6dd37d65e5aaee5c8cddd79da18a Mon Sep 17 00:00:00 2001 From: Jorge Cortes Date: Thu, 3 Oct 2024 10:13:24 -0500 Subject: [PATCH] Easy Peasy AI: Added new action components (#14190) --- .../create-transcription.mjs | 81 ++++++++++++++ .../actions/generate-image/generate-image.mjs | 93 ++++++++++++++++ .../actions/generate-text/generate-text.mjs | 105 ++++++++++++++++++ components/easy_peasy_ai/common/constants.mjs | 89 +++++++++++++++ .../easy_peasy_ai/easy_peasy_ai.app.mjs | 39 ++++++- components/easy_peasy_ai/package.json | 7 +- pnpm-lock.yaml | 5 +- 7 files changed, 412 insertions(+), 7 deletions(-) create mode 100644 components/easy_peasy_ai/actions/create-transcription/create-transcription.mjs create mode 100644 components/easy_peasy_ai/actions/generate-image/generate-image.mjs create mode 100644 components/easy_peasy_ai/actions/generate-text/generate-text.mjs create mode 100644 components/easy_peasy_ai/common/constants.mjs diff --git a/components/easy_peasy_ai/actions/create-transcription/create-transcription.mjs b/components/easy_peasy_ai/actions/create-transcription/create-transcription.mjs new file mode 100644 index 0000000000000..4953222c5aeed --- /dev/null +++ b/components/easy_peasy_ai/actions/create-transcription/create-transcription.mjs @@ -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, + }, + language: { + description: "The language of the audio E.g. `English`, `Chinese`, `French`.", + propDefinition: [ + app, + "language", + ], + }, + 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; + }, +}; diff --git a/components/easy_peasy_ai/actions/generate-image/generate-image.mjs b/components/easy_peasy_ai/actions/generate-image/generate-image.mjs new file mode 100644 index 0000000000000..6ff24d790f462 --- /dev/null +++ b/components/easy_peasy_ai/actions/generate-image/generate-image.mjs @@ -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, + }, + 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, + }, + }); + + $.export("$summary", "Successfully generated an image."); + return response; + }, +}; diff --git a/components/easy_peasy_ai/actions/generate-text/generate-text.mjs b/components/easy_peasy_ai/actions/generate-text/generate-text.mjs new file mode 100644 index 0000000000000..4eb176c3d4318 --- /dev/null +++ b/components/easy_peasy_ai/actions/generate-text/generate-text.mjs @@ -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)", + }, + 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, + }, + }); + $.export("$summary", "Successfully generated text content."); + return response; + }, +}; diff --git a/components/easy_peasy_ai/common/constants.mjs b/components/easy_peasy_ai/common/constants.mjs new file mode 100644 index 0000000000000..8ca14c1e07344 --- /dev/null +++ b/components/easy_peasy_ai/common/constants.mjs @@ -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, +}; diff --git a/components/easy_peasy_ai/easy_peasy_ai.app.mjs b/components/easy_peasy_ai/easy_peasy_ai.app.mjs index cf43813292e38..fe711c9b05044 100644 --- a/components/easy_peasy_ai/easy_peasy_ai.app.mjs +++ b/components/easy_peasy_ai/easy_peasy_ai.app.mjs @@ -1,11 +1,42 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "easy_peasy_ai", - propDefinitions: {}, + propDefinitions: { + language: { + type: "string", + label: "Language", + description: "The language of the generated content. Eg. `English`.", + optional: true, + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + getUrl(path) { + return `https://easy-peasy.ai/api${path}`; + }, + getHeaders(headers) { + return { + "Content-Type": "application/json", + "Accept": "application/json", + ...headers, + "x-api-key": this.$auth.api_key, + }; + }, + _makeRequest({ + $ = this, path, headers, ...args + } = {}) { + return axios($, { + ...args, + url: this.getUrl(path), + headers: this.getHeaders(headers), + }); + }, + post(args = {}) { + return this._makeRequest({ + method: "POST", + ...args, + }); }, }, }; diff --git a/components/easy_peasy_ai/package.json b/components/easy_peasy_ai/package.json index c80d1cf34ee3d..233f5ad8b29aa 100644 --- a/components/easy_peasy_ai/package.json +++ b/components/easy_peasy_ai/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/easy_peasy_ai", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream Easy-Peasy.AI Components", "main": "easy_peasy_ai.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "3.0.3" } -} \ No newline at end of file +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2b7139052b69f..70f43a35378d9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2892,7 +2892,10 @@ importers: specifiers: {} components/easy_peasy_ai: - specifiers: {} + specifiers: + '@pipedream/platform': 3.0.3 + dependencies: + '@pipedream/platform': 3.0.3 components/easy_project: specifiers: {}