Sadly Not, Havoc Dinosaur

Build an AI-Augmented Word Processor

Include an interactive version of your style guide; predict reader questions; argue with a devil's advocate; shorten or simplify text... Move beyond spelling and grammar checks—evaluate your logic!

Headshot of the author, Colarusso. David Colaursso

This is the 41st post in my series 50 Days of LIT Prompts.

If you want to take my AI-powered word processor for a test drive, be my guest, but consider letting me explain some things first.

I fear people hear "AI-augmented word processor" and imagine something that takes in 7 words and turns out 700 (e.g., write an essay on the French Revolution). I think that's a pretty unimaginative vision of AI-assisted writing. As I've said again, and again, that's looking through the wrong end of the telescope. More folks should be feeding these tools 500 words and asking for 5. Today I'll show you how to turn your prompt templates into an AI writing assistant. I'll show you what this technology can do when it's interested in helping you do the hard work, not taking a shortcut.

If there is any lesson that we should take from stories about genies granting wishes, it's that the desire to get something without effort is the real problem. Think about the story of "The Sorcerer's Apprentice," in which the apprentice casts a spell to make broomsticks carry water but is unable to make them stop. The lesson of that story is not that magic is impossible to control: at the end of the story, the sorcerer comes back and immediately fixes the mess the apprentice made. The lesson is that you can't get out of doing the hard work. The apprentice wanted to avoid his chores, and looking for a shortcut was what got him into trouble.

- Ted Chiang

We'll be working with ten prompt templates, all based on examples from earlier in this series. Each template corresponds to one of our word processor's 10 functions. The trick here is that we'll export a single HTML file containing all of the templates to act as our word processor.

“Spell check was followed by grammar check, and now we have tools that can check—or at least nudge us to more honestly check—our arguments.”

I'm particularly fond of the templates that engage with the author's ideas because they're the ones that help us do the hard work. Spell check was followed by grammar check, and now we have tools that can check—or at least nudge us to more honestly check—our arguments. Consider, functions 4, 5, and 6 below. First came spellcheck, then grammar check. Now we have logic and argument checks!

As I've noted before, one of my favorite bits of writing advice is, "let your writing breathe." That is, don't write everything in one go. Let it sit so you can come back to it with fresh eyes. Reading your work out loud, or better yet, having a computer read it to you are both great too. It's too easy to reread something you just wrote and unconsciously fill in the blanks. If you want a different perspective on your writing, you've always needed distance or another person. Now, however, there's a third option, ask a large language model (LLM).

The word processor's ten functions are listed below, along with links to the posts where we first met them. I suggest clicking through those links if you want to learn more. You can take them all for a test drive here. I do hope, however, you follow through below and add some of your own.

Functions

  1. 📖 Define word/phrase. A Rose by Any Other Name: Define a selected word, phrase, idiom, or initialism
  2. 🗜️ Shorten selected text. 500 Characters? I'll Make It Fit! Use AI to shorten text
  3. 👩🏻‍🏫 Suggest plain language. Translate Legalese: An AI tool for rewriting texts in plain language
  4. 🤷 Anticipate reader questions. Anticipating Reader Questions: Have AI/LLMs suggest questions readers might have about your writing
  5. 🕵🏽‍♀️ Flag logical fallacies (JSON). Flag Logical Fallacies with a Browser Extension: Have AI read your text and flag logical fallacies
  6. 😈 Engage devil's advocate. Summon the Demon: Strengthen your arguments with an AI-powered devil's advocate
  7. 📕 Apply house style guide. The Elements of Interactive Style Guides: Have AI provide writing feedback based on a house style guide
  8. 🗞️ Suggest headlines/titles. Follow This One Trick to Write Great Headlines: Produce a collection of possible clickbait compelling headlines based on the text of an article
  9. 📝 Summarize and question. Using AI to Distill and Question Texts: Summarize and question text
  10. 🤖 🐂 💩 BS with a "bot." Algorithmic BS: Shoot the breeze with your base LLM

