Understanding Context

Context is one of the most powerful features in Chibi AI, enabling you to create more relevant and accurate content. The perfect context combined with incredible AI prompts leads to the absolute best results possible from AI.

This guide will help you understand how context works and how to use it effectively across different parts of Chibi.

What is Context?

Context refers to all the information available to the AI model when generating content. Think of it like giving background information to a colleague before asking them to help with a task. The more relevant context they have, the better they can assist you.

In Chibi, context includes:

  • Your prompts and instructions

  • Content from your document

  • Information stored in memory fields

  • Global variables

  • Role instructions and settings

Why Context Matters

Understanding context in Chibi helps you:

  • Ensure the AI has the necessary information to generate appropriate content

  • Control token usage and costs

  • Maintain consistency in your content

  • Get more accurate and relevant results

  • Ultimately, to achieve the pinnacle of quality AI content


How Context Works in Different Parts of Chibi

Before we dive into context in Chibi, I want to mention this UI:

ss-compose-prompt-w-vpickers-hl-01.png

The highlighted part shows tools designed to help you pick from the various context variables you're about to learn. In Chibi, you will see this throughout. Use them to work faster and use context as you need.

Document Editor Context

When working in the document editor, Chibi provides several ways to access context through variables:

  1. Document-Wide Variables

    • {{WholeDocument}}: Captures everything in your document

    • {{Title}}: The document's title

    • {{FirstParagraph}}: The opening paragraph

    • {{FirstSentence}}: The first sentence of your document

  2. Cursor-Based Variables

    • {{AboveCursor}}: About 4,000 tokens of text above your cursor

    • {{AfterCursor}}: About 4,000 tokens of text after your cursor

    • {{AfterCursorHalf}}: About 1,000 tokens of text after your cursor

    • {{LastParagraph}}: The paragraph right before your cursor

    • {{LastSentence}}: The last sentence before your cursor

    • {{ParagraphAfterCursor}}: The paragraph immediately following your cursor

  3. Selection-Based Variables

    • {{Selection}}: Any text you've selected

    • {{HighlightedWords}}: Words you've highlighted using text formatting

Tool-Specific Context

Different tools in Chibi handle context in specific ways:

  1. Inline Prompts (/prompt)

    • Uses your prompt

    • Includes active memory fields (memory stack)

    • Incorporates ~500 tokens of text above the prompt location

    • Can access any document variables

  2. Write Button

    • Uses active memory fields

    • Includes ~500 tokens of text above the cursor

    • Follows the current role's instructions

    • Can access document variables

  3. Finish Button

    • Uses a smaller context window (~125 tokens above cursor)

    • Does not include memory fields

    • Focuses on completing the current sentence naturally

  4. Memory Context

    • {{MemoryStack}}: Combines all active memory fields

    • Individual memory fields accessible by their labels

    • Memory fields can be document-specific or global

Context in Actions

Actions handle context through their task sequence, with context flowing from one task to the next. Each task can access:

  • Results from previous tasks using task variables

  • Document variables

  • Memory fields

  • Global variables

Note: For a detailed explanation of how context flows through actions, refer to our Action Context Flow guide.


Managing Context Effectively

Best Practices

  1. Be Selective with Context

    • Include only relevant information

    • Use appropriate variables for your needs

    • Consider using smaller context windows for simple tasks

  2. Use Memory Strategically

    • Store frequently needed information in memory fields

    • Use global memory for cross-document consistency

    • Activate only the memory fields you need

  3. Optimize Token Usage

    • Choose cursor-based variables appropriate for your task

    • Use {{AfterCursorHalf}} instead of {{AfterCursor}} when less context is needed

    • Consider using Run Prompt instead of Stream Prompt when you don't need to write to the document immediately

Context Window Considerations

Different AI models have different context window sizes (the maximum amount of tokens they can process). When working with large amounts of context:

  • Consider chunking content for large documents

  • Use the Chunk Content task in actions when needed

  • Monitor token usage to optimize costs

  • Choose models with appropriate context windows for your needs


Advanced Context Tips

  1. Context Cut-off

    • Use \\\ in your document to create a context cut-off point

    • Text above this marker won't be included in variables like {{AboveCursor}}

    • Useful for controlling exactly what context is available

  2. Role-Based Context

    • Roles can include variables in their instructions

    • This allows for dynamic context in your role definitions

    • Useful for creating more adaptive AI behaviors

  3. Tool Integration

    • Various tools (Rework, Ask Cheebs, etc.) have their own context variables

    • These can be accessed in actions and prompts

    • Examples: {{ReworkInput}}, {{AskCheebsInput}}, {{WebComposerInput}}


Conclusion

Understanding context in Chibi AI is key to creating effective content and workflows. By mastering the different ways context can be accessed and controlled, you can:

  • Create more accurate and relevant content

  • Build more efficient actions

  • Optimize your token usage

  • Maintain consistency across your documents

Remember that context is not something to avoid, but rather a powerful tool to harness. The key is finding the right balance of context for each specific task or prompt.

For more advanced information about how context flows through actions, check out our Action Context Flow guide.

Was this helpful?