|
| 1 | +import altTextLab from "../../alttextlab.app.mjs"; |
| 2 | +import { AI_WRITING_STYLE } from "../../common/constants.mjs"; |
| 3 | + |
| 4 | +export default { |
| 5 | + key: "alttextlab-generate-alt-text", |
| 6 | + name: "Generate Alt Text", |
| 7 | + description: "Generates alt text for images using AI. [See the documentation](https://www.alttextlab.com/docs/api)", |
| 8 | + version: "0.0.1", |
| 9 | + type: "action", |
| 10 | + props: { |
| 11 | + altTextLab, |
| 12 | + alert: { |
| 13 | + type: "alert", |
| 14 | + alertType: "info", |
| 15 | + content: "Supported formats: PNG, JPG, WebP, AVIF, SVG", |
| 16 | + }, |
| 17 | + imageUrl: { |
| 18 | + type: "string", |
| 19 | + label: "Image URL", |
| 20 | + description: "Provide the direct URL to the image you want to generate alt text for. Make sure the link is publicly accessible (not behind a login or firewall).", |
| 21 | + }, |
| 22 | + lang: { |
| 23 | + type: "string", |
| 24 | + label: "Language", |
| 25 | + description: "Enter the language code for the alt text generation (e.g., \"en\" for English, \"fr\" for French). See the [full list of supported languages](https://www.alttextlab.com/docs/api#language)", |
| 26 | + default: "en", |
| 27 | + }, |
| 28 | + style: { |
| 29 | + type: "string", |
| 30 | + label: "AI writing styles", |
| 31 | + options: AI_WRITING_STYLE, |
| 32 | + description: "Alt-text writing styles define the tone, structure, and level of detail used to describe an image. [Learn more](https://www.alttextlab.com/docs/writing-style)", |
| 33 | + default: "neutral", |
| 34 | + }, |
| 35 | + keywords: { |
| 36 | + type: "string[]", |
| 37 | + label: "Keywords", |
| 38 | + description: "Enter one or more keywords to alt text generation. Separate multiple keywords with commas. Example: cat, window, sunset.", |
| 39 | + optional: true, |
| 40 | + }, |
| 41 | + ecommerceProduct: { |
| 42 | + type: "string", |
| 43 | + label: "Ecommerce Product Name", |
| 44 | + description: "The name of the product.", |
| 45 | + optional: true, |
| 46 | + }, |
| 47 | + ecommerceBrand: { |
| 48 | + type: "string", |
| 49 | + label: "Ecommerce Product Brand", |
| 50 | + description: "The brand of the product.", |
| 51 | + optional: true, |
| 52 | + }, |
| 53 | + ecommerceColor: { |
| 54 | + type: "string", |
| 55 | + label: "Ecommerce Product Color", |
| 56 | + description: "The color of the product.", |
| 57 | + optional: true, |
| 58 | + }, |
| 59 | + ecommerceMaterial: { |
| 60 | + type: "string", |
| 61 | + label: "Ecommerce Product Material", |
| 62 | + description: "The material of the product.", |
| 63 | + optional: true, |
| 64 | + }, |
| 65 | + }, |
| 66 | + async run({ $ }) { |
| 67 | + const response = await this.altTextLab.altTextGeneration({ |
| 68 | + $, |
| 69 | + data: { |
| 70 | + source: "pipedream", |
| 71 | + imageUrl: this.imageUrl, |
| 72 | + lang: this.lang, |
| 73 | + style: this.style, |
| 74 | + keywords: this.keywords, |
| 75 | + ecommerce: { |
| 76 | + product: this.ecommerceProduct, |
| 77 | + brand: this.ecommerceBrand, |
| 78 | + color: this.ecommerceColor, |
| 79 | + material: this.ecommerceMaterial, |
| 80 | + }, |
| 81 | + }, |
| 82 | + }); |
| 83 | + |
| 84 | + $.export("$summary", "Alt text has been generated"); |
| 85 | + return response; |
| 86 | + }, |
| 87 | +}; |
0 commit comments