There is one template I wish I could have included but didn't: Magnifying Ideas and Expanding Text with AI: In which I show you how to have AI write something both personal and original, bucking the assumptions that AI writing can never be personal or original. Unfortunately, this template used the Scratch Pad to store a running transcript of its conversation which conflicted with using the Scratch Pad as a place for typing your text. So, I had to leave it out. That being said...

Let's build something!

We'll do our building in the LIT Prompts extension. If you aren't familiar with the LIT Prompts extension, don't worry. We'll walk you through setting things up before we start building. If you have used the LIT Prompts extension before, skip to The Prompt Pattern (Template).

Up Next

Questions or comments? I'm on Mastodon @Colarusso@mastodon.social


Setup LIT Prompts

7 min intro video

LIT Prompts is a browser extension built at Suffolk University Law School's Legal Innovation and Technology Lab to help folks explore the use of Large Language Models (LLMs) and prompt engineering. LLMs are sentence completion machines, and prompts are the text upon which they build. Feed an LLM a prompt, and it will return a plausible-sounding follow-up (e.g., "Four score and seven..." might return "years ago our fathers brought forth..."). LIT Prompts lets users create and save prompt templates based on data from an active browser window (e.g., selected text or the whole text of a webpage) along with text from a user. Below we'll walk through a specific example.

To get started, follow the first four minutes of the intro video or the steps outlined below. Note: The video only shows Firefox, but once you've installed the extension, the steps are the same.

Install the extension

Follow the links for your browser.

  • Firefox: (1) visit the extension's add-ons page; (2) click "Add to Firefox;" and (3) grant permissions.
  • Chrome: (1) visit the extension's web store page; (2) click "Add to Chrome;" and (3) review permissions / "Add extension."

If you don't have Firefox, you can download it here. Would you rather use Chrome? Download it here.

Point it at an API

Here we'll walk through how to use an LLM provided by OpenAI, but you don't have to use their offering. If you're interested in alternatives, you can find them here. You can even run your LLM locally, avoiding the need to share your prompts with a third-party. If you need an OpenAI account, you can create one here. Note: when you create a new OpenAI account you are given a limited amount of free API credits. If you created an account some time ago, however, these may have expired. If your credits have expired, you will need to enter a billing method before you can use the API. You can check the state of any credits here.

Login to OpenAI, and navigate to the API documentation.

Once you are looking at the API docs, follow the steps outlined in the image above. That is:

  1. Select "API keys" from the left menu
  2. Click "+ Create new secret key"

On LIT Prompt's Templates & Settings screen, set your API Base to https://api.openai.com/v1/chat/completions and your API Key equal to the value you got above after clicking "+ Create new secret key". You get there by clicking the Templates & Settings button in the extension's popup:

  1. open the extension
  2. click on Templates & Settings
  3. enter the API Base and Key (under the section OpenAI-Compatible API Integration)

Once those two bits of information (the API Base and Key) are in place, you're good to go. Now you can edit, create, and run prompt templates. Just open the LIT Prompts extension, and click one of the options. I suggest, however, that you read through the Templates and Settings screen to get oriented. You might even try out a few of the preloaded prompt templates. This will let you jump right in and get your hands dirty in the next section.

If you receive an error when trying to run a template after entering your Base and Key, and you are using OpenAI, make sure to check the state of any credits here. If you don't have any credits, you will need a billing method on file.

If you found this hard to follow, consider following along with the first four minutes of the video above. It covers the same content. It focuses on Firefox, but once you've installed the extension, the steps are the same.


The Prompt Patterns (Templates)

When crafting a LIT Prompts template, we use a mix of plain language and variable placeholders. Specifically, you can use double curly brackets to encase predefined variables. If the text between the brackets matches one of our predefined variable names, that section of text will be replaced with the variable's value. Today we'll be using {{highlighted}}. The {{highlighted}} variable contains any text you have highlighted/selected in the active browser tab when you open the extension.

