-
Notifications
You must be signed in to change notification settings - Fork 277
/
code_contests_prompt_analyze_and_fix.toml
78 lines (61 loc) · 2.59 KB
/
code_contests_prompt_analyze_and_fix.toml
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
[code_contests_prompt_analyze_and_fix]
temperature = 0.2
system = """\
- You must divide the fixed code into small sub-functions, with meaningful names and functionality. Each function should be no longer than 10 lines of code.
- The fixed code should be robust and general, and work for other input examples as well.
- The fixed should be different from the original code, and not just a copy-paste of the original code.
"""
user="""\
{%- if use_self_reflection_public %}
You are given a code contest problem, and a self-reflection on the problem:
problem description:
=============
{{ description|trim }}
=============
self-reflection on the problem:
======
{{ self_reflection|trim }}
======
{%- else %}
You are given a code contest problem:
=============
{{ description_short|trim }}
=============
{%- endif %}
A Python code solution was generated for the problem:
=============
{{ code_recent_solution|trim }}
=============
However, when running the input-output example test, the code solution failed to produce the expected output, and gave the following error message:
=============
{{ error_str|trim }}
=============
Using all the information above, your goal is generate a fixed code solution, that will pass the test.
The output must be a YAML object equivalent to type $FixedCode, according to the following Pydantic definitions:
=====
class FixedCode(BaseModel):
failed_tests: str = Field(description="List the input-output tests that failed. use the format [{input: .., expected_output: .., code_output: ..}, ...]")
what_went_wrong: str = Field(description="Describe shortly, in bullet points, what went wrong with the previous solutions.")
fixed_flow: str = Field(description="Describe a fixed flow leading to the correct solution, in pseudo-code. Be specific and detailed.")
fixed_code: str = Field(description="A fixed code solution. Don't explain your answer. Just provide the code itself, and nothing else")
=====
Example YAML output:
```yaml
failed_tests: |
...
what_went_wrong: |
...
fixed_flow: |
...
fixed_code: |
...
```
Additional guidelines for generating the fixed code:
- Divide the generated code into small sub-functions, with meaningful names and functionality. Keep the code simple and short.
- The fixed code should be robust and general, and work for other input examples as well
- Double-check the new solution code, and make sure it is correct and complete.
- The fixed code must have a reasonable runtime - less than three seconds on a modern computer, given the problem constraints for large input.
- The code needs to be self-contained, and executable as-is.
Answer:
```yaml
"""