-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathprompt.py
More file actions
103 lines (82 loc) · 3.35 KB
/
prompt.py
File metadata and controls
103 lines (82 loc) · 3.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
INPUT_KB_EXEMPLARS = """Given a problem, provide relevant problems then identify the algorithm behind it and also explain the tutorial of the algorithm.
# Problem:
{query}
# Exemplars:
Recall {k} relevant and distinct problems (different from problem mentioned above). For each problem,
1. describe it
2. generate {language} code step by step to solve that problem
3. finally generate a planning to solve that problem
# Algorithm:
----------------
Important:
Your response must follow the following xml format-
<root>
<problem>
# Recall {k} relevant and distinct problems (different from problem mentioned above). Write each problem in the following format.
<description>
# Describe the problem.
</description>
<code>
# Let's think step by step to solve this problem in {language} programming language.
</code>
<planning>
# Planning to solve this problem.
</planning>
</problem>
# similarly add more problems here...
<algorithm>
# Identify the algorithm (Brute-force, Dynamic Programming, Divide-and-conquer, Greedy, Backtracking, Recursive, Binary search, and so on) that needs to be used to solve the original problem.
# Write a useful tutorial about the above mentioned algorithms. Provide a high level generic tutorial for solving this types of problem. Do not generate code.
</algorithm>
</root>
"""
ALGORITHM_PROMPT = "## Relevant Algorithm to solve the next problem:\n{algorithm}"
SAMPLE_IO_PROMPT = "## Sample Test cases: \n{sample_io}\n"
PLANNING = """Given a competitive programming problem generate a concrete planning to solve the problem.
# Problem:
{example_problem}
# Planning:
{example_planning}
{algorithm_prompt}
## Problem to be solved:
{prompt}
{sample_io_prompt}
## Planning:
----------------
Important: You should give only the planning to solve the problem. Do not add extra explanation or words."""
PLANNING_FOR_VERIFICATION = """Given a competitive programming problem and a plan to solve the problem in {language}, tell whether the plan is correct to solve this problem.
# Problem:
{query}
# Planning:
{planning}
----------------
Important: Your response must follow the following xml format-```
<root>
<explanation> Discuss whether the given competitive programming problem is solvable by using the above mentioned planning.</explanation>
<confidence> Confidence score regarding the solvability of the problem. Must be an integer between 0 and 100. </confidence>
</root>"""
FINAL_CODE_GENARATION = """Given a competitive programming problem generate {language} code to solve the problem.
{algorithm_prompt}
## Problem to be solved:
{prompt}
## Planning:
{planning}
{sample_io_prompt}
## Let's think step by step.
----------------
Important:
{std_input_prompt}
## Your response must contain only the {language} code to solve this problem. Do not add extra explanation or words."""
IMPROVING_CODE = """Given a competitive programming problem you have generated {language} code to solve the problem. But the generated code can not pass sample test cases. Improve your code to solve the problem correctly.
{algorithm_prompt}
## Problem to be solved:
{prompt}
{response}
## Test Report:
{test_log}
## Modified Planning:
## Let's think step by step to modify {language} Code for solving this problem.
----------------
Important:
{std_input_prompt}
## Your response must contain the modified planning and then the {language} code inside ``` block to solve this problem."""