If the text within brackets is not the name of a predefined variable, like {{What is your name?}}, it will trigger a prompt for your user that echo's the placeholder (e.g., a text bubble containing, "What is your name?"). After the user answers, their reply will replace this placeholder. A list of predefined variables can be found in the extension's documentation. We'll use this functionality in one of the templates below to collect and act on user input.

Looking for more on each of these templates? Check out the links provided in the list of functions.

Here's a template's title.

📖 Define word/phrase

Here's the template's text.

Define the following word/phrase: {{highlighted}}

And here are the template's parameters:

Here's a template's title.

🗜️ Shorten selected text

Here's the template's text.

You're a helpful editor and you're going to help trim some text. I know it's already pretty short, but see how much you can compress/shrink the text below. When you rewrite it, knock off at least 20% of the length, but keep the main points: 

{{highlighted}}

And here are the template's parameters:

Here's a template's title.

👩🏻‍🏫 Suggest plain language

Here's the template's text.

You're a helpful editor. Here is some text I'd like you to rewrite:

{{highlighted}}

Now rewrite the above text in plain language. That is, make sure it us using active voice and that it reads at a sixth-grade reading level. Replace any jargon with cogent and concise explanations. 

And here are the template's parameters:

Here's a template's title.

🤷 Anticpate reader questions

Here's the template's text.

You're a helpful editor, and you're going to help me with a writing project. For the text that follows, what unanswered questions might the reader have? 

{{highlighted}}

And here are the template's parameters:

Here's a template's title.

🕵🏽‍♀️ Flag logical fallacies (JSON)

Here's the template's text.

You are a high school A Simulated Speech and Debate Coach, working with science and English teachers to help your students better understand common logical fallacies. You're searching for examples of fallacies to highlight and explain to your students. In a moment, I will give you a text to evaluate for logical fallacies. The text may or may not contain fallacies you can use. Be on the lookout for any of the following common logical fallacies: 

1. Strawman: Misrepresenting someone's argument to make it easier to attack.
2. False cause: Assuming a relationship between things means that one is the cause of the other.
3. Appeal to emotion: Manipulating an emotional response instead of a valid argument.
4. Fallacy fallacy: Presuming a claim is wrong because it was poorly argued or a fallacy was made.
5. Slippery slope: Claiming that if one thing happens, then extreme outcomes will follow.
6. Ad hominem: Attacking an opponent's character to undermine their argument.
7. Tu quoque: Avoiding criticism by turning it back on the accuser.
8. Personal incredulity: Dismissing something because it's difficult to understand.
9. Special pleading: Moving the goalposts or making exceptions when a claim is shown to be false.
10. Loaded question: Asking a question with a presumption built in to make the answer appear guilty.
11. Burden of proof: Shifting the burden of proof to someone else to disprove a claim.
12. Ambiguity: Using double meanings or ambiguous language to mislead.
13. Gambler's fallacy: Believing that independent events are influenced by past outcomes.
14. Bandwagon: Appealing to popularity as a form of validation.
15. Appeal to authority: Assuming something is true because an authority figure believes it.
16. Composition/division: Assuming something true for a part applies to the whole, or vice versa.
17. No true Scotsman: Dismissing relevant criticisms by appealing to purity.
18. Genetic: Judging something as good or bad based on where it comes from.
19. Black-or-white: Presenting only two alternative states when more possibilities exist.
20. Begging the question: Circular reasoning where the conclusion is included in the premise.
21. Appeal to nature: Arguing that something 'natural' is valid, justified, or ideal.
22. Anecdotal: Using personal experience or isolated examples instead of strong evidence.
23. The Texas sharpshooter: Cherry-picking data to fit a predetermined conclusion.
24. Middle ground: Assuming a compromise between two extremes must be the truth.

---

Here's the text:

{{highlighted}}

---

Now that you've read the text. If you found any fallacies, think about the most egregious examples, and provide a list of JSON objects for the worst fallacies. The list should be of the following structure: 

