mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
feat(OpenAI Node): Support gpt-image-1 for image generation (#14870)
This commit is contained in:
committed by
GitHub
parent
84cee1d12d
commit
11379bf656
@@ -17,13 +17,17 @@ const properties: INodeProperties[] = [
|
|||||||
description: 'The model to use for image generation',
|
description: 'The model to use for image generation',
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
name: 'DALL-E-2',
|
name: 'DALL·E 2',
|
||||||
value: 'dall-e-2',
|
value: 'dall-e-2',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'DALL-E-3',
|
name: 'DALL·E 3',
|
||||||
value: 'dall-e-3',
|
value: 'dall-e-3',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'GPT Image 1',
|
||||||
|
value: 'gpt-image-1',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -63,7 +67,7 @@ const properties: INodeProperties[] = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Quality',
|
displayName: 'Quality',
|
||||||
name: 'quality',
|
name: 'dalleQuality',
|
||||||
type: 'options',
|
type: 'options',
|
||||||
description:
|
description:
|
||||||
'The quality of the image that will be generated, HD creates images with finer details and greater consistency across the image',
|
'The quality of the image that will be generated, HD creates images with finer details and greater consistency across the image',
|
||||||
@@ -84,6 +88,34 @@ const properties: INodeProperties[] = [
|
|||||||
},
|
},
|
||||||
default: 'standard',
|
default: 'standard',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Quality',
|
||||||
|
name: 'quality',
|
||||||
|
type: 'options',
|
||||||
|
description:
|
||||||
|
'The quality of the image that will be generated, High creates images with finer details and greater consistency across the image',
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: 'High',
|
||||||
|
value: 'high',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Medium',
|
||||||
|
value: 'medium',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Low',
|
||||||
|
value: 'low',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
'/model': ['gpt-image-1'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: 'medium',
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
displayName: 'Resolution',
|
displayName: 'Resolution',
|
||||||
name: 'size',
|
name: 'size',
|
||||||
@@ -134,6 +166,32 @@ const properties: INodeProperties[] = [
|
|||||||
},
|
},
|
||||||
default: '1024x1024',
|
default: '1024x1024',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Resolution',
|
||||||
|
name: 'size',
|
||||||
|
type: 'options',
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: '1024x1024',
|
||||||
|
value: '1024x1024',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '1024x1536',
|
||||||
|
value: '1024x1536',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '1536x1024',
|
||||||
|
value: '1536x1024',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
'/model': ['gpt-image-1'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
default: '1024x1024',
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
displayName: 'Style',
|
displayName: 'Style',
|
||||||
name: 'style',
|
name: 'style',
|
||||||
@@ -205,17 +263,20 @@ export async function execute(this: IExecuteFunctions, i: number): Promise<INode
|
|||||||
delete options.binaryPropertyOutput;
|
delete options.binaryPropertyOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete options.returnImageUrls;
|
if (options.dalleQuality) {
|
||||||
|
options.quality = options.dalleQuality;
|
||||||
|
delete options.dalleQuality;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete options.returnImageUrls;
|
||||||
const body: IDataObject = {
|
const body: IDataObject = {
|
||||||
prompt,
|
prompt,
|
||||||
model,
|
model,
|
||||||
response_format,
|
response_format: model !== 'gpt-image-1' ? response_format : undefined, // gpt-image-1 does not support response_format
|
||||||
...options,
|
...options,
|
||||||
};
|
};
|
||||||
|
|
||||||
const { data } = await apiRequest.call(this, 'POST', '/images/generations', { body });
|
const { data } = await apiRequest.call(this, 'POST', '/images/generations', { body });
|
||||||
|
|
||||||
if (response_format === 'url') {
|
if (response_format === 'url') {
|
||||||
return ((data as IDataObject[]) || []).map((entry) => ({
|
return ((data as IDataObject[]) || []).map((entry) => ({
|
||||||
json: entry,
|
json: entry,
|
||||||
|
|||||||
Reference in New Issue
Block a user