ToolJet/marketplace/plugins/openai/lib/operations.json
namanmathur372 d08cdebbfa
Add Model-Specific Size Validation and Update Size Parameter Placeholders for Image Generation (#10923)
* Update size parameter placeholder for image generation

Updated the placeholder for the size parameter in the operations.json file to specify valid options based on the selected model (DALL-E 2 or DALL-E 3).
- Added size options for DALL-E 2: 256x256, 512x512, 1024x1024 (default: 1024x1024)
- Added size options for DALL-E 3: 1024x1024, 1792x1024, 1024x1792 (default: 1024x1024)

* Implement model-specific size validation for image generation

Added logic to enforce model-specific size validation for DALL-E 2 and DALL-E 3 in the query_operations.ts file.
- DALL-E 3 accepts sizes: 1024x1024, 1792x1024, 1024x1792 (default: 1024x1024)
- DALL-E 2 accepts sizes: 256x256, 512x512, 1024x1024 (default: 1024x1024)
- Introduced a utility function to validate and apply the appropriate size based on the selected model.
2024-10-10 11:56:16 +05:30

305 lines
8.2 KiB
JSON

{
"$schema": "https://raw.githubusercontent.com/ToolJet/ToolJet/develop/plugins/schemas/operations.schema.json",
"title": "OpenAI Datasource",
"description": "A schema defining OpenAI datasource",
"type": "api",
"defaults": {},
"properties": {
"operation": {
"label": "Operation",
"key": "operation",
"type": "dropdown-component-flip",
"description": "Single select dropdown for operation",
"list": [
{ "value": "chat", "name": "Chat" },
{ "value": "completion", "name": "Completion" },
{ "value": "image_generation", "name": "Generate AI Image(s)" }
]
},
"chat": {
"model": {
"label": "Model",
"key": "model",
"type": "dropdown-component-flip",
"description": "Select OpenAI Model",
"list": [
{ "value": "gpt-4o", "name": "GPT-4.0" },
{ "value": "gpt-4o-mini", "name": "GPT-4.0 mini" },
{ "value": "gpt-4-turbo", "name": "GPT-4 Turbo" },
{ "value": "gpt-3.5-turbo-0125", "name": "GPT-3.5 Turbo" }
]
},
"gpt-4o": {
"prompt": {
"label": "Message",
"key": "prompt",
"type": "codehinter",
"description": "Enter message",
"placeholder": "Draft an email or other piece of writing",
"height": "150px"
},
"max_tokens": {
"label": "Max Tokens",
"key": "max_tokens",
"type": "codehinter",
"description": "Enter from 1 to 2048",
"width": "320px",
"height": "36px"
},
"temperature": {
"label": "Temperature",
"key": "temperature",
"type": "codehinter",
"description": "Enter from 0 to 1",
"width": "320px",
"height": "36px"
},
"stop_sequence": {
"label": "Stop Sequence",
"key": "stop_sequence",
"type": "codehinter",
"description": "Enter stop sequence",
"width": "320px",
"height": "36px"
},
"suffix": {
"label": "Suffix",
"key": "suffix",
"type": "codehinter",
"description": "Enter suffix",
"width": "320px",
"height": "36px"
}
},
"gpt-4o-mini": {
"prompt": {
"label": "Message",
"key": "prompt",
"type": "codehinter",
"description": "Enter message",
"placeholder": "Draft an email or other piece of writing",
"height": "150px"
},
"max_tokens": {
"label": "Max Tokens",
"key": "max_tokens",
"type": "codehinter",
"description": "Enter from 1 to 2048",
"width": "320px",
"height": "36px"
},
"temperature": {
"label": "Temperature",
"key": "temperature",
"type": "codehinter",
"description": "Enter from 0 to 1",
"width": "320px",
"height": "36px"
},
"stop_sequence": {
"label": "Stop Sequence",
"key": "stop_sequence",
"type": "codehinter",
"description": "Enter stop sequence",
"width": "320px",
"height": "36px"
},
"suffix": {
"label": "Suffix",
"key": "suffix",
"type": "codehinter",
"description": "Enter suffix",
"width": "320px",
"height": "36px"
}
},
"gpt-4-turbo": {
"prompt": {
"label": "Message",
"key": "prompt",
"type": "codehinter",
"description": "Enter message",
"placeholder": "Draft an email or other piece of writing",
"height": "150px"
},
"max_tokens": {
"label": "Max Tokens",
"key": "max_tokens",
"type": "codehinter",
"description": "Enter from 1 to 2048",
"width": "320px",
"height": "36px"
},
"temperature": {
"label": "Temperature",
"key": "temperature",
"type": "codehinter",
"description": "Enter from 0 to 1",
"width": "320px",
"height": "36px"
},
"stop_sequence": {
"label": "Stop Sequence",
"key": "stop_sequence",
"type": "codehinter",
"description": "Enter stop sequence",
"width": "320px",
"height": "36px"
},
"suffix": {
"label": "Suffix",
"key": "suffix",
"type": "codehinter",
"description": "Enter suffix",
"width": "320px",
"height": "36px"
}
},
"gpt-3.5-turbo-0125": {
"prompt": {
"label": "Message",
"key": "prompt",
"type": "codehinter",
"description": "Enter message",
"placeholder": "Draft an email or other piece of writing",
"height": "150px"
},
"max_tokens": {
"label": "Max Tokens",
"key": "max_tokens",
"type": "codehinter",
"description": "Enter from 1 to 2048",
"width": "320px",
"height": "36px"
},
"temperature": {
"label": "Temperature",
"key": "temperature",
"type": "codehinter",
"description": "Enter from 0 to 1",
"width": "320px",
"height": "36px"
},
"stop_sequence": {
"label": "Stop Sequence",
"key": "stop_sequence",
"type": "codehinter",
"description": "Enter stop sequence",
"width": "320px",
"height": "36px"
},
"suffix": {
"label": "Suffix",
"key": "suffix",
"type": "codehinter",
"description": "Enter suffix",
"width": "320px",
"height": "36px"
}
}
},
"completion": {
"model": {
"label": "Model",
"key": "model",
"type": "dropdown-component-flip",
"description": "Select OpenAI Model",
"list": [
{ "value": "gpt-3.5-turbo-instruct", "name": "GPT 3.5 Turbo" }
]
},
"gpt-3.5-turbo-instruct": {
"prompt": {
"label": "Prompt",
"key": "prompt",
"type": "codehinter",
"description": "Enter prompt",
"height": "150px"
},
"max_tokens": {
"label": "Max Tokens",
"key": "max_tokens",
"type": "codehinter",
"description": "Enter from 1 to 2048",
"width": "320px",
"height": "36px"
},
"temperature": {
"label": "Temperature",
"key": "temperature",
"type": "codehinter",
"description": "Enter from 0 to 1",
"width": "320px",
"height": "36px"
},
"stop_sequence": {
"label": "Stop Sequence",
"key": "stop_sequence",
"type": "codehinter",
"description": "Enter stop sequence",
"width": "320px",
"height": "36px"
},
"suffix": {
"label": "Suffix",
"key": "suffix",
"type": "codehinter",
"description": "Enter suffix",
"width": "320px",
"height": "36px"
}
}
},
"image_generation": {
"model": {
"label": "Model",
"key": "model",
"type": "dropdown-component-flip",
"description": "Select OpenAI Model",
"list": [
{ "value": "dall-e-3", "name": "DALL-E 3" },
{ "value": "dall-e-2", "name": "DALL-E 2" }
],
"disabled": true,
"default": "dall-e-3"
},
"dall-e-3": {
"prompt": {
"label": "Prompt",
"key": "prompt",
"type": "codehinter",
"description": "Enter prompt for image generation",
"height": "150px"
},
"size": {
"label": "Size (in pixels)",
"key": "size",
"type": "codehinter",
"description": "Enter image size in pixels (e.g., 1024x1024)",
"placeholder": "1024x1024, 1792x1024 or 1024x1792. By default 1024x1024 sized image is generated",
"width": "320px",
"height": "36px"
}
},
"dall-e-2": {
"prompt": {
"label": "Prompt",
"key": "prompt",
"type": "codehinter",
"description": "Enter prompt for image generation",
"height": "150px"
},
"size": {
"label": "Size (in pixels)",
"key": "size",
"type": "codehinter",
"description": "Enter image size in pixels (e.g., 1024x1024)",
"placeholder": "256x256, 512x512 or 1024x1024. By default 1024x1024 sized image is generated",
"width": "320px",
"height": "36px"
}
}
}
}
}