npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@apostrophecms/ai-helper

v1.0.0-beta.9

Published

AI helpers for content creation

Downloads

20

Readme

ai-helper: AI for content creation in Apostrophe 3

Purpose

This module enhances Apostrophe with AI-driven helpers. Currently this module offers:

  • A button to generate an image from a text prompt via OpenAI.
  • An insert menu option to generate rich text from a prompt via OpenAI.

You will need to obtain your own API key from OpenAI. As of this writing you can also obtain a free API key for limited usage.

Caveats

This is a beta module where we are experimenting with simple ways to integrate generative AI in the content creation process. AI systems can generate surprising and sometimes inappropriate results. The OpenAI API itself is subject to change.

Install

npm install @apostrophecms/ai-helper
// in app.js
modules: {
  '@apostrophecms/ai-helper': {
    // Optional: specify a particular GPT model name.
    // This is the default:
    textModel: 'gpt-4o',
    // Optional: specify a particular Dall-E image
    // generation model name. This is the default.
    // Note: dall-e-3 currently lacks features needed
    // by this module
    imageModel: 'dall-e-2',
    // Optional: override the maximum number of tokens,
    // up to GPT's limit for the model. This is the default:
    textMaxTokens: 1000
  }
}
// Anywhere you have a rich text widget that should support
// AI-generated rich text
someAreaName: {
  widgets: {
    '@apostrophecms/rich-text': {
      toolbar: [
        'styles',
        'bold'
      ],
      insert: [
        'ai'
      ],
      // Generated text includes headings if asked for
      styles: [
        {
          name: 'Heading',
          tag: 'h2'
        },
        {
          name: 'Subheading',
          tag: 'h3'
        },
        {
          name: 'Paragraph',
          tag: 'p'
        }
      ]
    }
  }
}
// in modules/@apostrophecms/security-headers/index.js,
// only if you are using that module in your project
module.exports = {
  options: {
    policies: {
      ai: {
        // Images served by OpenAI, for editing purposes only
        'img-src': '*.blob.core.windows.net'
      }
    }
  }
};

Run

export APOS_OPENAI_KEY=get-your-own-key-from-openai
node app

Usage

Image Generation

Add an image widget to the page. Click the edit pencil, then "Browse" as you normally would.

When the media manager appears, click the "🤖" (robot) button in the upper right corner.

When the "Generate Image" dialog appears, follow the instructions to enter a plain English description of the image you want. Then click "Generate." After a pause, four images will appear. You can do this as many times as you wish.

When you are happy with the results, click on the best of the four images to review it and click "Select" to bring it into the media library, "Variants" to generate variants of it, or "Delete" to discard it.

The image helper generates 1024x1024 images. This is the maximum size supported by OpenAI. As of this writing, smaller images are not much cheaper, and are unlikely to look good in various placements on a website.

Note that generated images not selected for use in the media library after one hour will be discarded by OpenAI. Those you select are permanently imported to the media library.

Text Generation

Configure a rich text widget with the insert subproperty configured as shown above.

Now press the "/" (slash) key at the start of any line to bring up the insert menu. Choose "Generate Text" to generate text.

Enter a prompt as suggested and click "Generate." After a pause, the generated text is inserted into the rich text widget.

Note that the generated text can include headings and links if you so request. It is also a good idea to specify a word count. You can make your request using ordinary conversational language.