With this Custom Field, you can leverage Open AI to generate CMS content for your products, webistes, blogs or whatever your heat desires.
- Change the number of words the API generates
- Change the langauge model used for text generation
Inside your Strapi Application, add the package
With npm
npm install ai-text-generation
or yarn
yarn add ai-text-generation
Then get your Open AI API Token here and add it to the .env
file at the root of your project as OPEN_AI_API_TOKEN
. Next, in ./config
, create a file called plugins.js
to enable the plugin.
// ...
'ai-text-generation': {
enabled: true,
config: {
apiToken: process.env.OPEN_AI_API_TOKEN,
},
},
//...
After, build your admin with
npm run build
or
yarn build
and start your server with
npm run develop
or
yarn develop
and now you have the power of Open AI, right in your favourite CMS. For more on how to enable Custom Feilds in your content Model, have a look at this video on "How to install and use Strapi custom fields".
In this section, we'll look at how YOU can contribute to this Custom Field.
Start by creating a new Strapi project.
npx create-strapi-app --quickstart strapi-plugin-dev
cd strapi-plugin-dev
Create a new plugins folder if it doesn't exist already.
mkdir -p src/plugins
Now we should clone this repository so you can work on it.
git clone https://github.com/malgamves/strapi-open-ai-text-generation.git src/plugins/ai-text-generation
Install project dependencies
yarn install
Now we need to register plugin so strapi can use it. In order to do that we need to create (if not already created) ./config/plugins.js
file and add entry to it.
// ...
'ai-text-generation': {
enabled: true,
config: {
apiToken: process.env.OPEN_AI_API_TOKEN,
},
resolve: './src/plugins/ai-text-generation'
},
// ...
When contributing, you need to change the value of the
tofetch()
url belowhttp://localhost:1337
Rebuild the project and start the server
yarn build
yarn develop
For an optimum development experience, start your Strapi server in Watch Mode
so you don't have to build everytime you make changes as show below
yarn develop --watch-admin
Thanks to the team at CKEditor, the format of this Readme is inspired by theirs.