{
  "fallacies": [
   {
    "fallacy":"name of fallacy",
     "explanation":"explanation of why the text is an example of this fallacy"
   },
   {
    "fallacy":"name of fallacy",
     "explanation":"explanation of why the text is an example of this fallacy"
   }
  ]
}

If multiple fallacies are present, provide multiple examples, but no more than three in total. If there are no clear fallacies return:

{
  "fallacies": []
}


And here are the template's parameters:

Here's a template's title.

😈 Engage devil's advocate

Here's the template's text.

You are helping a colleague improve their thinking about a particular issue by taking on the role of a devil's advocate. Your job is to take issue with your colleague's conclusions, pushing back on the assumptions they are making and forcing them to consider that which they wouldn't normally consider. In a moment I will show you a text written by your colleague to get the ball rolling. You can also think of this as an acting job. As such, your job is to stay in character and act out your part. You are aiming for a realistic performance. To help you get into character, here is some background information about how to approach the role: 

BACKGROUND

1. Understand the Argument Fully

 - Listen Carefully: Before presenting counterarguments, make sure you have a thorough understanding of your colleague's viewpoint.
 - Clarify: Ask questions to clarify any points that are not clear to you. This shows you're engaged and also ensures you're responding to their actual position rather than a misunderstanding.

2. State Your Intent

 - Explain Your Role: Make it clear you're playing devil's advocate to explore the argument fully, not because you necessarily disagree.
 - Reaffirm Your Objectives: Emphasize that your goal is to strengthen the argument by examining it from all angles.

3. Present Alternative Perspectives

 - Offer Counterarguments: Introduce alternative viewpoints or potential weaknesses in the argument. Do this thoughtfully and respectfully.
 - Use Hypotheticals: Present hypothetical scenarios that challenge the argument in a non-confrontational way.

4. Encourage Exploration

 - Ask Open-Ended Questions: Encourage your colleague to think deeper about their stance by asking questions that require more than a yes or no answer.
 - Suggest Exploring Contrary Evidence: Propose looking into data or case studies that might offer a different perspective.

5. Maintain Respect and Openness

 - Be Respectful: Always communicate in a way that respects your colleague's intelligence and intentions.
 - Stay Open to Being Convinced: Show that you are open to changing your own stance based on the conversation. This makes it more likely for your colleague to be open-minded as well.

6. Summarize and Reflect

 - Summarize the Discussion: Recap what has been discussed, highlighting the strengths of the original argument and the insights gained from playing devil's advocate.
 - Reflect Together: Ask your colleague how they found the exercise and share your own reflections on the process.

7. Conclude Positively

 - Express Gratitude: Thank your colleague for engaging in the discussion. Recognize the value of having explored the argument from multiple angles.
 - Reiterate Support: Reinforce your support for your colleague, regardless of the argument's outcome.

Now here's the text you are to engage with.

THE TEXT

{{highlighted}}

DIRECTION

Be sure to keep your questions and responses short. You "speak in sentences not paragraphs." Short and conversational, no speechifying!

Think about how your character would respond and craft an appropriate reply. Remember, you are a the devil's advocate. Your goal is to embody your character while achieving a naturalistic believable performance. You will continue to play the part of your character throughout the conversation. Whatever happens, do NOT break character! Respond only with dialog, and include only the text of your reply (e.g., do NOT preface the text with the name of the speaker). After seeing The Text above, what do you say? And remember you're engaged in a dialogue not speechifying. Keep it short!
        

And here are the template's parameters:

Here's a template's title.

📕 Apply house style guide

Here's the template's text.

[the first six chapters of the 1920 edition of The Elements of Style by William Strunk, Jr.]

And here are the template's parameters:

Here's a template's title.

Generate feedback

Here's the template's text.

You are an editor helping a writer improve a piece. To refresh your memory I'm going to show you a copy of your house style guide. This will be followed by the writer's text. After this, I'll ask you to provide some helpful feedback on the piece based on the style guide.

----

HOUSE STYLE GUIDE:

{{passThrough}}

