""" React mode specific prompt templates with context-aware placeholders. These templates are optimized for different phases of React mode execution. """ def createReactPlanSelectionPromptTemplate() -> str: """Create React plan selection prompt template with minimal context.""" return """Select exactly one action to advance the task. OBJECTIVE: {{KEY:USER_PROMPT}} AVAILABLE DOCUMENTS: {{KEY:AVAILABLE_DOCUMENTS}} USER LANGUAGE: {{KEY:USER_LANGUAGE}} AVAILABLE METHODS: {{KEY:AVAILABLE_METHODS}} AVAILABLE CONNECTIONS: {{KEY:AVAILABLE_CONNECTIONS}} CRITICAL: Return ONLY the method and action name. Do NOT include parameters or prompts. CRITICAL: Use EXACT method names from AVAILABLE_METHODS above - do NOT combine method and action names! REQUIRED JSON FORMAT: {"action":{"method":"method_name","name":"action_name"}} EXAMPLES: {"action":{"method":"ai","name":"process"}} {"action":{"method":"document","name":"extract"}} {"action":{"method":"document","name":"generate"}} {"action":{"method":"web","name":"search"}} WRONG FORMAT (DO NOT USE): {"action":{"method":"document.extract","name":"some_action"}} {"action":{"method":"ai.process","name":"some_action"}}""" def createReactParametersPromptTemplate() -> str: """Create React parameters prompt template with full context.""" return """CRITICAL: You MUST wrap all parameters in a "parameters" object! MANDATORY RESPONSE FORMAT: {"parameters":{"parameterName": "parameterValue"}} EXAMPLES: For aiPrompt parameter: {"parameters":{"aiPrompt": "Your prompt here"}} For multiple parameters: {"parameters":{"aiPrompt": "Your prompt here", "language": "en"}} WRONG FORMAT (DO NOT USE): {"aiPrompt": "Your prompt here"} ```json {"aiPrompt": "Your prompt here"} ``` CORRECT FORMAT (MUST USE): {"parameters":{"aiPrompt": "Your prompt here"}} DO NOT use code blocks or markdown. Return ONLY the JSON object with parameters wrapped in "parameters". Provide only the required parameters for this action. SELECTED ACTION: {{KEY:SELECTED_ACTION}} ACTION SIGNATURE: {{KEY:ACTION_SIGNATURE}} OBJECTIVE: {{KEY:USER_PROMPT}} AVAILABLE DOCUMENTS: {{KEY:AVAILABLE_DOCUMENTS}} AVAILABLE CONNECTIONS: {{KEY:AVAILABLE_CONNECTIONS}} USER LANGUAGE: {{KEY:USER_LANGUAGE}} DOCUMENT REFERENCE TYPES: - docItem: Reference to a single document (e.g., "docItem:uuid:filename.pdf") - docList: Reference to a group of documents (e.g., "docList:msg_123:AnalysisResults") - Use the EXACT reference strings shown in AVAILABLE_DOCUMENTS (e.g., "docList:msg_123:round1_task1_action1_results") CONNECTION REFERENCE TYPES: - Use exact connection references from AVAILABLE CONNECTIONS (e.g., "conn_microsoft_123", "conn_sharepoint_456") CRITICAL RULES: - ONLY use exact document reference strings from AVAILABLE_DOCUMENTS (e.g., "docList:msg_123:round1_task1_action1_results") - DO NOT add file paths or individual filenames to document references - ONLY use exact connection references from AVAILABLE CONNECTIONS - For documentList parameters: Use the EXACT reference strings shown in AVAILABLE_DOCUMENTS - For connectionReference parameters: Use the exact connection reference from AVAILABLE CONNECTIONS - Include user language if relevant - Avoid unnecessary fields; host applies defaults - Use the ACTION SIGNATURE above to understand what parameters are required - Convert the objective into appropriate parameter values as needed CRITICAL: You MUST wrap all parameters in a "parameters" object! MANDATORY RESPONSE FORMAT: {"parameters":{"parameterName": "parameterValue"}} EXAMPLES: For aiPrompt parameter: {"parameters":{"aiPrompt": "Your prompt here"}} For multiple parameters: {"parameters":{"aiPrompt": "Your prompt here", "language": "en"}} WRONG FORMAT (DO NOT USE): {"aiPrompt": "Your prompt here"} ```json {"aiPrompt": "Your prompt here"} ``` CORRECT FORMAT (MUST USE): {"parameters":{"aiPrompt": "Your prompt here"}} DO NOT use code blocks or markdown. Return ONLY the JSON object with parameters wrapped in "parameters".""" def createReactRefinementPromptTemplate() -> str: """Create React refinement prompt template.""" return """Decide next step based on observation. OBJECTIVE: {{KEY:USER_PROMPT}} OBSERVATION: {{KEY:REVIEW_CONTENT}} CRITICAL RULES: - If user wants DATA (numbers, lists, calculations): Ensure AI delivers the actual data, not code - If user wants DOCUMENTS (Word, PDF, Excel): Ensure appropriate method is used to create the document - If user wants ANALYSIS: Ensure AI analyzes and delivers insights - NEVER accept code when user wants data - demand the actual data - NEVER accept algorithms when user wants results - demand the actual results DECISION RULES: - If the objective is fulfilled (user got what they asked for), decide stop - If the objective is not fulfilled (user didn't get what they asked for), decide continue - Focus on what the user actually wants, not what was delivered RESPONSE FORMAT (JSON only): {"decision":"continue","reason":"Need more data"}"""