Commit graph

2 commits

Author SHA1 Message Date
namanmathur372
83de623440
Enhance OpenAI Datasource Schema with Image Generation and Model Selection Support (#10669)
* Add model selection and update schema for OpenAI API operations

This commit will add optional model selection to both completion and chat operations, update the QueryOptions type to include the model field, and modify the operations.json schema to support model selection in the UI for various OpenAI models, including GPT-4 Turbo and GPT-3.5 Turbo. The commit also adjusts the code structure to handle these changes effectively.

* Refactor OpenAI SDK integration and add image generation operation

Refactored OpenAI SDK integration to use correct imports for SDK version 4.56.0.
Replaced deprecated method listModels() with models.list() to retrieve model information.
Fixed redundant apiKey initialization in getConnection method.
Added support for the ImageGeneration operation in the run method to handle image generation using OpenAI's DALL-E.
Improved connection test logic to check for model availability instead of relying on the response status.

* Refactor image generation logic with improved error handling and response format

Updated the image generation logic to include a proper status, message, and description in the response format.
Added validation for the number of images and size using utility functions getNumberOfImages and getSizeEnum.
Commented out getNumberOfImages and num_images parameter in the image generation function as they are not currently in use but reserved for future implementation.
Removed redundant commented code for better readability and maintainability.
Ensured image URL is returned as part of the structured JSON response with a "success" or "failed" status.
Improved error handling by providing detailed error messages and descriptions when the query fails.

* Add UI components for model selection and image generation options

Added dropdown UI component for selecting OpenAI models, including DALL-E 3 and DALL-E 2 options.
Included a component for setting the image size (size) during image generation.
Provided descriptions and placeholders for the size input, with default values for image generation parameters.
Disabled model selection by default with dall-e-3 pre-selected for initial use.
A component for num_images can be set up if required, and the field will be added in future updates.

* Update QueryOptions type to include optional image generation parameters

Added optional num_images parameter to QueryOptions for specifying the number of images to be generated, although currently commented out for future use.
Included size parameter to QueryOptions to define the size of the generated image.
Ensured backward compatibility by making these parameters optional in the QueryOptions interface.

* Update OpenAI SDK and clean up dependencies

Updated the OpenAI SDK version from ^3.2.1 to ^4.56.0 in dependencies.
Fixed duplicate entries and cleaned up redundant dependency declarations.
Ensured consistency in devDependencies by removing duplicate typescript and @vercel/ncc entries.
2024-10-09 15:16:27 +05:30
Arpit
6d2e2046cf
Feature : OpenAI plugin (#5975)
* openai plugin init

* admin private route with admin access only

* update dev mode check
2023-04-11 11:07:27 +05:30