Skip to content

Get help with your Wagtail content using AI superpowers.

License

Notifications You must be signed in to change notification settings

yishenggudou/wagtail-ai

 
 

Repository files navigation

wagtail-ai

Wagtail AI

Get help with your content using AI superpowers.

License: MIT PyPI version ai CI

Wagtail AI integrates Wagtail with OpenAI's APIs (think ChatGPT) to help you write and correct your content.

Right now, it can:

  • Finish what you've started - write some text and tell Wagtail AI to finish it off for you
  • Correct your spelling/grammar
  • Let you add your own custom prompts
WagtailAIDemo.mp4

Requirements & Costs

You'll need a paid OpenAI account and an API key. There'll also be some cost involved. For the API used here, OpenAI charges $0.002 for 1,000 tokens (a word is about 1.3 tokens). Every token sent to the API, and every token we get back counts, so you can expect using 'correction' on 1,000 word paragraph to cost roughly:

  • (1,000 * 1.3) + (35 * 1.3) (for the initial prompt) tokens sent to the API
  • + (1,000 * 1.3) tokens received from the API
  • = 2,645 tokens = $0.0053

The Future

Wagtail AI is very new. Here's some things we'd like to do:

  • Streaming support - the API supports server-sent events, we could do the same
  • A nice UI - it's a bit rough right now
  • Reduce bundle size
  • Internationalisation on text and support for different language prompts
  • Find a better way to hook in to Draftail to do things like show progress bars/spinners.
  • Add more AI behaviours and features - content recommendations, content based Q&A tools, better ways to direct the prompt.
  • Tests!

If you're interested in working on these things, please do!

Links

Supported Versions

  • Wagtail 4.0, 4.1 and 4.2

Contributing

Install

To make changes to this project, first clone this repository:

git clone https://github.com/tomusher/wagtail-ai.git
cd wagtail-ai

With your preferred virtualenv activated, install testing dependencies:

Using pip

python -m pip install --upgrade pip>=21.3
python -m pip install -e .[testing] -U

Using flit

python -m pip install flit
flit install

pre-commit

Note that this project uses pre-commit. It is included in the project testing requirements. To set up locally:

# go to the project directory
$ cd wagtail-ai
# initialize pre-commit
$ pre-commit install

# Optional, run all checks once for this, then the checks will run only on the changed files
$ git ls-files --others --cached --exclude-standard | xargs pre-commit run --files

How to run tests

Now you can run tests as shown below:

tox

or, you can run them for a specific environment tox -e python3.8-django3.2-wagtail2.15 or specific test tox -e python3.9-django3.2-wagtail2.15-sqlite wagtail-ai.tests.test_file.TestClass.test_method

To run the test app interactively, use tox -e interactive, visit http://127.0.0.1:8020/admin/ and log in with admin/changeme.

About

Get help with your Wagtail content using AI superpowers.

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 83.2%
  • TypeScript 11.7%
  • JavaScript 3.9%
  • CSS 1.2%