@directus-labs/ai-image-generation-operation
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -1,37 +0,1 @@ | ||
import { request, log } from 'directus:api'; | ||
var api = { | ||
id: 'directus-labs-ai-image-generation', | ||
handler: async ({ apiKey, prompt, quality, size }) => { | ||
try { | ||
const { size: dimensions } = [ | ||
{ label: 'square', size: '1024x1024' }, | ||
{ label: 'portrait', size: '1024x1792' }, | ||
{ label: 'landscape', size: '1792x1024' }, | ||
].find(d => d.label == size); | ||
const response = await request('https://api.openai.com/v1/images/generations', { | ||
method: 'POST', | ||
headers: { | ||
Authorization: `Bearer ${apiKey}`, | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify({ | ||
model: 'dall-e-3', | ||
n: 1, | ||
prompt, | ||
quality, | ||
size: dimensions | ||
}) | ||
}); | ||
if(response.status != 200) throw new Error('An error occurred when accessing OpenAI') | ||
return response.data.data[0].url | ||
} catch(error) { | ||
log(error.message); | ||
throw new Error(error.message) | ||
} | ||
}, | ||
}; | ||
export { api as default }; | ||
import{request as e,log as a}from"directus:api";var r={id:"directus-labs-ai-image-generation",handler:async({apiKey:r,prompt:t,quality:i,size:s})=>{try{const{size:a}=[{label:"square",size:"1024x1024"},{label:"portrait",size:"1024x1792"},{label:"landscape",size:"1792x1024"}].find((e=>e.label==s)),o=await e("https://api.openai.com/v1/images/generations",{method:"POST",headers:{Authorization:`Bearer ${r}`,"Content-Type":"application/json"},body:JSON.stringify({model:"dall-e-3",n:1,prompt:t,quality:i,size:a})});if(200!=o.status)throw new Error("An error occurred when accessing OpenAI");return o.data.data[0].url}catch(e){throw a(e.message),new Error(e.message)}}};export{r as default}; |
@@ -1,95 +0,1 @@ | ||
var app = { | ||
id: 'directus-labs-ai-image-generation', | ||
name: 'AI Image Generation', | ||
icon: 'draw', | ||
description: 'Use Open AI\'s Image Generation API to create new images based on user prompts.', | ||
overview: ({ prompt, quality, size }) => [ | ||
{ | ||
label: 'Prompt', | ||
text: prompt, | ||
}, | ||
{ | ||
label: 'Quality', | ||
text: quality, | ||
}, | ||
{ | ||
label: 'Size', | ||
text: size, | ||
}, | ||
], | ||
options: [ | ||
{ | ||
field: 'apiKey', | ||
name: 'OpenAI API Key', | ||
type: 'string', | ||
required: true, | ||
meta: { | ||
width: 'full', | ||
interface: 'input', | ||
options: { | ||
masked: true, | ||
}, | ||
}, | ||
}, | ||
{ | ||
field: 'prompt', | ||
name: 'Prompt', | ||
type: 'text', | ||
required: true, | ||
meta: { | ||
width: 'full', | ||
interface: 'textarea', | ||
}, | ||
}, | ||
{ | ||
field: 'quality', | ||
name: 'Quality', | ||
type: 'string', | ||
required: true, | ||
meta: { | ||
width: 'half', | ||
interface: 'select-dropdown', | ||
options: { | ||
choices: [ | ||
{ | ||
text: 'Standard', | ||
value: 'standard' | ||
}, | ||
{ | ||
text: 'High', | ||
value: 'hd' | ||
}, | ||
] | ||
} | ||
} | ||
}, | ||
{ | ||
field: 'size', | ||
name: 'Size', | ||
type: 'string', | ||
required: true, | ||
meta: { | ||
width: 'half', | ||
interface: 'select-dropdown', | ||
options: { | ||
choices: [ | ||
{ | ||
text: 'Square', | ||
value: 'square' | ||
}, | ||
{ | ||
text: 'Portrait', | ||
value: 'portrait' | ||
}, | ||
{ | ||
text: 'Landscape', | ||
value: 'landscape' | ||
}, | ||
] | ||
} | ||
} | ||
}, | ||
], | ||
}; | ||
export { app as default }; | ||
var e={id:"directus-labs-ai-image-generation",name:"AI Image Generation",icon:"draw",description:"Use Open AI's Image Generation API to create new images based on user prompts.",overview:({prompt:e,quality:t,size:a})=>[{label:"Prompt",text:e},{label:"Quality",text:t},{label:"Size",text:a}],options:[{field:"apiKey",name:"OpenAI API Key",type:"string",required:!0,meta:{width:"full",interface:"input",options:{masked:!0}}},{field:"prompt",name:"Prompt",type:"text",required:!0,meta:{width:"full",interface:"textarea"}},{field:"quality",name:"Quality",type:"string",required:!0,meta:{width:"half",interface:"select-dropdown",options:{choices:[{text:"Standard",value:"standard"},{text:"High",value:"hd"}]}}},{field:"size",name:"Size",type:"string",required:!0,meta:{width:"half",interface:"select-dropdown",options:{choices:[{text:"Square",value:"square"},{text:"Portrait",value:"portrait"},{text:"Landscape",value:"landscape"}]}}}]};export{e as default}; |
{ | ||
"name": "@directus-labs/ai-image-generation-operation", | ||
"description": "Use DALLE•E 3 to generate images based on a user prompt.", | ||
"icon": "extension", | ||
"version": "1.0.1", | ||
"license": "MIT", | ||
"keywords": [ | ||
"directus", | ||
"directus-extension", | ||
"directus-extension-operation" | ||
], | ||
"type": "module", | ||
"files": [ | ||
"dist" | ||
], | ||
"directus:extension": { | ||
"type": "operation", | ||
"path": { | ||
"app": "dist/app.js", | ||
"api": "dist/api.js" | ||
}, | ||
"source": { | ||
"app": "src/app.js", | ||
"api": "src/api.js" | ||
}, | ||
"host": "^10.10.0", | ||
"sandbox": { | ||
"enabled": true, | ||
"requestedScopes": { | ||
"log": {}, | ||
"request": { | ||
"methods": [ | ||
"POST" | ||
], | ||
"urls": [ | ||
"https://api.openai.com/v1/**" | ||
] | ||
} | ||
} | ||
} | ||
}, | ||
"scripts": { | ||
"build": "directus-extension build", | ||
"dev": "directus-extension build -w --no-minify", | ||
"link": "directus-extension link" | ||
}, | ||
"devDependencies": { | ||
"@directus/extensions-sdk": "11.0.1", | ||
"vue": "^3.4.21" | ||
} | ||
"name": "@directus-labs/ai-image-generation-operation", | ||
"description": "Use DALLE•E 3 to generate images based on a user prompt.", | ||
"icon": "extension", | ||
"version": "1.0.2", | ||
"license": "MIT", | ||
"keywords": [ | ||
"directus", | ||
"directus-extension", | ||
"directus-extension-operation" | ||
], | ||
"type": "module", | ||
"files": [ | ||
"dist" | ||
], | ||
"directus:extension": { | ||
"type": "operation", | ||
"path": { | ||
"app": "dist/app.js", | ||
"api": "dist/api.js" | ||
}, | ||
"source": { | ||
"app": "src/app.js", | ||
"api": "src/api.js" | ||
}, | ||
"host": "^10.10.0", | ||
"sandbox": { | ||
"enabled": true, | ||
"requestedScopes": { | ||
"log": {}, | ||
"request": { | ||
"methods": [ | ||
"POST" | ||
], | ||
"urls": [ | ||
"https://api.openai.com/v1/**" | ||
] | ||
} | ||
} | ||
} | ||
}, | ||
"scripts": { | ||
"build": "directus-extension build", | ||
"dev": "directus-extension build -w --no-minify", | ||
"link": "directus-extension link" | ||
}, | ||
"devDependencies": { | ||
"@directus/extensions-sdk": "11.0.1", | ||
"vue": "^3.4.21" | ||
} | ||
} |
@@ -5,3 +5,3 @@ # AI Image Generation Operation | ||
![The AI Image Generation operation, showing an OpenAI API Key field, and fields for a prompt, quality, and size selection](https://raw.githubusercontent.com/directus-labs/extension-ai-image-generation-operation/main/docs/options.png) | ||
![The AI Image Generation operation, showing an OpenAI API Key field, and fields for a prompt, quality, and size selection](https://raw.githubusercontent.com/directus-labs/extensions/main/packages/ai-image-generation-operation/docs/options.png) | ||
@@ -8,0 +8,0 @@ This operation contains four required configuration options - an [OpenAI API Key](https://platform.openai.com), a text prompt, a quality (standard or high), and a size (square, portrait, or landscape). It returns a string which is a direct URL to the generated image. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4373
7
2