-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprompt_construction_utils.py
93 lines (73 loc) · 1.78 KB
/
prompt_construction_utils.py
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
def get_repo_sketch_prompt(readme_content):
instruction = f"""Below is a detailed README.md of repository. Please write a repository sketch in the form of a tree, including all folders, files, as well as imports information if necessary.
---
README.md
---
{readme_content}
---
Repository Sketch
---
"""
return instruction
def get_file_sketch_prompt(readme_content, repo_sketch_content, path):
instruction = f"""Below is a detailed README.md of repository, repository sketch, as well as a file path. Please write a corresponding file sketch.
---
README.md
---
{readme_content}
---
Repository Sketch
---
Here is a practicable repository sketch.
```
{repo_sketch_content}
```
---
File Path
---
{path}
---
File Sketch
---
"""
return instruction
def get_function_body_prompt(readme_summary, repo_sketch_content, relevant_file_sketch_content, function_header_content):
instruction = f"""Below is a detailed README.md of repository, repository sketch, as well as some relevant file sketches. Please fill the function body for the given function header.
---
README.md
---
{readme_summary}
---
Repository Sketch
---
Here is a practicable repository sketch.
```
{repo_sketch_content}
```
{relevant_file_sketch_content}
---
Function Complement
---
{function_header_content}
"""
return instruction
def get_relervant_file_sketch_content(idx, this_relevant_path, this_python_file_sketch):
instruction = f"""---
Relevant File Sketch/{idx}
---
Here is the file sketch of `{this_relevant_path}`.
```python
{this_python_file_sketch}
```
"""
return instruction
def get_current_file_sketch_content(idx, path, current_python_content):
instruction = f"""---
Current File Sketch/{idx}
---
Here is the file sketch of `{path}`.
```python
{current_python_content}
```
"""
return instruction