Docs
Generation Nodes

Generation Nodes

Note that enabling this feature will use credits when used in a playthrough. For more details, please view the licencing docs.

Generation nodes bring the capabilities of large language models such as ChatGPT directly into Charisma, giving you the flexibility to safely mix both author-written replies with generated replies.

To get started, toggle on the 'Is generation node available?' checkbox on the Story Overview page (note you need to be a Manager of the story to do this).

After a generation node has been created in the graph, you can click 'Edit prompt' to get started.

Selecting a model

OpenAI: GPT-3 (text-davinci-003) is now deprecated, and Charisma will instead use the OpenAI: gpt-3.5-turbo-instruct model, which uses less credit.

There are currently six models available:

  • Anthropic's claude-1
  • Anthropic's claude-instant-1
  • Anthropic's claude-2
  • OpenAI's gpt-3.5-turbo (commonly known as ChatGPT)
  • OpenAI's gpt-3.5-turbo-instruct (ChatGPT-Instruct)
  • OpenAI's gpt-4 (GPT-4)

It's recommended to start with the ChatGPT model as this is the most capable model.

Writing a prompt

GPT-4 and ChatGPT

Every message in the prompt is expected to have a role associated with it. This can either be system, user or assistant. For more information on the roles, see the OpenAI docs (opens in a new tab).

Charisma supports using multiple message in a single prompt by prefixing a block of one or more lines with system:, user: or assistant:. Here's an example:

system:You are roleplaying as a fisherman, having a conversation with <player_name>.
system:Say something about fish:

Generally, system prompts are the most useful, though you may find you have use cases for other types of prompt.

Anthropic and OpenAI's ChatGPT-Instruct

Anthropic and ChatGPT-Instruct are simpler to use than ChatGPT or GPT-4, and expect only text with no associated role metadata. Here's an example:

You are roleplaying as a fisherman, having a conversation with <player_name>.

Say something about fish:

When using ChatGPT-Instruct, ensure that you prompt it to generate without line breaks. For example:

Complete the sequence: 1 2 3 4

On the bottom-right of the Prompt editor, you already have the stop sequence pre-filled with \n. Make sure to delete this if you expect line breaks.

Using prompt variables

In the above examples, we saw the use of <player_name>. You can use any Charisma memories directly in the prompt! Simply use the same angle bracket syntax as in Character nodes.

There are also some special prompt variables which allow you to inject other useful bits of text.

  • <STORY_DESCRIPTION>: Whatever was put in the story description on the "Story Overview" page.
  • <GRAPH_DESCRIPTION>: The description entered into the scene or subplot, by clicking "Edit details..." under the graph in the sidebar.
  • <MESSAGE_HISTORY>: The last few character and player messages in the conversation, in the following form:
Player: Hello there!
Character: It's good to meet you.
Player: Nice to meet you too.
Character: You're a pleasant one.

Note that Character is replaced with the actual character's name.

By default MESSAGE_HISTORY returns the latest 10 messages. You can increase or reduce this by putting a number in brackets specifying the number of messages you want to return, such as <MESSAGE_HISTORY(2)> for the last 2 messages.

  • <PLAYER_MESSAGE>: The text of the currently considered player message (without Player: like in the MESSAGE_HISTORY). A generation node with this in the prompt can only be after a Wildcard or Player node.

Examples

system:You are a government official who has just listened to a pitch. The idea of the pitch is <player_idea>.

The PLAYER has just answered your question as best as they can. The question and answer are listed below.

<MESSAGE_HISTORY(2)>

Now, quote back what they said in a way that demonstrates that you don't really understand the concept. What you say should be similar enough to what the PLAYER said, but show you weren't really listening.

Do this in one sentence ending in the words "is that right?":
system:You are roleplaying as a court jester.

Scene context: <GRAPH_DESCRIPTION>

The PLAYER has just described why they want you to dance all day and all night. They said "<PLAYER_MESSAGE>".

Now respond to them, telling them why you can't just do what they say:

Using the generation

The generation can be used in any attached Character node by using the <Generation> tag.

Additionally, a generation can be saved directly into a memory to then recall in the future, by selecting a memory on the Generation node. You can even use a generation saved into a memory in the prompt of a future generation, as described in using prompt variables!

If you use multiple Generation nodes in a row before a Character node, each relying on the output of the node before ('chaining'), note that this will significantly increase latency of the character responding to a player as the generations are performed sequentially. Here's an example:

🚨 Important! 🚨 Sometimes, a generation may not generate successfully. For example, the request to the underlying model may fail, or either the input or output may not pass content moderation checks. In these cases, it is highly recommended to have a fallback response (such as a wildcard route).

Limitations

Outputs are restricted to 150 tokens. Long outputs take a long time to generate so it's generally advised to include limit your response to 2 sentences or similar in your prompts.

Even with short outputs, some models may take several seconds to generate, so be patient, and also experiment to find the best model for your use-case.

If the generated response exceeds 150 tokens it will end abruptly at that limit.

Analytics

You can review any generations for a Generation node by clicking the "View analytics" button on the node.

This will show you a list of the responses that were generated. The full prompt with any variable substitutions made can be reviewed by toggling the arrow to the left.