|
1
|
|
|
def type_prompt(function_text: str, needs_typing: list, previous_error: str) -> str: |
|
2
|
|
|
# print("previous_error", previous_error) |
|
3
|
|
|
needs_typing_text = ",".join(needs_typing) |
|
4
|
|
|
# Do not assume the existence any unreferenced classes outside the standard library unless you see. |
|
5
|
|
|
return f""" |
|
6
|
|
|
Please infer these missing Python type hints. |
|
7
|
|
|
If you cannot determine the type with confidence, use 'any'. |
|
8
|
|
|
The lowercase built-in types available include: int, str, list, set, dict, tuple. |
|
9
|
|
|
You will be shown a previous error message from the type-checker with useful clues. |
|
10
|
|
|
|
|
11
|
|
|
Input: |
|
12
|
|
|
``` |
|
13
|
|
|
def foo(a, b: int, unk): |
|
14
|
|
|
return a + b |
|
15
|
|
|
``` |
|
16
|
|
|
Previous error: |
|
17
|
|
|
``` |
|
18
|
|
|
error: Argument 3 to "foo" has incompatible type "LightBulb"; expected "NoReturn" [arg-type] |
|
19
|
|
|
``` |
|
20
|
|
|
Infer: a, unk, return |
|
21
|
|
|
Output: |
|
22
|
|
|
a: int |
|
23
|
|
|
unk: LightBulb |
|
24
|
|
|
return: int |
|
25
|
|
|
|
|
26
|
|
|
Input: |
|
27
|
|
|
``` |
|
28
|
|
|
{function_text} |
|
29
|
|
|
``` |
|
30
|
|
|
Previous error: |
|
31
|
|
|
``` |
|
32
|
|
|
{previous_error} |
|
33
|
|
|
``` |
|
34
|
|
|
Infer: {needs_typing_text} |
|
35
|
|
|
Output: |
|
36
|
|
|
""" |
|
37
|
|
|
|
|
38
|
|
|
|
|
39
|
|
|
def change_list_prompt(diff_text: str) -> str: |
|
40
|
|
|
return f""" |
|
41
|
|
|
- Summarize the diff into markdown hyphen-bulleted list of changes. |
|
42
|
|
|
- Use present tense verbs like "Add/Update", not "Added/Updated". |
|
43
|
|
|
- Do not mention trivial changes like imports that support other changes. |
|
44
|
|
|
|
|
45
|
|
|
# BEGIN DIFF |
|
46
|
|
|
{diff_text} |
|
47
|
|
|
# END DIFF |
|
48
|
|
|
""" |
|
49
|
|
|
|
|
50
|
|
|
|
|
51
|
|
|
def code_review_prompt(diff_text: str) -> str: |
|
52
|
|
|
return f""" |
|
53
|
|
|
Act as an expert Software Engineer. Give a code review for this diff. |
|
54
|
|
|
|
|
55
|
|
|
# BEGIN DIFF |
|
56
|
|
|
{diff_text} |
|
57
|
|
|
# END DIFF |
|
58
|
|
|
""" |
|
59
|
|
|
|
|
60
|
|
|
|
|
61
|
|
|
def commit_msg_prompt(change_list_text: str) -> str: |
|
62
|
|
|
return f""" |
|
63
|
|
|
From this list of changes, write a brief commit message. |
|
64
|
|
|
- Sart with a one line summary, guessing the specific intent behind the changes including the names of any updated features. |
|
65
|
|
|
- Include a condensed version of the input change list formatted as a markdown list with hyphen "-" bullets. |
|
66
|
|
|
- Only output the new commit message, not any further conversation. |
|
67
|
|
|
- Omit from the list trivial changes like imports |
|
68
|
|
|
- Do not refer to anything that changes behavior as a "refactor" |
|
69
|
|
|
|
|
70
|
|
|
Example Output: |
|
71
|
|
|
``` |
|
72
|
|
|
Refactor foo module |
|
73
|
|
|
|
|
74
|
|
|
* Add types to foo.bar |
|
75
|
|
|
* Extract baz logic from foo.main to foo.baz |
|
76
|
|
|
* Formatting |
|
77
|
|
|
``` |
|
78
|
|
|
|
|
79
|
|
|
# BEGIN CHANGES |
|
80
|
|
|
{change_list_text} |
|
81
|
|
|
# END CHANGES |
|
82
|
|
|
|
|
83
|
|
|
Output: |
|
84
|
|
|
""" |
|
85
|
|
|
|