rivapereira123 commited on
Commit
0ec0a0e
·
verified ·
1 Parent(s): 47cd817

Update core/prompt_generation_agent.py

Browse files
Files changed (1) hide show
  1. core/prompt_generation_agent.py +21 -21
core/prompt_generation_agent.py CHANGED
@@ -11,47 +11,47 @@ class PromptGenerationAgent:
11
  # Template patterns for different techniques
12
  self.technique_templates = {
13
  "zero_shot": {
14
- "template": "{instruction}\n\nInput: {user_prompt}\n\nOutput:",
15
- "instruction": "Please complete the following task:"
16
  },
17
  "few_shot": {
18
- "template": "{instruction}\n\n{examples}\n\nInput: {user_prompt}\n\nOutput:",
19
- "instruction": "Here are some examples of the desired format:",
20
- "examples": "Example 1: [Input] -> [Output]\nExample 2: [Input] -> [Output]"
21
  },
22
  "chain_of_thought": {
23
- "template": "{instruction}\n\nInput: {user_prompt}\n\nLet's think step by step:\n1.",
24
- "instruction": "Solve this problem by breaking it down into clear, logical steps."
25
  },
26
  "react": {
27
- "template": "{instruction}\n\nInput: {user_prompt}\n\nThought: I need to think about this step by step.\nAction: [What action to take]\nObservation: [What I observe]\nThought: [Next thought based on observation]\n...",
28
- "instruction": "Use the ReAct framework (Reasoning and Acting) to solve this problem. Alternate between Thought, Action, and Observation."
29
  },
30
  "tree_of_thoughts": {
31
- "template": "{instruction}\n\nInput: {user_prompt}\n\nLet me explore multiple approaches:\n\nApproach 1:\n- [First approach]\n\nApproach 2:\n- [Second approach]\n\nApproach 3:\n- [Third approach]\n\nEvaluation: [Compare approaches and select the best one]",
32
- "instruction": "Explore multiple solution paths and evaluate them to find the best approach."
33
  },
34
  "self_consistency": {
35
- "template": "{instruction}\n\nInput: {user_prompt}\n\nSolution 1:\n[First reasoning path]\n\nSolution 2:\n[Second reasoning path]\n\nSolution 3:\n[Third reasoning path]\n\nFinal Answer: [Most consistent answer across solutions]",
36
- "instruction": "Generate multiple reasoning paths and select the most consistent answer."
37
  },
38
  "generated_knowledge": {
39
- "template": "{instruction}\n\nInput: {user_prompt}\n\nFirst, let me generate relevant knowledge:\nKnowledge: [Generate relevant facts and information]\n\nNow, using this knowledge:\nAnswer: [Answer based on generated knowledge]",
40
- "instruction": "First generate relevant knowledge, then use it to answer the question."
41
  },
42
  "prompt_chaining": {
43
- "template": "{instruction}\n\nInput: {user_prompt}\n\nStep 1: [Break down the task]\nSubtask 1: [First subtask]\nResult 1: [Result of first subtask]\n\nStep 2: [Next step]\nSubtask 2: [Second subtask]\nResult 2: [Result of second subtask]\n\nFinal Integration: [Combine results]",
44
- "instruction": "Break this complex task into smaller subtasks and solve them sequentially."
45
  },
46
  "meta_prompting": {
47
- "template": "{instruction}\n\nInput: {user_prompt}\n\nStructural Analysis:\n- Pattern: [Identify the pattern]\n- Format: [Identify the format]\n- Requirements: [Identify requirements]\n\nSolution: [Apply the identified structure]",
48
- "instruction": "Focus on the structural and syntactical aspects of this task."
49
  },
50
  "pal": {
51
- "template": "{instruction}\n\nInput: {user_prompt}\n\nLet me solve this step by step with code:\n\n```python\n# Step 1: [Describe what this code does]\n[code]\n\n# Step 2: [Describe next step]\n[code]\n\n# Final result\nprint(result)\n```\n\nAnswer: [Interpret the code result]",
52
- "instruction": "Solve this problem by writing and executing code."
53
  }
54
  }
 
55
 
56
  def generate_prompt(self, user_prompt: str, technique_key: str,
57
  analysis_result: Dict[str, Any]) -> Dict[str, Any]:
 
11
  # Template patterns for different techniques
12
  self.technique_templates = {
13
  "zero_shot": {
14
+ "template": "{user_prompt}",
15
+ "instruction": ""
16
  },
17
  "few_shot": {
18
+ "template": "Study the following examples and apply the same pattern.\n\n{examples}\n\nNow complete this:\n{user_prompt}",
19
+ "instruction": ""
 
20
  },
21
  "chain_of_thought": {
22
+ "template": "You're a helpful assistant. Answer the following by reasoning step by step:\n\nQ: {user_prompt}\n\nA:\nLet's think it through:\n1.",
23
+ "instruction": ""
24
  },
25
  "react": {
26
+ "template": "You're a reasoning agent who can both think and act using tools. Follow the ReAct format.\n\nTask: {user_prompt}\n\nThought: Let's analyze the problem.\nAction: [what action to take]\nObservation: [result of action]\nThought: [next reasoning step]",
27
+ "instruction": ""
28
  },
29
  "tree_of_thoughts": {
30
+ "template": "Let's explore several possible strategies to solve this task:\n\nProblem: {user_prompt}\n\nApproach 1:\n- ...\n\nApproach 2:\n- ...\n\nApproach 3:\n- ...\n\nNow compare the approaches and choose the best one.",
31
+ "instruction": ""
32
  },
33
  "self_consistency": {
34
+ "template": "Answer the following using three independent reasoning paths. Then choose the most consistent answer.\n\nPrompt: {user_prompt}\n\nPath 1:\n...\n\nPath 2:\n...\n\nPath 3:\n...\n\nFinal Answer:",
35
+ "instruction": ""
36
  },
37
  "generated_knowledge": {
38
+ "template": "Before answering, first generate helpful background knowledge. Then use it to respond.\n\nPrompt: {user_prompt}\n\nRelevant Knowledge:\n...\n\nAnswer:",
39
+ "instruction": ""
40
  },
41
  "prompt_chaining": {
42
+ "template": "Break the task below into logical steps and solve each one. Then combine the results.\n\nPrompt: {user_prompt}\n\nStep 1:\nSubtask: ...\nResult: ...\n\nStep 2:\nSubtask: ...\nResult: ...\n\nFinal Answer:",
43
+ "instruction": ""
44
  },
45
  "meta_prompting": {
46
+ "template": "Analyze the prompt structure and respond in a format that matches its intent.\n\nPrompt: {user_prompt}\n\nStructure Analysis:\n- Pattern:\n- Format:\n- Constraints:\n\nResponse:",
47
+ "instruction": ""
48
  },
49
  "pal": {
50
+ "template": "Write Python code to solve the following problem. Explain the logic as comments.\n\nTask: {user_prompt}\n\n```python\n# Step 1:\n# ...\n\n# Step 2:\n# ...\n\n# Final step:\nprint(...)\n```\n\nAnswer:",
51
+ "instruction": ""
52
  }
53
  }
54
+
55
 
56
  def generate_prompt(self, user_prompt: str, technique_key: str,
57
  analysis_result: Dict[str, Any]) -> Dict[str, Any]: