Like so many, I grew up watching “The Jetsons” and then “Doctor Who” eagerly awaiting a future filled with hover cars and jet packs. What future do we get instead? UberEats and robo-taxis. So far, two things the futurists taught me to expect, and that actually exist, are virtual reality and artificial intelligence.

We’re light years away from Wintermute, and Skynet seems as likely to happen due to a malfunctioning Cybertruck as anything else. AI isn’t all that “I” at the moment, and getting it to do more than behave like a suspiciously-sourced research librarian can be tricky.

Aside from trying to better understand and use my own local chatbot installs (First, Oobabooga and now KoboldCpp), I decided to explore the world of online AI-powered chatbots. I recognized some similarities between what I was seeing out there and the characters I tried to create for my own installs, and when I wanted to know more, I found some excellent guides over at AI Girlfriend Expert that helped kick-start my journey.

SFW Tutorials Using an NSFW ChatBot

I went with a subscription to GirlfriendGPT. GirlfriendGPT is an EXTREMELY NSFW chatbot interface that actually advertises itself as a “porn girlfriend” creator. And it’s true. There is a lot of very sexually explicit content. There are also role-playing games, a good set of standards and practices, categories that clearly define content, and a robust base of content creators.

It’s a site that suits me well, but it might not suit you. While I will be using GirlfriendGPT as the basis for my character creation – and the tutorials – the tutorials themselves will remain strictly safe for work.

ChatBots are trained on many different large language models, but among those that allow for character creation, emerging standards do seem to be developing. Hopefully, anything you learn here will work there (wherever there is for you), but if not, I’m going to try and be as thorough as I can so that you’ll have a better idea how to build something from the ground up based on the rules and abilities of the system you’re using.

Who is This JSON Everyone Keeps Talking About?

If you’ve taken a look at the character creation screen on any AI-powered chatbot, you’re used to seeing something like this:

Chihiro is a pleasant and energetic technology expert who loves everything to do with computerw. She’s eager to get started researching new ideas and answering technology-related questions.

Yeah… ok, as far as it goes. But it isn’t very detailed. Also, if you tried to export this character to a “character card” for use on another site, you might find something more like this when you opened the resulting .json file:

{
     "character name" : "Chihiro",
     "persona" : "Chihiro is a pleasant and energetic technology expert who loves   everything to do with computerw. She's eager to get started researching new ideas and answering technology-related questions."
}

That little bit of mark-up is known as JSON, which stands for Javascript Object Notation and you can stop rolling your eyes right now. You’ve already learned how to use it.

Although the name is a bit fancy and perhaps daunting, JSON isn’t a scripting language at all. It is just a formatting standard used by software developers to get information from one system to another.

The point of JSON is to be easy to read for people, so it simply communicates plain text. It is also supposed to be easy to read for computers, so that text is easily parsed from the simple formatting standard.

As a web developer, I used to use JSON to pass query strings and session variables back and forth. I can tell you it is the simplest formatting to use because it does one thing: pass along a key and a value. In the above example, “character name” is the key, and “Chihiro” is the value.

Keys can be anything. Any word, phrase or number… anything that can be parsed as text. Under normal conditions, a developer would have to know what keys the remote system has available and what they do in order to make good use of them. I can tell a web page “background:red” all day long, but if it doesn’t know what to do with that information, it will simply be ignored.

This is true to a certain extent with GirlfriendGPT and related chatbots as well, but since they are AI powered, it’s not nearly as true, meaning you have some leeway and a lot of creative license. It also means you just need to format your input correctly if you choose to write instructions using JSON formatting rather than just plain English.

Consider the following:

Beauchamp is an imposing figure, standing at 6’4″ with a lanky muscular build. His eyes are a piercing gray, and his blonde hair is short and neat. Wearing a Brooks Brother suit, Beauchamp is a commanding presence.

Again, that’s good enough… but you’ll run into a couple of hurdles when creating chatbot characters, and the first and foremost is token count. You have a limited amount of capacity in your character creation fields. GirlfriendGPT allows for up to 2,500 tokens per character.

That might seem like a lot, but everything you type into any of the character creation fields adds to your token count, including line breaks and empty space. Suddenly, a descriptive paragraph might not seem like the best solution.

Let’s try this…

{
"character name" : "Beauchamp",
"Physical Description" : "6' 4", muscular, lanky, neat short blonde hair.",
"Clothing" : "Brooks Brothers suit, black silk tie, leather oxford shoes."
}

It lacks any nuance, but this description of the character is more granular and concise.

The basic format is:

{
     "key" : "value"
}

If you want to include more than one pair of keys and values, separate each pair with a comma.

{
     "key01" : "value01",
     "key02" : "value02"
}

If you’re running out of room, you can save a few tokens by compacting everything onto one line:

{ "key01" : "value01", "key02" : "value02" }

If you’re going to use JSON to have more control over your character creation, please keep the simple formatting rules in-mind. A colon separates a key from a value, and a comma is used to separate key-value pairs.

For example, each of these are very different lines to a computer…

{ "character name" : "Beauchamp", "height" : "6' 4" }

Creates a character with the name Beauchamp, who is 6 foot, 4 inches tall.

{ "character name", "Beauchamp" : "height", "6'4" }

Creates an empty character name, assigns the value “height” to the key “Beauchamp”, and then creates an empty key “6’4”. None of this will make sense to the chatbot software and will produce confusing results, if it isn’t ignored completely.

The keys and the values themselves are always passed as plain text. That’s the whole point of JSON in its more general usage. So keys and values are always placed in between double quotes (Use single quotes to denote speech inside a value).

And blocks of code are always surrounded by braces (“{” and “}”) so the computer knows you’re talking JSON, not plain English.

Use Arrays For More Complex Information

If you’re computer or math skills are rusty, an array is just a collection of objects grouped together so that the array can be dealt with as a single object (an outfit, perhaps), or by its individual parts (shirt, trousers, shoes… etc.)

There is no variable typing going on here, so arrays can be used for anything. Similar objects, dissimilar ones, system instructions. The list is endless… and speaking of which, if the word list just lit an inner bulb, then arrays are also known as “collections” in some computer languages.

You can make arrays out of just about anything, but you’ll confuse the AI and yourself if they don’t make any sense. “Outfits” is a good example, because creating keys for “daily wear” and “evening wear” makes sense logically. Other good candidates typically used in chatbots are “locations” or even “extra characters”.

You format an array in JSON using square brackets to separate the list of values from the key.

{
     "clothing" : [
                   "Everyday" : "Brooks Brothers suit, leather oxford shoes, black silk tie",
                   "Casual" : "oversized graphic t-shirt, gray sweatpants, white athletic socks"
                  ]
}

Like with any key-value pair, you separate arrays with a comma

{
     "clothing" : [
                   "Everyday" : "Brooks Brothers suit, leather oxford shoes, black silk tie",
                   "Casual" : "oversized graphic t-shirt, gray sweatpants, white athletic socks"
                  ],
    "locations" : [
                  "Home" : "ranch-style, mid-century modern, 2-bedrooms, big yard, quiet neighborhood",
                 "Office" : "A slick, modern office suite in a city high rise. Glass, chrome, polished wood."
                  ]
}

Nesting Arrays

Finally, you can nest arrays using JSON. To do so, you need to put each nested array inside a new code block (“{ … }”).

{
     "Clothing" : [
                  {
                  "Everyday" : [
                               "shirt" : "white oxford with French cuffs",
                               "pants" : "Gray wool slacks, pleated in front",
                               "shoes" : "black patent leather"
                               ]
                  },
                  {
                  "Casual" : [
                             "shirt" : "oversized graphic t-shirt", 
                             "pants" : "gray sweatpants",
                             "footwear" : "white athletic socks"
                             ] 
                  }
}

The snippet above is useful as an example of a nested array, but you’ll find it’s probably too much for practical use. Detail comes at the price of token cost.

Now, You Know…

And that’s pretty much all there is to know about JSON as far as chatbot character creation goes. By using some simple formatting rules, you can really increase the level of detail you give your characters, and remove some of the fuzziness where it’s not wanted.

There are a few other ways of passing key-value pairs in JSON.

key(“value”) is the most common alternative to “key” : “value”.

{
"key" : "value",
key("value")
}

… are two lines that give the AI the exact same information.

That’s it. You’re an expert. Because AI-enhanced chatbots are what they are, there is a huge amount of leeway as to what information you can pass to the AI when creating your character. If you’re doing a martial roleplaying game of some sort, your character might have a “scars” array. The antagonist in a mystery might have a “disguises” array. You can pass long “nose” : “bulbous” if you think it’s important.

The only limits are your imagination, the abilities of the AI to interpret word choice, and the terms of service of any platform on which you’re creating characters.

JSON is a great way of dialing into specifics by telling the AI “Yes, this. This exactly. The rest you get to make up.” And even if you choose not to write your character instructions in JSON, at least you’ll know what you’re looking at when you open a character’s .json file.

Next up, the anatomy of a character template…


One response to “ChatBot Character Creation Basics – Part 1: JSON”

  1. ChatBot Character Creation Basics – Part 2: Phrase Anatomy – Chris Dangerferret's 2nd Childhood Avatar

    […] the first post, I introduced you (or refreshed your memory on) JSON, the easy-to-use formatting standard that […]

    Like

Leave a comment