directus-extension-ai-operations
v1.1.0
Published
A small bundle of Flow Operations which enable interaction with the [OpenAI](https://beta.openai.com/overview) and [Stability](https://stability.ai/) API's.
Downloads
3
Maintainers
Readme
Directus AI Operations Bundle
A small bundle of Flow Operations which enable interaction with the OpenAI and Stability API's.
Note: To use these you will need an API Key for the respective services.
Tested with Directus 10.6.3
Installation
The package is published to npm:
npm install https://github.com/ilanur/directus-extension-ai-operations.git
Manual Installation
- Download or fork the repository
- Install the requirements
npm install
- Build the extension
npm run build
- Move the entire project to your extension folder (only the
package.json
anddist
folder are strictly necessary)mv ./ extensions/directus-extension-ai-operations
- Restart your Directus instance
Bundle Content
Stable Diffusion Operation
This operation allow you generate images from text using the Stable Diffusion models with the Stability.ai API taking a prompt
as input and saves the resulting image to the file library returning its ID as output.
Output
An object containing the ID of the resulting image file.
{ "id": "[UUID]" }
Configuration Options
I am by no means an expert in what any of these model specific settings do so please check out the stability docs for that.
Prompt
This is the main text input used for generating the image.Width
Width of the image (note: height * width must be <= 1 Megapixel)Height
Height of the image (note: height * width must be <= 1 Megapixel)CFG Scale
How strictly the diffusion process adheres to the prompt text (higher values keep your image closer to your prompt)Steps
Number of diffusion steps to runEngine
The model to be used (defined choices can be found in src/lib/constants.jsAPI Key Override
Used to set an API Key to be used specificly on this operation.
DALL-E Operation
Similar to the Stable Diffusion operation this allows you to generate images from text but using the OpenAI DALL-E models instead with the OpenAI API taking a prompt
as input, optionally saves it to the local file library and returning both the original URL and local image file ID.
Output
An object containing the ID(s) and URL(s) of the resulting image file(s).
For a single result:
{ "url": "https://some.url", "id": "[UUID]" }
For multiple results:
{ "url": ["https://some.url","https://some.other.url"], "id": ["[UUID]","[UUID]"] }
Configuration Options
Prompt
This is the main text input used for generating the image.Save To File Library
Disable importing the image into the local storage allowing you to use the DALL-E result URL for other systems.Number of pictures
DALL-E allows you to generate up to 10 images.Image Size
Choices are256x256
,512x512
or1024x1024
API Key Override
Used to set an API Key to be used specificly on this operation.
GPT-3 Davinci Operation
This operation allows text completion using the OpenAI Davinci models with the OpenAI API taking a prompt
as input and returns the generated text.
Output
An object containing the generated text:
{ "response": "Generated TEXT" }
Configuration Options
I am by no means an expert in what any of these model specific settings do so please check out the OpenAI docs for that.
Prompt
This is the main text input used for text completion.Temperature
Controls randomness: Lowering results in less random completions.Maximum Length
The maximum number of tokens to generate. Requests can use up to 2,048 or 4,000 tokens shared between prompt and completion.Top P
Controls diversity via nucleus sampling: 0.5 means hald of all likelihood-weighted options are considered.Frequency Penalty
How much to penalize new tokens based on their existing frequency in the text so far. Decreases the models likelihood to repeat the same line verbatim.Presence Penalty
How much to penalize new tokens based on whether they appear in the text so far. Increases the models likelihood to talk about new topics.API Key Override
Used to set an API Key to be used specificly on this operation.
ChatGPT Operation
This operation allows chat text completion using the OpenAI gpt-3.5-turbo
models with the OpenAI API taking a list of messages
as input and returns the generated response text.
Output
An object containing the generated text:
{ "response": "Generated chat message" }
Configuration Options
Please check out the OpenAI docs for details usage.
Messages
a json string list of messages as described in OpenAI docsTemperature
Controls randomness: Lowering results in less random completions.Maximum Length
The maximum number of tokens to generate. Requests can use up to 2,048 or 4,000 tokens shared between prompt and completion.Top P
Controls diversity via nucleus sampling: 0.5 means hald of all likelihood-weighted options are considered.Frequency Penalty
How much to penalize new tokens based on their existing frequency in the text so far. Decreases the models likelihood to repeat the same line verbatim.Presence Penalty
How much to penalize new tokens based on whether they appear in the text so far. Increases the models likelihood to talk about new topics.API Key Override
Used to set an API Key to be used specificly on this operation.
Configuration Hook
This hook ensures the existence of API Key fields in the Directus Setting. These global settings will be used by the individual operations if not overridden in its local configuration.