1====== DokuLLM Plugin - Prompt System and Namespace Documentation ====== 2 3This document explains how the DokuLLM plugin's prompt system works, including the namespace structure, prompt hierarchy, available placeholders, system prompt extensions, and how to customize prompts. 4 5===== Namespace Structure ===== 6 7The ''dokullm:'' namespace in DokuWiki serves as the central configuration and prompt management system for the DokuLLM plugin. This namespace contains all the prompt templates, profiles, and system configurations that control how the LLM processes content. 8 9==== System Prompts ===== 10 11===== Main System Prompt (''dokullm:profiles:default:system'') ===== 12 13The system prompt is the foundational instruction set that defines the LLM's role, behavior, and capabilities. It establishes: 14 15 * Role Definition: The LLM acts as a helpful assistant specialized in text processing tasks 16 * Content Guidelines: 17 * Use clear and professional language 18 * Maintain proper DokuWiki formatting 19 * Follow structured content organization 20 * Capabilities: 21 * Access to templates, examples, and previous content 22 * Ability to retrieve relevant information 23 * Context-aware processing 24 * Safety Constraints: 25 * Focus on factual content 26 * No personal opinions 27 * Maintain professional tone 28 29===== Command-Specific System Appendages ===== 30 31Each action can have an additional system prompt that extends the main system prompt: 32 33 * ''create:system'' - Additional instructions for content creation 34 * ''rewrite:system'' - Guidelines for text rewriting and improvement 35 * ''summarize:system'' - Focus areas for summarization 36 * ''analyze:system'' - Analysis framework and structure 37 * ''expand:system'' - Guidelines for content expansion 38 39===== Prompt Placeholders ===== 40 41The system uses several special placeholders that are automatically populated: 42 43===== Core Placeholders ===== 44 45 * ''{text}'' - The main content being processed 46 * ''{template}'' - Template content for structure guidance 47 * ''{examples}'' - Style examples from previous content 48 * ''{snippets}'' - Relevant text snippets from similar content 49 * ''{previous}'' - Content from previous related documents 50 * ''{prompt}'' - Custom user prompts 51 52===== Metadata Placeholders ===== 53 54 * ''{current_date}'' - Current date 55 * ''{previous_date}'' - Date of previous document (if applicable) 56 * ''{action}'' - Current action being performed 57 * ''{think}'' - Thinking mode indicator (/think or /no_think) 58 59===== Template Integration ===== 60 61===== Template Metadata ===== 62 63Templates are referenced using metadata directives: 64 * ''~~LLM_TEMPLATE:template_id~~'' 65 * ''~~LLM_EXAMPLES:example1,example2~~'' 66 * ''~~LLM_PREVIOUS:previous_page_id~~'' 67 68===== Automatic Template Discovery ===== 69 70When no template is specified, the system can automatically find relevant templates based on content similarity using ChromaDB vector search. 71 72===== Context Management ===== 73 74The system provides rich context through: 75 76 1. Template Context: Structural guidance from template documents 77 2. Style Context: Examples showing preferred writing style 78 3. Content Context: Relevant snippets from similar documents 79 4. Historical Context: Previous related documents for continuity 80 81===== Thinking Process ===== 82 83When enabled, the LLM can engage in deeper reasoning processes, with the thinking output optionally displayed to users. This is controlled by the ''{think}'' placeholder which resolves to ''/think'' or ''/no_think''. 84 85===== Prompt Hierarchy ===== 86 87The DokuLLM plugin uses a hierarchical prompt system that allows for flexible customization using DokuWiki pages: 88 89==== 1. Default Prompts ==== 90 * Located in the ''dokullm:profiles:default:'' namespace 91 * These are the base prompts that ship with the plugin 92 * Used when no custom prompts are defined 93 * Named according to their function (e.g., ''summarize'', ''expand'') 94 95==== 2. Profile Prompts ==== 96 * Located in the ''dokullm:profiles:[PROFILE_NAME]:'' namespace 97 * Allow for different prompt configurations for different use cases 98 * Can override default prompts selectively 99 * Activated through plugin configuration 100 101==== 3. Custom Prompts ==== 102 * Can be created in custom namespaces under ''dokullm:profiles:'' 103 * Completely override default and profile prompts 104 * Allow for organization-specific customizations 105 * Take precedence over all other prompt types 106 107===== Prompt Structure ===== 108 109Each prompt page follows a simple structure with placeholders: 110 111==== Simple Prompt Format ==== 112 * Contains direct instructions to the LLM 113 * Uses placeholders for dynamic content insertion 114 * Does not require complex sectioning 115 116===== Available Placeholders ===== 117 118The plugin provides several placeholders that can be used in prompts: 119 120==== Content Placeholders ==== 121 122**{text}** 123 * The main content being processed 124 * Could be the entire document or selected text 125 * Automatically populated by the plugin 126 127**{template}** 128 * Content of the template associated with this page 129 * Used when applying template-based structures 130 131**{examples}** 132 * Example content related to the current task 133 * Helps guide the LLM with specific examples 134 135**{snippets}** 136 * Relevant text snippets from similar documents 137 * Provides context from related content 138 139**{previous}** 140 * Content from a previous version or related page 141 * Useful for continuation or comparison tasks 142 143**{prompt}** 144 * Custom instructions provided by the user 145 * Allows for dynamic user input 146 147==== Context Placeholders ==== 148 149**{current_date}** 150 * Current date in ISO format 151 * Useful for time-sensitive operations 152 153**{previous_date}** 154 * Date of previous related document 155 * Useful for tracking changes over time 156 157**{action}** 158 * The current action being performed 159 * Can be used for action-specific instructions 160 161**{think}** 162 * Thinking mode indicator (/think or /no_think) 163 * Controls whether reasoning process is shown 164 165===== Creating Custom Prompts ===== 166 167==== Basic Process ==== 168 1691. **Identify the Action** 170 * Determine which action you want to customize 171 * Check existing prompt names in the ''dokullm:profiles:default:'' namespace 172 1732. **Create Prompt Page** 174 * Create a new page with the same name in your profile namespace 175 * Use the same structure as existing prompts 176 1773. **Add Placeholders** 178 * Incorporate relevant placeholders for dynamic content 179 * Ensure all required placeholders are included 180 1814. **Test and Refine** 182 * Test the prompt with various content types 183 * Refine based on the quality of results 184 185==== Example Prompt Structure ==== 186 187A typical prompt page might look like this: 188 189Summarize the following text in a concise manner: 190 191{text} 192 193===== System Prompt Extensions ===== 194 195The plugin supports a hierarchical system prompt architecture that allows for fine-grained control over LLM behavior for specific actions. This extension mechanism enables you to provide additional context and instructions that are specific to individual operations. 196 197==== Extension Mechanism ==== 198 199The system works by automatically checking for command-specific system prompt extensions when processing any action. The extension follows this page naming convention: 200 201 ''dokullm:profiles:[PROFILE_NAME]:[ACTION_NAME]:system'' 202 203For example: 204 * ''dokullm:profiles:default:summarize:system'' 205 * ''dokullm:profiles:default:create:system'' 206 * ''dokullm:profiles:medical:analyze:system'' 207 208==== How It Works ==== 209 2101. **Base System Prompt Loading**: When any action is initiated, the main system prompt is first loaded from: 211 ''dokullm:profiles:[PROFILE_NAME]:system'' 212 2132. **Command-Specific Extension Check**: The system then checks if a command-specific system prompt extension exists: 214 ''dokullm:profiles:[PROFILE_NAME]:[ACTION_NAME]:system'' 215 2163. **Automatic Appendage**: If the extension exists, its content is automatically appended to the base system prompt with a newline separator. 217 2184. **Fallback Behavior**: If the extension doesn't exist, the system simply uses the base system prompt without any additional instructions. 219 220==== Use Cases ==== 221 222===== Action-Specific Guidelines ===== 223 224Command extensions are ideal for providing action-specific guidance that supplements the general system instructions. For example: 225 226Base System Prompt (''dokullm:profiles:default:system''): 227 You are a helpful assistant specialized in text processing tasks... 228 229Summarize Extension (''dokullm:profiles:default:summarize:system''): 230 When summarizing content, focus on the key findings and conclusions. 231 Create a concise executive summary that captures the most important information. 232 Limit your summary to 3-5 bullet points. 233 234Combined Result: 235 You are a helpful assistant specialized in text processing tasks... 236 [base instructions...] 237 238 When summarizing content, focus on the key findings and conclusions. 239 Create a concise executive summary that captures the most important information. 240 Limit your summary to 3-5 bullet points. 241 242===== Specialized Processing Instructions ===== 243 244Extensions can provide detailed processing instructions that are unique to each action: 245 * Analysis Extension: Specify analytical frameworks and evaluation criteria 246 * Comparison Extension: Define comparison methodologies and focus areas 247 * Rewrite Extension: Provide style guidelines and content restructuring rules 248 * Create Extension: Outline content generation templates and required sections 249 250==== Best Practices ==== 251 2521. **Complementary Content**: Extensions should complement, not contradict, the base system prompt 2532. **Concise Instructions**: Keep extensions focused and specific to the action 2543. **Consistent Formatting**: Maintain consistent style with the base system prompt 2554. **Profile Awareness**: Create profile-specific extensions when using multiple profiles 2565. **Testing**: Test extensions thoroughly to ensure they produce desired behavior 257 258==== Example Structure ==== 259 260 dokullm:profiles:default: 261 ├── system # Base system prompt 262 ├── summarize # Summarize action prompt 263 ├── summarize:system # Summarize-specific system extension 264 ├── expand # Expand action prompt 265 ├── expand:system # Expand-specific system extension 266 ├── grammar # Grammar action prompt 267 └── grammar:system # Grammar-specific system extension 268 269This extension mechanism provides powerful flexibility in customizing LLM behavior for different actions while maintaining a consistent foundational set of instructions. 270 271===== Prompt Best Practices ===== 272 273==== Writing Effective Prompts ==== 274 275 * **Be Specific**: Clearly define the task and expected output 276 * **Provide Context**: Include relevant background information 277 * **Use Examples**: Show examples of desired output format 278 * **Set Constraints**: Define limitations on length, style, or content 279 * **Guide Formatting**: Specify output format requirements 280 281==== Placeholder Usage ==== 282 283 * **Always Include Required Placeholders**: Missing placeholders can cause errors 284 * **Use Contextual Placeholders**: Only include placeholders that add value 285 * **Test Placeholder Substitution**: Verify that placeholders are correctly replaced 286 * **Document Custom Placeholders**: If adding new placeholders, document their purpose 287 288==== Organization and Maintenance ==== 289 290 * **Consistent Naming**: Use consistent naming conventions for prompt pages 291 * **Version Control**: Keep prompts under version control 292 * **Documentation**: Document significant changes to prompts 293 * **Backup**: Keep backups of working prompt configurations 294 295===== Troubleshooting Prompts ===== 296 297Common issues and solutions: 298 299 * **Empty Responses**: Check that all required placeholders are provided 300 * **Irrelevant Content**: Improve context and constraints in the prompt 301 * **Formatting Issues**: Be more specific about output format requirements 302 * **Performance Problems**: Simplify prompts or reduce context length 303 * **Inconsistent Results**: Add more specific guidance and examples 304 305For debugging prompt issues, enable debug logging in the plugin configuration to see the actual prompts being sent to the LLM. 306 307===== Profile System ===== 308 309===== Default Profile ===== 310 311The ''default'' profile contains standard prompts for general use cases. Each prompt in this profile is designed for specific tasks: 312 313 * create: Generate new content from scratch 314 * rewrite: Improve existing text clarity and grammar 315 * summarize: Create concise summaries 316 * expand: Add more details to topics 317 * analyze: Provide detailed analysis 318 * grammar: Check grammar and spelling 319 320===== Custom Profiles ===== 321 322Additional profiles can be created under ''dokullm:profiles/'' for specialized use cases: 323 324 * Different content types 325 * Various writing styles 326 * Organization-specific requirements 327 * Language variations 328 329===== Best Practices ===== 330 331 1. Prompt Design: Keep prompts clear and specific 332 2. Template Structure: Use consistent formatting in templates 333 3. Example Selection: Choose representative examples 334 4. Metadata Usage: Properly tag pages with relevant metadata 335 5. Profile Organization: Group related prompts in appropriate profiles 336 337The ''dokullm:'' namespace provides a flexible, extensible framework for managing LLM interactions within DokuWiki, enabling sophisticated AI-assisted content creation while maintaining consistency and quality control. 338