Skip to content

✨✍️ Wordcraft is an AI-powered text editor with an emphasis on short story writing

License

Notifications You must be signed in to change notification settings

Deep-Brainz/wordcraft

 
 

Repository files navigation

✨✍️ Wordcraft

Wordcraft is an LLM-powered text editor with an emphasis on short story writing.

g.co/research/wordcraft

Wordcraft is a tool built by researchers at Google PAIR for writing stories with AI. The application is powered by LLMs such as PaLM, one of the latest generation of large language models. At its core, LLMs are simple machines — it's trained to predict the most likely next word given a textual prompt. But because the model is so large and has been trained on a massive amount of text, it's able to learn higher-level concepts. It also demonstrates a fascinating emergent capability often referred to as in-context learning. By carefully designing input prompts, the model can be instructed to perform an incredibly wide range of tasks.

However this process (often referred to as prompt engineering) is finicky and difficult even for experienced practitioners. We built Wordcraft with the goal of exploring how far we could push this technique through a carefully crafted user interface, and to empower writers by giving them access to these state-of-the-art tools.

👷‍♂️ Build

npm i
npm run dev

☁️ API

In order to run Wordcraft, you'll need a PaLM API key. Please follow the instructions at developers.generativeai.google/tutorials/setup. Once you have your API key, create a .env file and add the key!

touch .env
echo "PALM_API_KEY=\"<INSERT_PALM_API_KEY>\"" > .env

Remember, use your API keys securely. Do not share them with others, or embed them directly in code that's exposed to the public! This application stores/loads API keys on the client for ease of development, but these should be removed in all production apps!

You can find more information about the PaLM 2 API at developers.generativeai.google

🤖 App

Wordcraft can be customized by adding additional models or adding operations/controls. The basic architecture allows for a great deal of flexibility in the

/app/context

Defines the underlying data/examples that will be used to construct few-shot instructions to the underlying language model. This example data can be customized to fit a particular style or genre.

/app/core/operations

Defines how the user's intent is combined with the document state, manages updating the text editor, and handles user choices.

/app/models

Defines how the data from the Context is combined with an Operation state to construct text that will be sent to a mode, and parses model output.

Customizing context

The Wordcraft application uses few-shot examples for constructing prompts to send to the model. The style of the generated text is influenced by these examples, and you can customize Wordcraft's style or genre by editing these examples. These examples are found in /app/context/json, and follow a schema defined in /app/context/schema.

Adding new controls

To add a new custom control (e.g. a button that translates into pig latin):

  • Create a new pigLatinSchema in /app/context/schema.ts
  • Create a new pig_latin_examples.json in /app/context/json/
  • Register the examples int the WordCraftContext constructor (/app/context/index.ts)
  • Create a corresponding prompt handler in /app/models/palm/prompts
  • Register that prompt handler with the underlying Model class in /app/models/palm/index.ts
  • Create a new PigLatinOperation in /app/core/operations
  • Register the operation in main.ts

This is not an officially supported Google product

About

✨✍️ Wordcraft is an AI-powered text editor with an emphasis on short story writing

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 93.8%
  • CSS 4.5%
  • JavaScript 1.4%
  • HTML 0.3%