How Variables Work
In Chibi, wherever you see a word with double curly braces around it that's a variable. Variables are a way of injecting context from other places in Chibi.
Standard Variables
{{Title}}
- Document title. This variable automatically pulls the title of the document you are working on, which is the big H1 heading at the top.
Here’s how it might look in a prompt:
Example Prompt:
Write an introduction for a document titled "{{Title}}" that lays out the main topics that will be covered
By using the {{Title}}
variable, you ensure that your prompts always stay updated with the correct document title, making your content creation process smoother and more efficient.
This is how variables work. When you use them in a prompt or any other tool in Chibi, the variable is replaced by it's contents
{{Selection}}
- Selected text within a document (not available when using a /prompt).{{HighlightedWords}}
- Words you have highlighted (using text formatting){{WholeDocument}}
- Everything in the main editor (excluding notes and memory){{AboveCursor}}
- Up to ~4,000 tokens of text above the cursor (minus title){{FirstParagraph}}
- The first paragraph of the document{{FirstSentence}}
- First sentence of document{{LastParagraph}}
- The paragraph directly before cursor location
Holds the last paragraph above the current cursor location in the editor.
{{LastSentence}}
- Last sentence directly before cursor location{{Notes}}
- Everything in notes{{Notes:#}}
- A specified paragraph in notes (denoted by a line break)*
Replace the # with the number of the paragraph from within the notes you want to use.
Notes:# variable holds the contents of the #nth paragraph from the top of the notes. For example, {{Notes:1}}
would hold the contents of the first paragraph within notes.
{{AfterCursor}}
- Up to ~4,000 tokens of text after the cursor
Holds all the text that comes after the current cursor location in the editor, down to the end of the document.
{{AfterCursorHalf}}
- Up to ~1,000 tokens of text after the cursor{{ParagraphAfterCursor}}
- The paragraph directly after the current cursor location
Memory Variables
The label you give to a memory field becomes the variable. This assigns content to variables, on a per-document basis (in the memory sidebar). For example, you could create a {{Topic}}
memory variable and then use it in Rework, Prompts, Actions, or Chat (within the same document).
A unique feature of memory variables is, when memory is turned on, the active memory is used by inline prompts.
Task Variables
Task variables can only be used within actions. As actions run, they pass output from one to another down the sequence of tasks.
Best practice is to name the variables in your tasks so you can avoid abstract variables such as these we discuss below. Named variables are much easier to use.
{{FromTask:#}}
- This is the task variable you will use most often. It sends the output from the task into a later task.{{Line}}
- The line variable is used in the Loop Line By Line Task to reference the source material that the loop will cycle on. Here is a quick video that explains this in action.
Default task variables do not dynamically reassign so if you reorder tasks in your action -- you must manually edit the variables used in the prompt/template of your action tasks. But if you have named your variables this does not apply.
Nested Tasks
Some elements, such as Line by Line, Loop, and the logic checks (If... empty, If... Contains, etc.) work by letting you nest tasks inside of them.
But sometimes you might want to refer to the content created from a task before them. To do this you add a special modifier to the task variable.
This is useful when creating content like blog posts or stories and you want certain context available inside of the nested tasks as they run.
Global Variables
Global Variables are like memory variables, but usable across all documents (remember, memory variables are only within the document you created them in).