ai-text-generation

0.2.0 • Public • Published

Strapi AI Text Generation Custom Feild with Open AI

With this Custom Field, you can leverage Open AI to generate CMS content for your products, webistes, blogs or whatever your heat desires.

A Custom Field called writer that generates text for content editors.

Coming Soon

  • Change the number of words the API generates
  • Change the langauge model used for text generation

🔧 Installation

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".

🛠 Contributing

In this section, we'll look at how YOU can contribute to this Custom Field.

Setting up the environment

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 fetch() url below https://github.com/malgamves/strapi-open-ai-text-generation/blob/78e692b214fc51f8de6bbf6a76fca4db767411eb/admin/src/components/Input/index.js#L25 to http://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.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.2.0
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.2.0
    0
  • 0.1.1
    0
  • 0.1.0
    0

Package Sidebar

Install

npm i ai-text-generation

Weekly Downloads

0

Version

0.2.0

License

MIT

Unpacked Size

15.4 kB

Total Files

28

Last publish

Collaborators

  • malgamves