pdd-cli 0.0.39__py3-none-any.whl → 0.0.41__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pdd-cli might be problematic. Click here for more details.
- pdd/__init__.py +5 -4
- pdd/auto_deps_main.py +10 -6
- pdd/auto_include.py +143 -101
- pdd/auto_update.py +76 -68
- pdd/bug_main.py +2 -2
- pdd/bug_to_unit_test.py +46 -38
- pdd/change.py +20 -13
- pdd/change_main.py +222 -162
- pdd/cli.py +111 -92
- pdd/cmd_test_main.py +51 -35
- pdd/crash_main.py +9 -8
- pdd/data/llm_model.csv +1 -1
- pdd/fix_verification_errors.py +13 -0
- pdd/fix_verification_main.py +2 -2
- pdd/get_extension.py +23 -9
- pdd/logo_animation.py +455 -0
- pdd/process_csv_change.py +1 -1
- pdd/prompts/extract_program_code_fix_LLM.prompt +2 -1
- pdd/prompts/sync_analysis_LLM.prompt +82 -0
- pdd/sync_animation.py +643 -0
- pdd/sync_determine_operation.py +574 -0
- pdd/xml_tagger.py +15 -6
- {pdd_cli-0.0.39.dist-info → pdd_cli-0.0.41.dist-info}/METADATA +3 -3
- {pdd_cli-0.0.39.dist-info → pdd_cli-0.0.41.dist-info}/RECORD +28 -24
- {pdd_cli-0.0.39.dist-info → pdd_cli-0.0.41.dist-info}/WHEEL +0 -0
- {pdd_cli-0.0.39.dist-info → pdd_cli-0.0.41.dist-info}/entry_points.txt +0 -0
- {pdd_cli-0.0.39.dist-info → pdd_cli-0.0.41.dist-info}/licenses/LICENSE +0 -0
- {pdd_cli-0.0.39.dist-info → pdd_cli-0.0.41.dist-info}/top_level.txt +0 -0
pdd/bug_to_unit_test.py
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"""
|
|
2
|
+
This module provides functionality to generate a unit test based on a bug report.
|
|
3
|
+
"""
|
|
4
|
+
from typing import Tuple
|
|
3
5
|
from rich.markdown import Markdown
|
|
4
6
|
from rich.console import Console
|
|
5
7
|
from . import EXTRACTION_STRENGTH, DEFAULT_STRENGTH, DEFAULT_TIME
|
|
@@ -12,7 +14,8 @@ from .preprocess import preprocess
|
|
|
12
14
|
|
|
13
15
|
console = Console()
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
|
|
18
|
+
def bug_to_unit_test( # pylint: disable=too-many-arguments, too-many-locals
|
|
16
19
|
current_output: str,
|
|
17
20
|
desired_output: str,
|
|
18
21
|
prompt_used_to_generate_the_code: str,
|
|
@@ -21,7 +24,7 @@ def bug_to_unit_test(
|
|
|
21
24
|
strength: float = DEFAULT_STRENGTH,
|
|
22
25
|
temperature: float = 0.0,
|
|
23
26
|
time: float = DEFAULT_TIME,
|
|
24
|
-
language: str = "python"
|
|
27
|
+
language: str = "python",
|
|
25
28
|
) -> Tuple[str, float, str]:
|
|
26
29
|
"""
|
|
27
30
|
Generate a unit test from a code file with bug information.
|
|
@@ -32,7 +35,8 @@ def bug_to_unit_test(
|
|
|
32
35
|
prompt_used_to_generate_the_code (str): Original prompt used to generate the code
|
|
33
36
|
code_under_test (str): Code to be tested
|
|
34
37
|
program_used_to_run_code_under_test (str): Program used to run the code
|
|
35
|
-
strength (float, optional): Strength of the LLM model. Must be between 0 and 1.
|
|
38
|
+
strength (float, optional): Strength of the LLM model. Must be between 0 and 1.
|
|
39
|
+
Defaults to DEFAULT_STRENGTH.
|
|
36
40
|
temperature (float, optional): Temperature of the LLM model. Defaults to 0.0.
|
|
37
41
|
time (float, optional): Time budget for LLM calls. Defaults to DEFAULT_TIME.
|
|
38
42
|
language (str, optional): Programming language. Defaults to "python".
|
|
@@ -46,11 +50,14 @@ def bug_to_unit_test(
|
|
|
46
50
|
# Validate strength parameter
|
|
47
51
|
if not 0 <= strength <= 1:
|
|
48
52
|
raise ValueError("Strength parameter must be between 0 and 1")
|
|
49
|
-
|
|
50
|
-
# Ensure language parameter is not None or empty
|
|
53
|
+
|
|
54
|
+
# Ensure language parameter is not None or empty, defaulting to "python" if it is.
|
|
55
|
+
# This single check is sufficient for the whole function.
|
|
51
56
|
if not language or not isinstance(language, str):
|
|
52
|
-
language = "python"
|
|
53
|
-
console.print(
|
|
57
|
+
language = "python"
|
|
58
|
+
console.print(
|
|
59
|
+
"[yellow]Warning: Invalid or missing language parameter, defaulting to 'python'[/yellow]"
|
|
60
|
+
)
|
|
54
61
|
|
|
55
62
|
total_cost = 0.0
|
|
56
63
|
final_model_name = ""
|
|
@@ -62,15 +69,15 @@ def bug_to_unit_test(
|
|
|
62
69
|
raise ValueError("Failed to load prompt template")
|
|
63
70
|
|
|
64
71
|
# Step 2: Prepare input and run through LLM
|
|
65
|
-
preprocessed_prompt = preprocess(prompt_used_to_generate_the_code)
|
|
66
|
-
|
|
72
|
+
preprocessed_prompt = preprocess(prompt_used_to_generate_the_code, double_curly_brackets=False)
|
|
73
|
+
|
|
67
74
|
input_json = {
|
|
68
75
|
"prompt_that_generated_code": preprocessed_prompt,
|
|
69
76
|
"current_output": current_output,
|
|
70
77
|
"desired_output": desired_output,
|
|
71
78
|
"code_under_test": code_under_test,
|
|
72
79
|
"program_used_to_run_code_under_test": program_used_to_run_code_under_test,
|
|
73
|
-
"language": language
|
|
80
|
+
"language": language, # Simplified: language is guaranteed to be a valid string
|
|
74
81
|
}
|
|
75
82
|
|
|
76
83
|
console.print("[bold blue]Generating unit test...[/bold blue]")
|
|
@@ -80,57 +87,56 @@ def bug_to_unit_test(
|
|
|
80
87
|
strength=strength,
|
|
81
88
|
temperature=temperature,
|
|
82
89
|
time=time,
|
|
83
|
-
verbose=True
|
|
90
|
+
verbose=True,
|
|
84
91
|
)
|
|
85
92
|
|
|
86
|
-
total_cost += response[
|
|
87
|
-
final_model_name = response[
|
|
93
|
+
total_cost += response["cost"]
|
|
94
|
+
final_model_name = response["model_name"]
|
|
88
95
|
|
|
89
96
|
# Step 3: Print markdown formatting
|
|
90
|
-
console.print(Markdown(response[
|
|
97
|
+
console.print(Markdown(response["result"]))
|
|
91
98
|
|
|
92
99
|
# Step 4: Check if generation is complete
|
|
93
|
-
last_600_chars =
|
|
94
|
-
|
|
95
|
-
|
|
100
|
+
last_600_chars = (
|
|
101
|
+
response["result"][-600:]
|
|
102
|
+
if len(response["result"]) > 600
|
|
103
|
+
else response["result"]
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
_reasoning, is_finished, unfinished_cost, _unfinished_model = unfinished_prompt(
|
|
96
107
|
prompt_text=last_600_chars,
|
|
97
|
-
strength=0.
|
|
108
|
+
strength=0.89,
|
|
98
109
|
temperature=temperature,
|
|
99
110
|
time=time,
|
|
100
|
-
verbose=False
|
|
111
|
+
verbose=False,
|
|
101
112
|
)
|
|
102
|
-
|
|
113
|
+
|
|
103
114
|
total_cost += unfinished_cost
|
|
104
115
|
|
|
105
116
|
if not is_finished:
|
|
106
117
|
console.print("[yellow]Generation incomplete. Continuing...[/yellow]")
|
|
107
118
|
continued_output, continued_cost, continued_model = continue_generation(
|
|
108
119
|
formatted_input_prompt=prompt_template,
|
|
109
|
-
llm_output=response[
|
|
120
|
+
llm_output=response["result"],
|
|
110
121
|
strength=strength,
|
|
111
122
|
temperature=temperature,
|
|
112
123
|
time=time,
|
|
113
|
-
verbose=True
|
|
124
|
+
verbose=True,
|
|
114
125
|
)
|
|
115
126
|
total_cost += continued_cost
|
|
116
127
|
final_model_name = continued_model
|
|
117
128
|
result = continued_output
|
|
118
129
|
else:
|
|
119
|
-
result = response[
|
|
130
|
+
result = response["result"]
|
|
120
131
|
|
|
121
132
|
# Post-process the result
|
|
122
|
-
|
|
123
|
-
if not language or not isinstance(language, str):
|
|
124
|
-
language = "python" # Ensure language is valid
|
|
125
|
-
console.print("[yellow]Warning: Language value became invalid during processing, defaulting to 'python'[/yellow]")
|
|
126
|
-
|
|
127
|
-
final_code, postprocess_cost, postprocess_model = postprocess(
|
|
133
|
+
final_code, postprocess_cost, _postprocess_model = postprocess(
|
|
128
134
|
result,
|
|
129
135
|
language,
|
|
130
136
|
strength=EXTRACTION_STRENGTH,
|
|
131
137
|
temperature=temperature,
|
|
132
138
|
time=time,
|
|
133
|
-
verbose=True
|
|
139
|
+
verbose=True,
|
|
134
140
|
)
|
|
135
141
|
total_cost += postprocess_cost
|
|
136
142
|
|
|
@@ -139,10 +145,11 @@ def bug_to_unit_test(
|
|
|
139
145
|
|
|
140
146
|
return final_code, total_cost, final_model_name
|
|
141
147
|
|
|
142
|
-
except Exception as
|
|
143
|
-
console.print(f"[bold red]Error: {str(
|
|
148
|
+
except Exception as ex: # pylint: disable=broad-except
|
|
149
|
+
console.print(f"[bold red]Error: {str(ex)}[/bold red]")
|
|
144
150
|
return "", 0.0, ""
|
|
145
151
|
|
|
152
|
+
|
|
146
153
|
def main():
|
|
147
154
|
"""Example usage of the bug_to_unit_test function"""
|
|
148
155
|
try:
|
|
@@ -161,7 +168,7 @@ def add_numbers(a, b):
|
|
|
161
168
|
prompt_used_to_generate_the_code=prompt,
|
|
162
169
|
code_under_test=code,
|
|
163
170
|
program_used_to_run_code_under_test=program,
|
|
164
|
-
time=DEFAULT_TIME
|
|
171
|
+
time=DEFAULT_TIME,
|
|
165
172
|
)
|
|
166
173
|
|
|
167
174
|
if unit_test:
|
|
@@ -170,8 +177,9 @@ def add_numbers(a, b):
|
|
|
170
177
|
console.print(f"[bold blue]Total Cost: ${cost:.6f}[/bold blue]")
|
|
171
178
|
console.print(f"[bold blue]Model Used: {model}[/bold blue]")
|
|
172
179
|
|
|
173
|
-
except Exception as
|
|
174
|
-
console.print(f"[bold red]Error in main: {str(
|
|
180
|
+
except Exception as ex: # pylint: disable=broad-except
|
|
181
|
+
console.print(f"[bold red]Error in main: {str(ex)}[/bold red]")
|
|
182
|
+
|
|
175
183
|
|
|
176
184
|
if __name__ == "__main__":
|
|
177
|
-
main()
|
|
185
|
+
main()
|
pdd/change.py
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This module provides functionality to modify a prompt according to specified changes.
|
|
3
|
+
It takes an input prompt, input code, and change instructions to generate a modified prompt.
|
|
4
|
+
"""
|
|
1
5
|
from typing import Tuple
|
|
2
6
|
from rich.console import Console
|
|
3
7
|
from rich.markdown import Markdown
|
|
@@ -11,16 +15,17 @@ from . import EXTRACTION_STRENGTH, DEFAULT_STRENGTH, DEFAULT_TIME
|
|
|
11
15
|
console = Console()
|
|
12
16
|
|
|
13
17
|
class ExtractedPrompt(BaseModel):
|
|
18
|
+
"""Pydantic model for extracting the modified prompt from LLM output."""
|
|
14
19
|
modified_prompt: str = Field(description="The extracted modified prompt")
|
|
15
20
|
|
|
16
|
-
def change(
|
|
21
|
+
def change( # pylint: disable=too-many-arguments, too-many-locals
|
|
17
22
|
input_prompt: str,
|
|
18
23
|
input_code: str,
|
|
19
24
|
change_prompt: str,
|
|
20
25
|
strength: float = DEFAULT_STRENGTH,
|
|
21
26
|
temperature: float = 0.0,
|
|
22
27
|
time: float = DEFAULT_TIME,
|
|
23
|
-
budget: float = 5.0, #
|
|
28
|
+
budget: float = 5.0, # pylint: disable=unused-argument
|
|
24
29
|
verbose: bool = False
|
|
25
30
|
) -> Tuple[str, float, str]:
|
|
26
31
|
"""
|
|
@@ -33,7 +38,7 @@ def change(
|
|
|
33
38
|
strength (float): The strength parameter for the LLM model (0-1)
|
|
34
39
|
temperature (float): The temperature parameter for the LLM model
|
|
35
40
|
time (float): The time budget for LLM calls.
|
|
36
|
-
budget (float): The budget for the operation (
|
|
41
|
+
budget (float): The budget for the operation (not used, but kept for API compatibility).
|
|
37
42
|
verbose (bool): Whether to print out detailed information.
|
|
38
43
|
|
|
39
44
|
Returns:
|
|
@@ -48,13 +53,15 @@ def change(
|
|
|
48
53
|
raise ValueError("Failed to load prompt templates")
|
|
49
54
|
|
|
50
55
|
# Step 2: Preprocess the change_LLM prompt
|
|
51
|
-
processed_change_llm_template = preprocess(change_llm_prompt_template,
|
|
52
|
-
|
|
56
|
+
processed_change_llm_template = preprocess(change_llm_prompt_template,
|
|
57
|
+
recursive=False, double_curly_brackets=False)
|
|
58
|
+
processed_change_prompt_content = preprocess(change_prompt,
|
|
59
|
+
recursive=False, double_curly_brackets=False)
|
|
53
60
|
|
|
54
61
|
# Input validation
|
|
55
62
|
if not all([input_prompt, input_code, processed_change_prompt_content]):
|
|
56
63
|
raise ValueError("Missing required input parameters after preprocessing")
|
|
57
|
-
if not
|
|
64
|
+
if not 0 <= strength <= 1:
|
|
58
65
|
raise ValueError("Strength must be between 0 and 1")
|
|
59
66
|
|
|
60
67
|
total_cost = 0.0
|
|
@@ -115,10 +122,10 @@ def change(
|
|
|
115
122
|
# Step 7: Return results
|
|
116
123
|
return modified_prompt, total_cost, final_model_name
|
|
117
124
|
|
|
118
|
-
except Exception as
|
|
125
|
+
except Exception as error:
|
|
119
126
|
# Conditionally print error if verbose
|
|
120
|
-
if verbose:
|
|
121
|
-
console.print(f"[red]Error in change function: {str(
|
|
127
|
+
if verbose:
|
|
128
|
+
console.print(f"[red]Error in change function: {str(error)}[/red]")
|
|
122
129
|
raise
|
|
123
130
|
|
|
124
131
|
def main():
|
|
@@ -128,7 +135,7 @@ def main():
|
|
|
128
135
|
input_prompt_content = "Write a function that adds two numbers"
|
|
129
136
|
input_code_content = "def add(a, b):\n return a + b"
|
|
130
137
|
change_prompt_content = "Make the function handle negative numbers explicitly"
|
|
131
|
-
|
|
138
|
+
|
|
132
139
|
modified_prompt, cost, model = change(
|
|
133
140
|
input_prompt=input_prompt_content,
|
|
134
141
|
input_code=input_code_content,
|
|
@@ -145,8 +152,8 @@ def main():
|
|
|
145
152
|
console.print(f"Total Cost: ${cost:.6f}")
|
|
146
153
|
console.print(f"Model Used: {model}")
|
|
147
154
|
|
|
148
|
-
except Exception as
|
|
149
|
-
console.print(f"[red]Error in main: {str(
|
|
155
|
+
except Exception as error: # pylint: disable=broad-except
|
|
156
|
+
console.print(f"[red]Error in main: {str(error)}[/red]")
|
|
150
157
|
|
|
151
158
|
if __name__ == "__main__":
|
|
152
|
-
main()
|
|
159
|
+
main()
|