pdd-cli 0.0.23__py3-none-any.whl → 0.0.25__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 +7 -1
- pdd/bug_main.py +21 -3
- pdd/bug_to_unit_test.py +16 -5
- pdd/change.py +2 -1
- pdd/change_main.py +407 -189
- pdd/cli.py +853 -301
- pdd/code_generator.py +2 -1
- pdd/conflicts_in_prompts.py +2 -1
- pdd/construct_paths.py +377 -222
- pdd/context_generator.py +2 -1
- pdd/continue_generation.py +3 -2
- pdd/crash_main.py +55 -20
- pdd/data/llm_model.csv +8 -8
- pdd/detect_change.py +2 -1
- pdd/fix_code_loop.py +465 -160
- pdd/fix_code_module_errors.py +7 -4
- pdd/fix_error_loop.py +9 -9
- pdd/fix_errors_from_unit_tests.py +207 -365
- pdd/fix_main.py +31 -4
- pdd/fix_verification_errors.py +285 -0
- pdd/fix_verification_errors_loop.py +975 -0
- pdd/fix_verification_main.py +412 -0
- pdd/generate_output_paths.py +427 -183
- pdd/generate_test.py +3 -2
- pdd/increase_tests.py +2 -2
- pdd/llm_invoke.py +18 -8
- pdd/pdd_completion.zsh +38 -1
- pdd/preprocess.py +3 -3
- pdd/process_csv_change.py +466 -154
- pdd/prompts/extract_prompt_split_LLM.prompt +7 -4
- pdd/prompts/extract_prompt_update_LLM.prompt +11 -5
- pdd/prompts/extract_unit_code_fix_LLM.prompt +2 -2
- pdd/prompts/find_verification_errors_LLM.prompt +25 -0
- pdd/prompts/fix_code_module_errors_LLM.prompt +29 -0
- pdd/prompts/fix_errors_from_unit_tests_LLM.prompt +5 -5
- pdd/prompts/fix_verification_errors_LLM.prompt +20 -0
- pdd/prompts/generate_test_LLM.prompt +9 -3
- pdd/prompts/split_LLM.prompt +3 -3
- pdd/prompts/update_prompt_LLM.prompt +3 -3
- pdd/split.py +13 -12
- pdd/split_main.py +22 -13
- pdd/trace_main.py +7 -0
- pdd/xml_tagger.py +2 -1
- {pdd_cli-0.0.23.dist-info → pdd_cli-0.0.25.dist-info}/METADATA +4 -4
- {pdd_cli-0.0.23.dist-info → pdd_cli-0.0.25.dist-info}/RECORD +49 -44
- {pdd_cli-0.0.23.dist-info → pdd_cli-0.0.25.dist-info}/WHEEL +1 -1
- {pdd_cli-0.0.23.dist-info → pdd_cli-0.0.25.dist-info}/entry_points.txt +0 -0
- {pdd_cli-0.0.23.dist-info → pdd_cli-0.0.25.dist-info}/licenses/LICENSE +0 -0
- {pdd_cli-0.0.23.dist-info → pdd_cli-0.0.25.dist-info}/top_level.txt +0 -0
pdd/fix_code_module_errors.py
CHANGED
|
@@ -4,6 +4,7 @@ from rich import print
|
|
|
4
4
|
from rich.markdown import Markdown
|
|
5
5
|
from .load_prompt_template import load_prompt_template
|
|
6
6
|
from .llm_invoke import llm_invoke
|
|
7
|
+
from . import EXTRACTION_STRENGTH
|
|
7
8
|
import json
|
|
8
9
|
|
|
9
10
|
class CodeFix(BaseModel):
|
|
@@ -37,7 +38,7 @@ def fix_code_module_errors(
|
|
|
37
38
|
strength: float,
|
|
38
39
|
temperature: float = 0,
|
|
39
40
|
verbose: bool = False
|
|
40
|
-
) -> Tuple[bool, bool, str, str, float, str]:
|
|
41
|
+
) -> Tuple[bool, bool, str, str, str, float, str]:
|
|
41
42
|
"""
|
|
42
43
|
Fix errors in a code module that caused a program to crash and/or have errors.
|
|
43
44
|
"""
|
|
@@ -76,15 +77,16 @@ def fix_code_module_errors(
|
|
|
76
77
|
|
|
77
78
|
total_cost += first_response.get('cost', 0)
|
|
78
79
|
model_name = first_response.get('model_name', '')
|
|
80
|
+
program_code_fix = first_response['result']
|
|
79
81
|
|
|
80
82
|
if verbose:
|
|
81
83
|
print("[green]Error analysis complete[/green]")
|
|
82
|
-
print(Markdown(
|
|
84
|
+
print(Markdown(program_code_fix))
|
|
83
85
|
print(f"[yellow]Current cost: ${total_cost:.6f}[/yellow]")
|
|
84
86
|
|
|
85
87
|
# Step 4: Second LLM invoke for code extraction
|
|
86
88
|
extract_input = {
|
|
87
|
-
"program_code_fix":
|
|
89
|
+
"program_code_fix": program_code_fix,
|
|
88
90
|
"program": program,
|
|
89
91
|
"code": code
|
|
90
92
|
}
|
|
@@ -95,7 +97,7 @@ def fix_code_module_errors(
|
|
|
95
97
|
second_response = llm_invoke(
|
|
96
98
|
prompt=extract_prompt,
|
|
97
99
|
input_json=extract_input,
|
|
98
|
-
strength=
|
|
100
|
+
strength=EXTRACTION_STRENGTH, # Fixed strength for extraction
|
|
99
101
|
temperature=temperature,
|
|
100
102
|
verbose=verbose,
|
|
101
103
|
output_pydantic=CodeFix
|
|
@@ -128,6 +130,7 @@ def fix_code_module_errors(
|
|
|
128
130
|
result.update_code,
|
|
129
131
|
result.fixed_program,
|
|
130
132
|
result.fixed_code,
|
|
133
|
+
program_code_fix,
|
|
131
134
|
total_cost,
|
|
132
135
|
model_name
|
|
133
136
|
)
|
pdd/fix_error_loop.py
CHANGED
|
@@ -18,7 +18,7 @@ def escape_brackets(text: str) -> str:
|
|
|
18
18
|
"""Escape square brackets so Rich doesn't misinterpret them."""
|
|
19
19
|
return text.replace("[", "\\[").replace("]", "\\]")
|
|
20
20
|
|
|
21
|
-
def run_pytest_on_file(test_file: str) ->
|
|
21
|
+
def run_pytest_on_file(test_file: str) -> tuple[int, int, int, str]:
|
|
22
22
|
"""
|
|
23
23
|
Run pytest on the specified test file using subprocess.
|
|
24
24
|
Returns a tuple: (failures, errors, warnings, logs)
|
|
@@ -63,9 +63,9 @@ def format_log_for_output(log_structure):
|
|
|
63
63
|
|
|
64
64
|
# Initial test output (only for first iteration)
|
|
65
65
|
if log_structure["iterations"] and "initial_test_output" in log_structure["iterations"][0]:
|
|
66
|
-
formatted_text +=
|
|
66
|
+
formatted_text += "<pytest_output iteration=1>\n"
|
|
67
67
|
formatted_text += f"{log_structure['iterations'][0]['initial_test_output']}\n"
|
|
68
|
-
formatted_text +=
|
|
68
|
+
formatted_text += "</pytest_output>\n\n"
|
|
69
69
|
|
|
70
70
|
for i, iteration in enumerate(log_structure["iterations"]):
|
|
71
71
|
formatted_text += f"=== Attempt iteration {iteration['number']} ===\n\n"
|
|
@@ -74,23 +74,23 @@ def format_log_for_output(log_structure):
|
|
|
74
74
|
if iteration.get("fix_attempt"):
|
|
75
75
|
formatted_text += f"<fix_attempt iteration={iteration['number']}>\n"
|
|
76
76
|
formatted_text += f"{iteration['fix_attempt']}\n"
|
|
77
|
-
formatted_text +=
|
|
77
|
+
formatted_text += "</fix_attempt>\n\n"
|
|
78
78
|
|
|
79
79
|
# Verification with XML tags
|
|
80
80
|
if iteration.get("verification"):
|
|
81
81
|
formatted_text += f"<verification_output iteration={iteration['number']}>\n"
|
|
82
82
|
formatted_text += f"{iteration['verification']}\n"
|
|
83
|
-
formatted_text +=
|
|
83
|
+
formatted_text += "</verification_output>\n\n"
|
|
84
84
|
|
|
85
85
|
# Post-fix test results (except for last iteration to avoid duplication)
|
|
86
86
|
if i < len(log_structure["iterations"]) - 1 and iteration.get("post_test_output"):
|
|
87
87
|
formatted_text += f"<pytest_output iteration={iteration['number']+1}>\n"
|
|
88
88
|
formatted_text += f"{iteration['post_test_output']}\n"
|
|
89
|
-
formatted_text +=
|
|
89
|
+
formatted_text += "</pytest_output>\n\n"
|
|
90
90
|
|
|
91
91
|
# Final run (using last iteration's post-test output)
|
|
92
92
|
if log_structure["iterations"] and log_structure["iterations"][-1].get("post_test_output"):
|
|
93
|
-
formatted_text +=
|
|
93
|
+
formatted_text += "=== Final Pytest Run ===\n"
|
|
94
94
|
formatted_text += f"{log_structure['iterations'][-1]['post_test_output']}\n"
|
|
95
95
|
|
|
96
96
|
return formatted_text
|
|
@@ -343,7 +343,7 @@ def fix_error_loop(unit_test_file: str,
|
|
|
343
343
|
fix_attempts += 1 # We used one fix attempt
|
|
344
344
|
total_cost += cost
|
|
345
345
|
if verbose:
|
|
346
|
-
rprint(f"[cyan]Iteration
|
|
346
|
+
rprint(f"[cyan]Iteration {iteration} Fix Cost: ${cost:.6f}, Cumulative Total Cost: ${total_cost:.6f}[/cyan]")
|
|
347
347
|
if total_cost > budget:
|
|
348
348
|
rprint(f"[red]Exceeded the budget of ${budget:.6f}. Ending fixing loop.[/red]")
|
|
349
349
|
break
|
|
@@ -539,7 +539,7 @@ if __name__ == "__main__":
|
|
|
539
539
|
verbose
|
|
540
540
|
)
|
|
541
541
|
|
|
542
|
-
rprint(
|
|
542
|
+
rprint("\n[bold]Process complete.[/bold]")
|
|
543
543
|
rprint(f"Success: {success}")
|
|
544
544
|
rprint(f"Attempts: {attempts}")
|
|
545
545
|
rprint(f"Total cost: ${total_cost:.6f}")
|