gateway/modules/workflows/processing/shared/reactPromptTemplates.py
2025-10-05 02:48:53 +02:00

82 lines
No EOL
2 KiB
Python

"""
React-specific prompt templates for dynamic AI calls.
These templates are tailored for the React mode's iterative process.
"""
def createReactPlanSelectionPromptTemplate() -> str:
"""Create action selection prompt template for React mode with minimal placeholders."""
return """Select one action to advance the task.
OBJECTIVE:
{{KEY:USER_PROMPT}}
AVAILABLE_DOCUMENTS:
{{KEY:AVAILABLE_DOCUMENTS}}
AVAILABLE_METHODS:
{{KEY:AVAILABLE_METHODS}}
REPLY: Return only a JSON object with the selected action:
{{
"action": "method.action_name"
}}
RULES:
1. Use EXACT action names from AVAILABLE_METHODS
2. Return ONLY JSON - no other text
3. Do NOT use markdown code blocks
4. Do NOT add explanations
"""
def createReactParametersPromptTemplate() -> str:
"""Create ultra-simple action parameter prompt template for React mode."""
return """Generate parameters for this action.
ACTION_SIGNATURE:
{{KEY:ACTION_SIGNATURE}}
AVAILABLE_DOCUMENTS:
{{KEY:AVAILABLE_DOCUMENTS}}
USER_REQUEST:
{{KEY:USER_PROMPT}}
REPLY: Return only a JSON object with the parameters according to the ACTION_SIGNATURE without any comments in the structure below:
{{
"parameters": {{
"parameter": "value",
}},
"signature": [List of all signatures, you see in the ACTION_SIGNATURE]
}}
RULES:
1. Use ONLY parameter names from ACTION_SIGNATURE
4. Return ONLY JSON - no other text
5. Do NOT use markdown code blocks
6. Do NOT add explanations
"""
def createReactRefinementPromptTemplate() -> str:
"""Create refinement prompt template for React mode with full context placeholders."""
return """Decide the next step based on the observation.
OBJECTIVE:
{{KEY:USER_PROMPT}}
OBSERVATION:
{{KEY:REVIEW_CONTENT}}
REPLY: Return only a JSON object with your decision:
{{
"decision": "continue|stop",
"reason": "brief explanation"
}}
RULES:
1. Use "continue" if objective NOT fulfilled
2. Use "stop" if objective fulfilled
3. Return ONLY JSON - no other text
4. Do NOT use markdown code blocks
5. Do NOT add explanations
"""