----

THE WRITER'S TEXT

{{highlighted}}

---

Provide helpful feedback based on the suggestions found in House Style Guide. Provide your advice along with quotes from where you suggest an edit.

And here are the template's parameters:

Here's a template's title.

🗞️ Suggest headlines/titles

Here's the template's text.

You are the editor for an online publication. You're about to read a new post to your site. Once you've finished reading it, you will be asked to provide a list of possible titles/headlines to use when publishing it. 

Here's the text of the post

---- 

{{highlighted}}

----

For the untitled text above, provide a list of several compelling (clickable) titles/headlines that might do well to generate attention and clicks: 

And here are the template's parameters:

Here's a template's title.

📝 Summerize and question

Here's the template's text.

{{highlighted}} 

---

Provide a short 150-word summary of the above text. If asked any follow-up questions, use the above text, and ONLY the above text, to answer them. If you can't find an answer in the above text, politely decline to answer explaining that you can't find the information. You can, however, finish a thought you started above if asked to continue, but don't write anything that isn't supported by the above text. And keep all of your replies short! But first, please provide a summary of the text. 

And here are the template's parameters:

Here's a template's title.

🤖 🐂 💩 BS with a "bot"

Here's the template's text.

{{Yes?}} [# {{Yes?}} isn't a predefined variable. So, the user will be presented with a text input, and since Post-run Behavior is set to CHAT, this ends up being a plain old chat with an LLM. #]

And here are the template's parameters:

Working with the above templates

To work with the above templates, you could copy them and their parameters into LIT Prompts one by one, or you could download a single prompts file and upload it from the extension's Templates & Settings screen. This will replace your existing prompts.

You can download a prompts file (the above template and its parameters) suitable for upload by clicking this button:


Kick the Tires

It's one thing to read about something and another to put what you've learned into practice. Let's see how this template performs.


Export and Share

After you've made the templates your own and them behaving the way you like, you can export and share them with others. This will produce an HTML file you can share. This file should work on any internet connected device. To create your file, click the Export Scratch Pad & Interactions Page button. The contents of the textarea above the button will be appended to the top of your exported file. Importantly, if you don't want to share your API key, you should temporarily remove it from your settings before exporting.

If you want to see what an exported file looks like without having to make one yourself. You can use the buttons below. View export in browser will open the file in your browser, and Download export will download a file. In either case the following custom header will be inserted into your file. It will NOT include an API key. So, you'll have to enter one when asked if you want to see things work. This information is saved in your browser. If you've provided it before, you won't be asked again. It is not shared with me. To remove this information for this site (and only this site, not individual files), you can follow the instructions found on my privacy page. Remember, when you export your own file, whether or not it contains and API key depends on if you have one defined at the time of output.

Custom header:

<h2>An AI Word Processor</h2>

<p>All of the actions below, except <i>🤖 🐂 💩 BS with a "bot"</i>, require you to select text in the writing area before triggering them. Sometimes you'll want to select everything you've written (ctrl+a). Other times you'll want to select a paragraph, sentence, or word. All of these, except <i>📖 Define word/phrase</i>, expect a sentence or more. Failure to select enough text may cause <a href="https://en.wikipedia.org/wiki/Hallucination_(artificial_intelligence)" target="_blank">hallucinations</a>. To understand what's going on here, and how to make your own AI word processor, check out <a href="https://sadlynothavocdinosaur.com/posts/word-processor" target="_blank">Build an AI-Augmented Word Processor</a>.</p>

<p><b><i>If you're in the middle of a chat below, and you want to restart, just refresh this page. The text in the text area will be saved.</b></i></p>

<hr style="border: solid 0px; border-bottom: solid 1px #555;margin: 5px 0 15px 0"/>

Not sure what's up with all those greater than and less than signs? Looking for tips on how to style your HTML? Check out this general HTML tutorial.


TL;DR References

ICYMI, here are blubs for a selection of works I linked to in this post. If you didn't click through above, you might want to give them a look now.