pdd-cli 0.0.45__py3-none-any.whl → 0.0.90__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.
- pdd/__init__.py +4 -4
- pdd/agentic_common.py +863 -0
- pdd/agentic_crash.py +534 -0
- pdd/agentic_fix.py +1179 -0
- pdd/agentic_langtest.py +162 -0
- pdd/agentic_update.py +370 -0
- pdd/agentic_verify.py +183 -0
- pdd/auto_deps_main.py +15 -5
- pdd/auto_include.py +63 -5
- pdd/bug_main.py +3 -2
- pdd/bug_to_unit_test.py +2 -0
- pdd/change_main.py +11 -4
- pdd/cli.py +22 -1181
- pdd/cmd_test_main.py +73 -21
- pdd/code_generator.py +58 -18
- pdd/code_generator_main.py +672 -25
- pdd/commands/__init__.py +42 -0
- pdd/commands/analysis.py +248 -0
- pdd/commands/fix.py +140 -0
- pdd/commands/generate.py +257 -0
- pdd/commands/maintenance.py +174 -0
- pdd/commands/misc.py +79 -0
- pdd/commands/modify.py +230 -0
- pdd/commands/report.py +144 -0
- pdd/commands/templates.py +215 -0
- pdd/commands/utility.py +110 -0
- pdd/config_resolution.py +58 -0
- pdd/conflicts_main.py +8 -3
- pdd/construct_paths.py +258 -82
- pdd/context_generator.py +10 -2
- pdd/context_generator_main.py +113 -11
- pdd/continue_generation.py +47 -7
- pdd/core/__init__.py +0 -0
- pdd/core/cli.py +503 -0
- pdd/core/dump.py +554 -0
- pdd/core/errors.py +63 -0
- pdd/core/utils.py +90 -0
- pdd/crash_main.py +44 -11
- pdd/data/language_format.csv +71 -63
- pdd/data/llm_model.csv +20 -18
- pdd/detect_change_main.py +5 -4
- pdd/fix_code_loop.py +330 -76
- pdd/fix_error_loop.py +207 -61
- pdd/fix_errors_from_unit_tests.py +4 -3
- pdd/fix_main.py +75 -18
- pdd/fix_verification_errors.py +12 -100
- pdd/fix_verification_errors_loop.py +306 -272
- pdd/fix_verification_main.py +28 -9
- pdd/generate_output_paths.py +93 -10
- pdd/generate_test.py +16 -5
- pdd/get_jwt_token.py +9 -2
- pdd/get_run_command.py +73 -0
- pdd/get_test_command.py +68 -0
- pdd/git_update.py +70 -19
- pdd/incremental_code_generator.py +2 -2
- pdd/insert_includes.py +11 -3
- pdd/llm_invoke.py +1269 -103
- pdd/load_prompt_template.py +36 -10
- pdd/pdd_completion.fish +25 -2
- pdd/pdd_completion.sh +30 -4
- pdd/pdd_completion.zsh +79 -4
- pdd/postprocess.py +10 -3
- pdd/preprocess.py +228 -15
- pdd/preprocess_main.py +8 -5
- pdd/prompts/agentic_crash_explore_LLM.prompt +49 -0
- pdd/prompts/agentic_fix_explore_LLM.prompt +45 -0
- pdd/prompts/agentic_fix_harvest_only_LLM.prompt +48 -0
- pdd/prompts/agentic_fix_primary_LLM.prompt +85 -0
- pdd/prompts/agentic_update_LLM.prompt +1071 -0
- pdd/prompts/agentic_verify_explore_LLM.prompt +45 -0
- pdd/prompts/auto_include_LLM.prompt +100 -905
- pdd/prompts/detect_change_LLM.prompt +122 -20
- pdd/prompts/example_generator_LLM.prompt +22 -1
- pdd/prompts/extract_code_LLM.prompt +5 -1
- pdd/prompts/extract_program_code_fix_LLM.prompt +7 -1
- pdd/prompts/extract_prompt_update_LLM.prompt +7 -8
- pdd/prompts/extract_promptline_LLM.prompt +17 -11
- pdd/prompts/find_verification_errors_LLM.prompt +6 -0
- pdd/prompts/fix_code_module_errors_LLM.prompt +4 -2
- pdd/prompts/fix_errors_from_unit_tests_LLM.prompt +8 -0
- pdd/prompts/fix_verification_errors_LLM.prompt +22 -0
- pdd/prompts/generate_test_LLM.prompt +21 -6
- pdd/prompts/increase_tests_LLM.prompt +1 -5
- pdd/prompts/insert_includes_LLM.prompt +228 -108
- pdd/prompts/trace_LLM.prompt +25 -22
- pdd/prompts/unfinished_prompt_LLM.prompt +85 -1
- pdd/prompts/update_prompt_LLM.prompt +22 -1
- pdd/pytest_output.py +127 -12
- pdd/render_mermaid.py +236 -0
- pdd/setup_tool.py +648 -0
- pdd/simple_math.py +2 -0
- pdd/split_main.py +3 -2
- pdd/summarize_directory.py +49 -6
- pdd/sync_determine_operation.py +543 -98
- pdd/sync_main.py +81 -31
- pdd/sync_orchestration.py +1334 -751
- pdd/sync_tui.py +848 -0
- pdd/template_registry.py +264 -0
- pdd/templates/architecture/architecture_json.prompt +242 -0
- pdd/templates/generic/generate_prompt.prompt +174 -0
- pdd/trace.py +168 -12
- pdd/trace_main.py +4 -3
- pdd/track_cost.py +151 -61
- pdd/unfinished_prompt.py +49 -3
- pdd/update_main.py +549 -67
- pdd/update_model_costs.py +2 -2
- pdd/update_prompt.py +19 -4
- {pdd_cli-0.0.45.dist-info → pdd_cli-0.0.90.dist-info}/METADATA +19 -6
- pdd_cli-0.0.90.dist-info/RECORD +153 -0
- {pdd_cli-0.0.45.dist-info → pdd_cli-0.0.90.dist-info}/licenses/LICENSE +1 -1
- pdd_cli-0.0.45.dist-info/RECORD +0 -116
- {pdd_cli-0.0.45.dist-info → pdd_cli-0.0.90.dist-info}/WHEEL +0 -0
- {pdd_cli-0.0.45.dist-info → pdd_cli-0.0.90.dist-info}/entry_points.txt +0 -0
- {pdd_cli-0.0.45.dist-info → pdd_cli-0.0.90.dist-info}/top_level.txt +0 -0
|
@@ -16,8 +16,19 @@
|
|
|
16
16
|
<example>
|
|
17
17
|
<input_example>
|
|
18
18
|
<prompt_list_example>
|
|
19
|
-
[{"PROMPT_NAME": "change_python.prompt", "PROMPT_DESCRIPTION": "% You are an expert Python Software Engineer. Your goal is to write a Python function, \"change\", that will modify an input_prompt into a modified_prompt per the change_prompt. All output to the console will be pretty printed using the Python Rich library. Ensure that the module imports are done using relative imports.\n\n% Here are the inputs and outputs of the function:\n Inputs:\n - 'input_prompt' - A string that contains the prompt that will be modified by the change_prompt.\n - 'input_code' - A string that contains the code that was generated from the input_prompt.\n - 'change_prompt' - A string that contains the instructions of how to modify the input_prompt.\n - 'strength': A float value representing the strength parameter for the LLM model, used to influence the model's behavior.\n - 'temperature': A float value representing the temperature parameter for the LLM model, used to control the randomness of the model's output.\n Outputs:\n - 'modified_prompt' - A string that contains the modified prompt that was changed based on the change_prompt.\n - 'total_cost': A float value representing the total cost of running the function.\n - 'model_name': A string representing the name of the selected LLM model.\n\n% Here is an example how to preprocess the prompt from a file: ```<./context/preprocess_example.py>```\n\n% Example usage of the Langchain LCEL program: ```<./context/langchain_lcel_example.py>```\n\n% Example of selecting a Langchain LLM and counting tokens using llm_selector: ```<./context/llm_selector_example.py>```\n\n% Steps to be followed by the function:\n 1. Load the '$PDD_PATH/prompts/xml/change_LLM.prompt' and '$PDD_PATH/prompts/extract_prompt_change_LLM.prompt' files.\n 2. Preprocess the change_LLM prompt using the preprocess function from the preprocess module and set double_curly_brackets to false.\n 3. Create a Langchain LCEL template from the processed change_LLM prompt to return a string output. \n 4. Use the llm_selector function for the LLM model and token counting.\n 5. Run the input_prompt through the model using Langchain LCEL:\n - a. Pass the following string parameters to the prompt during invocation: \n * 'input_prompt'\n * 'input_code'\n * 'change_prompt' (preprocess this with double_curly_brackets set to false)\n - b. Calculate the input and output token count using token_counter from llm_selector and pretty print the output of 4a, including the token count and estimated cost. The cost from llm_selector is in dollars per million tokens.\n 6. Create a Langchain LCEL template with strength .9 from the extract_prompt_change_LLM prompt that outputs JSON:\n - a. Pass the following string parameters to the prompt during invocation: 'llm_output' (this string is from Step 4).\n - b. Calculate input and output token count using token_counter from llm_selector and pretty print the running message with the token count and cost.\n - c. Use 'get' function to extract 'modified_prompt' key values using from the dictionary output.\n 7. Pretty print the extracted modified_prompt using Rich Markdown function. Include token counts and costs.\n 8. Return the 'modified_prompt' string, the total_cost of both invokes and model_name use for the change_LLM prompt.\n\n% Ensure the function handles edge cases, such as missing inputs or model errors, and provide clear error messages."}, {"PROMPT_NAME": "preprocess_python.prompt", "PROMPT_DESCRIPTION": "% You are an expert Python engineer. Your goal is to write a Python function, 'preprocess_prompt', that will preprocess the prompt from a prompt string for a LLM. This will use regular expressions to preprocess specific XML-like tags, if any, in the prompt. All output to the console will be pretty print using the Python rich library.\n\n% Here are the inputs and outputs of the function:\n Input: \n 'prompt' - A string that is the prompt to preprocess\n 'recursive' - A boolean that is True if the program needs to recursively process the includes in the prompt and False if it does not need to recursively process the prompt. Default is True.\n 'double_curly_brackets' - A boolean that is True if the curly brackets need to be doubled and False if they do not need to be doubled. Default is True.\n 'exclude_keys' - An optional list of strings that are excluded from the curly bracket doubling.\n Output: returns a string that is the preprocessed prompt, with any leading or trailing whitespace removed.\n\n% Here are the XML-like tags to preprocess, other tags will remain unmodified:\n 'include' - This tag will include the content of the file indicated in the include tag. The 'include tag' will be directly replaced with the content of the file in the prompt, without wrapping it in a new tag.\n 'pdd' - This tag indicates a comment and anything in this XML will be deleted from the string including the 'pdd' tags themselves.\n 'shell' - This tag indicates that there are shell commands to run. Capture all output of the shell commands and include it in the prompt but remove the shell tags.\n\n% Includes can be nested, that is there can be includes inside of the files of the includes and 'preprocess' should be called recursively on these include files if recursive is True. There are two ways of having includes in the prompt:\n 1. Will check to see if the file has any angle brackets in triple backticks. If so, it will read the included file indicated in the angle brackets and replace the angle brackets with the content of the included file. This will be done recursively until there are no more angle brackets in triple backticks. The program will then remove the angle brackets but leave the contents in the triple backticks.\n 2. The XML 'include' mentioned above.\n\n% If double_curly_brackets is True, the program will check to see if the file has any single curly brackets and if it does and the string in the curly brackets are not in the exclude_keys list, it will check to see if the curly brackets are already doubled before doubling the curly brackets.\n\n% The program should resolve file paths using the PDD_PATH environment variable. Implement a function 'get_file_path' that takes a file name and returns the full path using this environment variable.\n\n% Keep the user informed of the progress of the program by pretty printing messages."}, {"PROMPT_NAME": "unfinished_prompt_python.prompt", "PROMPT_DESCRIPTION": "% You are an expert Python engineer. Your goal is to write a python function called 'unfinished_prompt' that will determine if a given prompt is complete or needs to continue.\n\n% Here are the inputs and outputs of the function:\n Inputs:\n 'prompt_text' - A string containing the prompt text to analyze.\n 'strength' - A float that is the strength of the LLM model to use for the analysis. Default is 0.5.\n 'temperature' - A float that is the temperature of the LLM model to use for the analysis. Default is 0.\n Outputs:\n 'reasoning' - A string containing the structured reasoning for the completeness assessment.\n 'is_finished' - A boolean indicating whether the prompt is complete (True) or incomplete (False).\n 'total_cost' - A float that is the total cost of the analysis function. This is an optional output.\n 'model_name' - A string that is the name of the LLM model used for the analysis. This is an optional output.\n\n% Here is an example of a Langchain LCEL program: ```<./context/langchain_lcel_example.py>```\n\n% Here is an example how to select the Langchain llm and count tokens: ```<./context/llm_selector_example.py>```\n\n% Note: Use relative import for 'llm_selector' to ensure compatibility within the package structure (i.e. 'from .llm_selector') instead of 'from pdd.llm_selector'.\n\n% This function will do the following:\n Step 1. Use $PDD_PATH environment variable to get the path to the project. Load the '$PDD_PATH/prompts/unfinished_prompt_LLM.prompt' file.\n Step 2. Create a Langchain LCEL template from unfinished_prompt_LLM prompt so that it returns a JSON output.\n Step 3. Use the llm_selector function for the LLM model.\n Step 4. Run the prompt text through the model using Langchain LCEL.\n 4a. Pass the following string parameters to the prompt during invoke:\n - 'PROMPT_TEXT'\n 4b. Pretty print a message letting the user know it is running and how many tokens (using token_counter function from llm_selector) are in the prompt and the cost. The cost from llm_selector is in dollars per million tokens.\n 4c. The dictionary output of the LCEL will have the keys 'reasoning' and 'is_finished'. Be sure to access these keys using the get method with default error messages.\n 4d. Pretty print the reasoning and completion status using the rich library. Also, print the number of tokens in the result, the output token cost and the total_cost.\n Step 5. Return the 'reasoning' string and 'is_finished' boolean from the JSON output using 'get', and the 'total_cost' float, and 'model_name' string.\n\n% Ensure that the function handles potential errors gracefully, such as missing input parameters or issues with the LLM model responses.\n\n"}, {"PROMPT_NAME": "xml_tagger_python.prompt", "PROMPT_DESCRIPTION": "% You are an expert Python engineer. Your goal is to write a Python function, \"xml_tagger\", that will enhance a given LLM prompt by adding XML tags to improve its structure and readability.\n\n% The function should be part of a Python package, using relative imports (single dot) for internal modules (e.g. 'from .module_name import module_name'). All output to the console will be pretty printed using the Python Rich library. Ensure the function handles edge cases, such as missing inputs or model errors, and provide clear error messages.
|
|
20
|
-
|
|
19
|
+
[{"PROMPT_NAME": "change_python.prompt", "PROMPT_DESCRIPTION": "% You are an expert Python Software Engineer. Your goal is to write a Python function, \"change\", that will modify an input_prompt into a modified_prompt per the change_prompt. All output to the console will be pretty printed using the Python Rich library. Ensure that the module imports are done using relative imports.\n\n% Here are the inputs and outputs of the function:\n Inputs:\n - 'input_prompt' - A string that contains the prompt that will be modified by the change_prompt.\n - 'input_code' - A string that contains the code that was generated from the input_prompt.\n - 'change_prompt' - A string that contains the instructions of how to modify the input_prompt.\n - 'strength': A float value representing the strength parameter for the LLM model, used to influence the model's behavior.\n - 'temperature': A float value representing the temperature parameter for the LLM model, used to control the randomness of the model's output.\n Outputs:\n - 'modified_prompt' - A string that contains the modified prompt that was changed based on the change_prompt.\n - 'total_cost': A float value representing the total cost of running the function.\n - 'model_name': A string representing the name of the selected LLM model.\n\n% Here is an example how to preprocess the prompt from a file: ```<./context/preprocess_example.py>```\n\n% Example usage of the Langchain LCEL program: ```<./context/langchain_lcel_example.py>```\n\n% Example of selecting a Langchain LLM and counting tokens using llm_selector: ```<./context/llm_selector_example.py>```\n\n% Steps to be followed by the function:\n 1. Load the '$PDD_PATH/prompts/xml/change_LLM.prompt' and '$PDD_PATH/prompts/extract_prompt_change_LLM.prompt' files.\n 2. Preprocess the change_LLM prompt using the preprocess function from the preprocess module and set double_curly_brackets to false.\n 3. Create a Langchain LCEL template from the processed change_LLM prompt to return a string output. \n 4. Use the llm_selector function for the LLM model and token counting.\n 5. Run the input_prompt through the model using Langchain LCEL:\n - a. Pass the following string parameters to the prompt during invocation: \n * 'input_prompt'\n * 'input_code'\n * 'change_prompt' (preprocess this with double_curly_brackets set to false)\n - b. Calculate the input and output token count using token_counter from llm_selector and pretty print the output of 4a, including the token count and estimated cost. The cost from llm_selector is in dollars per million tokens.\n 6. Create a Langchain LCEL template with strength .9 from the extract_prompt_change_LLM prompt that outputs JSON:\n - a. Pass the following string parameters to the prompt during invocation: 'llm_output' (this string is from Step 4).\n - b. Calculate input and output token count using token_counter from llm_selector and pretty print the running message with the token count and cost.\n - c. Use 'get' function to extract 'modified_prompt' key values using from the dictionary output.\n 7. Pretty print the extracted modified_prompt using Rich Markdown function. Include token counts and costs.\n 8. Return the 'modified_prompt' string, the total_cost of both invokes and model_name use for the change_LLM prompt.\n\n% Ensure the function handles edge cases, such as missing inputs or model errors, and provide clear error messages."}, {"PROMPT_NAME": "preprocess_python.prompt", "PROMPT_DESCRIPTION": "% You are an expert Python engineer. Your goal is to write a Python function, 'preprocess_prompt', that will preprocess the prompt from a prompt string for a LLM. This will use regular expressions to preprocess specific XML-like tags, if any, in the prompt. All output to the console will be pretty print using the Python rich library.\n\n% Here are the inputs and outputs of the function:\n Input: \n 'prompt' - A string that is the prompt to preprocess\n 'recursive' - A boolean that is True if the program needs to recursively process the includes in the prompt and False if it does not need to recursively process the prompt. Default is True.\n 'double_curly_brackets' - A boolean that is True if the curly brackets need to be doubled and False if they do not need to be doubled. Default is True.\n 'exclude_keys' - An optional list of strings that are excluded from the curly bracket doubling.\n Output: returns a string that is the preprocessed prompt, with any leading or trailing whitespace removed.\n\n% Here are the XML-like tags to preprocess, other tags will remain unmodified:\n 'include' - This tag will include the content of the file indicated in the include tag. The 'include tag' will be directly replaced with the content of the file in the prompt, without wrapping it in a new tag.\n 'pdd' - This tag indicates a comment and anything in this XML will be deleted from the string including the 'pdd' tags themselves.\n 'shell' - This tag indicates that there are shell commands to run. Capture all output of the shell commands and include it in the prompt but remove the shell tags.\n\n% Includes can be nested, that is there can be includes inside of the files of the includes and 'preprocess' should be called recursively on these include files if recursive is True. There are two ways of having includes in the prompt:\n 1. Will check to see if the file has any angle brackets in triple backticks. If so, it will read the included file indicated in the angle brackets and replace the angle brackets with the content of the included file. This will be done recursively until there are no more angle brackets in triple backticks. The program will then remove the angle brackets but leave the contents in the triple backticks.\n 2. The XML 'include' mentioned above.\n\n% If double_curly_brackets is True, the program will check to see if the file has any single curly brackets and if it does and the string in the curly brackets are not in the exclude_keys list, it will check to see if the curly brackets are already doubled before doubling the curly brackets.\n\n% The program should resolve file paths using the PDD_PATH environment variable. Implement a function 'get_file_path' that takes a file name and returns the full path using this environment variable.\n\n% Keep the user informed of the progress of the program by pretty printing messages."}, {"PROMPT_NAME": "unfinished_prompt_python.prompt", "PROMPT_DESCRIPTION": "% You are an expert Python engineer. Your goal is to write a python function called 'unfinished_prompt' that will determine if a given prompt is complete or needs to continue.\n\n% Here are the inputs and outputs of the function:\n Inputs:\n 'prompt_text' - A string containing the prompt text to analyze.\n 'strength' - A float that is the strength of the LLM model to use for the analysis. Default is 0.5.\n 'temperature' - A float that is the temperature of the LLM model to use for the analysis. Default is 0.\n Outputs:\n 'reasoning' - A string containing the structured reasoning for the completeness assessment.\n 'is_finished' - A boolean indicating whether the prompt is complete (True) or incomplete (False).\n 'total_cost' - A float that is the total cost of the analysis function. This is an optional output.\n 'model_name' - A string that is the name of the LLM model used for the analysis. This is an optional output.\n\n% Here is an example of a Langchain LCEL program: ```<./context/langchain_lcel_example.py>```\n\n% Here is an example how to select the Langchain llm and count tokens: ```<./context/llm_selector_example.py>```\n\n% Note: Use relative import for 'llm_selector' to ensure compatibility within the package structure (i.e. 'from .llm_selector') instead of 'from pdd.llm_selector'.\n\n% This function will do the following:\n Step 1. Use $PDD_PATH environment variable to get the path to the project. Load the '$PDD_PATH/prompts/unfinished_prompt_LLM.prompt' file.\n Step 2. Create a Langchain LCEL template from unfinished_prompt_LLM prompt so that it returns a JSON output.\n Step 3. Use the llm_selector function for the LLM model.\n Step 4. Run the prompt text through the model using Langchain LCEL.\n 4a. Pass the following string parameters to the prompt during invoke:\n - 'PROMPT_TEXT'\n 4b. Pretty print a message letting the user know it is running and how many tokens (using token_counter function from llm_selector) are in the prompt and the cost. The cost from llm_selector is in dollars per million tokens.\n 4c. The dictionary output of the LCEL will have the keys 'reasoning' and 'is_finished'. Be sure to access these keys using the get method with default error messages.\n 4d. Pretty print the reasoning and completion status using the rich library. Also, print the number of tokens in the result, the output token cost and the total_cost.\n Step 5. Return the 'reasoning' string and 'is_finished' boolean from the JSON output using 'get', and the 'total_cost' float, and 'model_name' string.\n\n% Ensure that the function handles potential errors gracefully, such as missing input parameters or issues with the LLM model responses.\n\n"}, {"PROMPT_NAME": "xml_tagger_python.prompt", "PROMPT_DESCRIPTION": "% You are an expert Python engineer. Your goal is to write a Python function, \"xml_tagger\", that will enhance a given LLM prompt by adding XML tags to improve its structure and readability.\n\n% You are an expert Python engineer.
|
|
20
|
+
|
|
21
|
+
% Code Style Requirements
|
|
22
|
+
- File must start with `from __future__ import annotations`.
|
|
23
|
+
- All functions must be fully type-hinted.
|
|
24
|
+
- Use `rich.console.Console` for all printing.
|
|
25
|
+
|
|
26
|
+
% Package Structure
|
|
27
|
+
- The function should be part of a Python package, using relative imports (single dot) for internal modules (e.g. 'from .module_name import module_name').
|
|
28
|
+
- The ./pdd/__init__.py file will have the EXTRACTION_STRENGTH, DEFAULT_STRENGTH, DEFAULT_TIME and other global constants. Example: ```from . import DEFAULT_STRENGTH```
|
|
29
|
+
|
|
30
|
+
% Error Handling
|
|
31
|
+
- Ensure the function handles edge cases, such as missing inputs or model errors, and provide clear error messages.\n\n% Here are the inputs and outputs of the function:\n Input: \n 'raw_prompt' - A string containing the prompt that needs XML tagging to improve its organization and clarity.\n 'strength' - A float value representing the strength parameter for the LLM model.\n 'temperature' - A float value representing the temperature parameter for the LLM model.\n Output: \n 'xml_tagged' - A string containing the prompt with properly added XML tags.\n 'total_cost' - A float representing the total cost of running the LCELs.\n 'model_name' - A string representing the name of the selected LLM model.\n\n% Here is an example of a LangChain Expression Language (LCEL) program: <lcel_example>import os
|
|
21
32
|
from langchain_core.prompts import PromptTemplate
|
|
22
33
|
from langchain_community.cache import SQLiteCache
|
|
23
34
|
from langchain_community.llms.mlx_pipeline import MLXPipeline
|
|
@@ -367,12 +378,59 @@ if __name__ == "__main__":
|
|
|
367
378
|
<change_description_example>
|
|
368
379
|
% Use context/python_preamble.prompt to make prompts more compact. Some prompts might already have this.
|
|
369
380
|
|
|
370
|
-
% Here is what is inside context/python_preamble.prompt:<preamble>%
|
|
371
|
-
|
|
381
|
+
% Here is what is inside context/python_preamble.prompt:<preamble>% You are an expert Python engineer.
|
|
382
|
+
|
|
383
|
+
% Code Style Requirements
|
|
384
|
+
- File must start with `from __future__ import annotations`.
|
|
385
|
+
- All functions must be fully type-hinted.
|
|
386
|
+
- Use `rich.console.Console` for all printing.
|
|
387
|
+
|
|
388
|
+
% Package Structure
|
|
389
|
+
- The function should be part of a Python package, using relative imports (single dot) for internal modules (e.g. 'from .module_name import module_name').
|
|
390
|
+
- The ./pdd/__init__.py file will have the EXTRACTION_STRENGTH, DEFAULT_STRENGTH, DEFAULT_TIME and other global constants. Example: ```from . import DEFAULT_STRENGTH```
|
|
391
|
+
|
|
392
|
+
% Error Handling
|
|
393
|
+
- Ensure the function handles edge cases, such as missing inputs or model errors, and provide clear error messages.</preamble>
|
|
372
394
|
|
|
373
395
|
% Here is an example of this being done: <example>% You are an expert Python engineer. Your goal is to write a python function, "code_generator", that will compile a prompt into a code file.
|
|
374
396
|
|
|
375
|
-
|
|
397
|
+
You are an expert Python engineer working on the PDD Cloud project.
|
|
398
|
+
|
|
399
|
+
-------------------------------------------------------------------------------
|
|
400
|
+
Python Coding Standards (PDD Cloud)
|
|
401
|
+
-------------------------------------------------------------------------------
|
|
402
|
+
|
|
403
|
+
## Style
|
|
404
|
+
- Python 3.12, PEP 8 compliant
|
|
405
|
+
- Type hints required (from typing import Optional, List, Dict, Any, Tuple)
|
|
406
|
+
- Imports: standard lib -> third-party -> local (alphabetical within groups)
|
|
407
|
+
|
|
408
|
+
## Critical First Import
|
|
409
|
+
import function_import_setup # MUST be first import
|
|
410
|
+
|
|
411
|
+
This enables subprocess module resolution for Firebase Functions Framework.
|
|
412
|
+
All endpoint files must have this as their very first import statement.
|
|
413
|
+
|
|
414
|
+
## Standard Library Imports
|
|
415
|
+
import os
|
|
416
|
+
import logging
|
|
417
|
+
|
|
418
|
+
## Error Handling Pattern
|
|
419
|
+
Map exceptions to HTTP status codes:
|
|
420
|
+
- AuthenticationError -> 401 Unauthorized
|
|
421
|
+
- AuthorizationError -> 403 Forbidden
|
|
422
|
+
- ValidationError -> 400 Bad Request
|
|
423
|
+
- ResourceNotFoundError -> 404 Not Found
|
|
424
|
+
- DatabaseError / Exception -> 500 Internal Server Error
|
|
425
|
+
|
|
426
|
+
All error responses: {"error": "descriptive message"}
|
|
427
|
+
|
|
428
|
+
## Logging
|
|
429
|
+
logger = logging.getLogger(__name__)
|
|
430
|
+
|
|
431
|
+
## Response Format
|
|
432
|
+
Return tuple: (response_dict, status_code)
|
|
433
|
+
|
|
376
434
|
|
|
377
435
|
% Here are the inputs and outputs of the function:
|
|
378
436
|
Inputs:
|
|
@@ -380,13 +438,13 @@ if __name__ == "__main__":
|
|
|
380
438
|
'language' - A string that is the language type (e.g. python, bash) of file that will be outputed by the LLM.
|
|
381
439
|
'strength' - A float between 0 and 1 that is the strength of the LLM model to use.
|
|
382
440
|
'temperature' - A float that is the temperature of the LLM model to use. Default is 0.
|
|
383
|
-
'time' - A float
|
|
441
|
+
'time' - A float in [0,1] or None that controls the thinking effort for the LLM model, passed to llm_invoke. Default is DEFAULT_TIME. If None, treat as DEFAULT_TIME before invoking llm_invoke.
|
|
384
442
|
'verbose' - A boolean that indicates whether to print out the details of the function. Default is False.
|
|
385
443
|
'preprocess_prompt' - A boolean that indicates whether to preprocess the prompt. Default is True.
|
|
386
444
|
Outputs:
|
|
387
445
|
'runnable_code' - A string that is runnable code
|
|
388
|
-
'total_cost' - A float that is the total cost of
|
|
389
|
-
'model_name' - A string that is the name of the selected LLM model
|
|
446
|
+
'total_cost' - A float that is the total cost of all LLM calls within this function (initial generation, unfinished check, continuation if used, and postprocess)
|
|
447
|
+
'model_name' - A string that is the name of the selected LLM model used for the main generation (or continuation). Postprocess may use a different model internally and does not change this value.
|
|
390
448
|
|
|
391
449
|
% Here is how to use the internal modules:
|
|
392
450
|
<internal_modules>
|
|
@@ -417,14 +475,25 @@ if __name__ == "__main__":
|
|
|
417
475
|
</internal_modules>
|
|
418
476
|
|
|
419
477
|
% This program will do the following:
|
|
420
|
-
Step 1. Conditionally preprocess the raw prompt using the preprocess function from the preprocess module based on the value of 'preprocess_prompt'. If 'preprocess_prompt' is True, preprocess the prompt; otherwise, use the raw prompt directly.
|
|
478
|
+
Step 1. Conditionally preprocess the raw prompt using the preprocess function from the preprocess module based on the value of 'preprocess_prompt'. If 'preprocess_prompt' is True, preprocess the prompt; otherwise, use the raw prompt directly. When preprocessing, it is acceptable to enable options such as double_curly_brackets=True and recursive=False to preserve placeholders and avoid over-expansion.
|
|
479
|
+
|
|
480
|
+
Step 2. Generate the initial response as follows:
|
|
481
|
+
- If the prompt contains embedded data URLs (e.g., 'data:image/...;base64,...'), split the prompt into alternating text and image parts (preserving order) and call llm_invoke with messages=[{role: 'user', content: [{type: 'image_url', image_url: {url: ...}}, {type: 'text', text: ...}, ...]}] and the provided strength, temperature, time, and verbose.
|
|
482
|
+
- Otherwise, call llm_invoke with the (preprocessed or raw) prompt, input_json={}, and the provided strength, temperature, time, and verbose.
|
|
483
|
+
|
|
484
|
+
Step 3. Detect if the generation is incomplete using the unfinished_prompt function (use strength=0.5, temperature=0.0) by passing in the last 600 characters of the output of Step 2. Pass through language, time, and verbose.
|
|
485
|
+
- a. If incomplete, call the continue_generation function to complete the generation and set final_output to that result.
|
|
486
|
+
- b. Else, set final_output to the initial model output.
|
|
487
|
+
|
|
488
|
+
Step 4. Postprocess the final_output using the postprocess function from the postprocess module with the EXTRACTION_STRENGTH constant. Use temperature=0.0 and pass through language, time, and verbose.
|
|
421
489
|
|
|
422
|
-
Step
|
|
490
|
+
Step 5. Return the runnable_code, total_cost and model_name.
|
|
423
491
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
492
|
+
% Validation and defaults:
|
|
493
|
+
- Validate non-empty 'prompt' and 'language'.
|
|
494
|
+
- Enforce 0 ≤ strength ≤ 1 and 0 ≤ temperature ≤ 2.
|
|
495
|
+
- Enforce 0 ≤ time ≤ 1 when provided; if time is None, substitute DEFAULT_TIME before llm_invoke.
|
|
496
|
+
</example>
|
|
428
497
|
</change_description_example>
|
|
429
498
|
</input_example>
|
|
430
499
|
|
|
@@ -465,24 +534,57 @@ if __name__ == "__main__":
|
|
|
465
534
|
- Insert the contents of the file `./context/python_preamble.prompt` immediately after the role and goal statement using 'include' XML tags.
|
|
466
535
|
- Remove any redundant instructions that are covered by the preamble, such as those related to pretty printing and handling edge cases.
|
|
467
536
|
- Ensure that the logical flow of the prompt is maintained and that any unique instructions specific to this prompt are retained.
|
|
468
|
-
- Here is what is inside context/python_preamble.prompt:<preamble>%
|
|
469
|
-
|
|
537
|
+
- Here is what is inside context/python_preamble.prompt:<preamble>% You are an expert Python engineer.
|
|
538
|
+
|
|
539
|
+
% Code Style Requirements
|
|
540
|
+
- File must start with `from __future__ import annotations`.
|
|
541
|
+
- All functions must be fully type-hinted.
|
|
542
|
+
- Use `rich.console.Console` for all printing.
|
|
543
|
+
|
|
544
|
+
% Package Structure
|
|
545
|
+
- The function should be part of a Python package, using relative imports (single dot) for internal modules (e.g. 'from .module_name import module_name').
|
|
546
|
+
- The ./pdd/__init__.py file will have the EXTRACTION_STRENGTH, DEFAULT_STRENGTH, DEFAULT_TIME and other global constants. Example: ```from . import DEFAULT_STRENGTH```
|
|
547
|
+
|
|
548
|
+
% Error Handling
|
|
549
|
+
- Ensure the function handles edge cases, such as missing inputs or model errors, and provide clear error messages.</preamble>
|
|
470
550
|
|
|
471
551
|
- **preprocess_python.prompt**
|
|
472
552
|
- **Instructions:**
|
|
473
553
|
- Insert the contents of the file `./context/python_preamble.prompt` immediately after the role and goal statement using 'include' XML tags.
|
|
474
554
|
- Remove any redundant instructions that are covered by the preamble, such as those related to pretty printing and handling edge cases.
|
|
475
555
|
- Ensure that the logical flow of the prompt is maintained and that any unique instructions specific to this prompt are retained.
|
|
476
|
-
- Here is what is inside context/python_preamble.prompt:<preamble>%
|
|
477
|
-
|
|
556
|
+
- Here is what is inside context/python_preamble.prompt:<preamble>% You are an expert Python engineer.
|
|
557
|
+
|
|
558
|
+
% Code Style Requirements
|
|
559
|
+
- File must start with `from __future__ import annotations`.
|
|
560
|
+
- All functions must be fully type-hinted.
|
|
561
|
+
- Use `rich.console.Console` for all printing.
|
|
562
|
+
|
|
563
|
+
% Package Structure
|
|
564
|
+
- The function should be part of a Python package, using relative imports (single dot) for internal modules (e.g. 'from .module_name import module_name').
|
|
565
|
+
- The ./pdd/__init__.py file will have the EXTRACTION_STRENGTH, DEFAULT_STRENGTH, DEFAULT_TIME and other global constants. Example: ```from . import DEFAULT_STRENGTH```
|
|
566
|
+
|
|
567
|
+
% Error Handling
|
|
568
|
+
- Ensure the function handles edge cases, such as missing inputs or model errors, and provide clear error messages.</preamble>
|
|
478
569
|
|
|
479
570
|
- **unfinished_prompt_python.prompt**
|
|
480
571
|
- **Instructions:**
|
|
481
572
|
- Insert the contents of the file `./context/python_preamble.prompt` immediately after the role and goal statement using 'include' XML tags.
|
|
482
573
|
- Remove any redundant instructions that are covered by the preamble, such as those related to pretty printing and handling edge cases.
|
|
483
574
|
- Ensure that the logical flow of the prompt is maintained and that any unique instructions specific to this prompt are retained.
|
|
484
|
-
- Here is what is inside context/python_preamble.prompt:<preamble>%
|
|
485
|
-
|
|
575
|
+
- Here is what is inside context/python_preamble.prompt:<preamble>% You are an expert Python engineer.
|
|
576
|
+
|
|
577
|
+
% Code Style Requirements
|
|
578
|
+
- File must start with `from __future__ import annotations`.
|
|
579
|
+
- All functions must be fully type-hinted.
|
|
580
|
+
- Use `rich.console.Console` for all printing.
|
|
581
|
+
|
|
582
|
+
% Package Structure
|
|
583
|
+
- The function should be part of a Python package, using relative imports (single dot) for internal modules (e.g. 'from .module_name import module_name').
|
|
584
|
+
- The ./pdd/__init__.py file will have the EXTRACTION_STRENGTH, DEFAULT_STRENGTH, DEFAULT_TIME and other global constants. Example: ```from . import DEFAULT_STRENGTH```
|
|
585
|
+
|
|
586
|
+
% Error Handling
|
|
587
|
+
- Ensure the function handles edge cases, such as missing inputs or model errors, and provide clear error messages.</preamble>
|
|
486
588
|
</output_example>
|
|
487
589
|
</example>
|
|
488
590
|
|
|
@@ -4,7 +4,28 @@
|
|
|
4
4
|
|
|
5
5
|
% The language of the example should be in: <language_for_example>{language}</language_for_example>
|
|
6
6
|
|
|
7
|
+
% File path information:
|
|
8
|
+
- The code module file is located at: <code_module_file_path>{source_file_path}</code_module_file_path>
|
|
9
|
+
- The example file will be saved at: <example_file_path>{example_file_path}</example_file_path>
|
|
10
|
+
- The module name (without extension) is: <module_name>{module_name}</module_name>
|
|
11
|
+
|
|
12
|
+
% IMPORT INSTRUCTIONS: Use the appropriate import mechanism for the target language
|
|
13
|
+
- CRITICAL: Use the exact module_name provided in the file path information above - DO NOT use generic names like "greetings" or "module"
|
|
14
|
+
- Avoid package-style imports unless the file is actually in a package structure
|
|
15
|
+
- Import the specific functions/classes that are defined in the code module
|
|
16
|
+
- CRITICAL: Do not assume module names - use the exact module_name provided
|
|
17
|
+
- CRITICAL: Import the appropriate functions/classes from the module (e.g., if module_name is "simple_math", import "add", "subtract", etc.)
|
|
18
|
+
- CRITICAL: Never include hardcoded absolute paths like "/Users/username/project/examples/" in comments or code
|
|
19
|
+
- Use only relative path descriptions in comments (e.g., "relative to project root" or "relative to this script")
|
|
20
|
+
- Make the example portable across different development environments
|
|
21
|
+
- Use dynamic path resolution with os.path.dirname(__file__) and relative path construction
|
|
22
|
+
- In comments, describe file structure using relative terms, not absolute paths
|
|
23
|
+
- CRITICAL: The 'extracted_code' field must preserve all newlines using proper JSON escaping (\\n). The output must be valid JSON where multi-line code is represented with \\n escape sequences for each line break.
|
|
24
|
+
|
|
7
25
|
% Make sure the following happens:
|
|
8
26
|
- Document in detail what the input and output parameters in the doc strings
|
|
9
|
-
- Someone needs to be able to fully understand how to use the module from the example.
|
|
27
|
+
- Someone needs to be able to fully understand how to use the module from the example.
|
|
28
|
+
- Use correct import statements based on the actual file structure
|
|
29
|
+
- The example should be a complete, runnable script that imports from the actual module
|
|
30
|
+
- Include proper file path handling and module discovery if needed
|
|
10
31
|
<include>./context/example.prompt</include>
|
|
@@ -19,4 +19,8 @@
|
|
|
19
19
|
% Output a JSON object with the following keys:
|
|
20
20
|
- 'focus': String containing the focus of the generation.
|
|
21
21
|
- 'explanation': String explanation of why this block_type was the focus of the generation and explain any errors detected in the code, if a code type of block.
|
|
22
|
-
- 'extracted_code': String containing the entire generated and corrected block_type of focus.
|
|
22
|
+
- 'extracted_code': String containing the entire generated and corrected block_type of focus.
|
|
23
|
+
|
|
24
|
+
% CRITICAL: The 'extracted_code' field MUST preserve all newlines and indentation from the original code. In JSON, newlines must be represented as the escape sequence \n (backslash-n). Each line break in the code must appear as \n in the JSON string value. Do NOT concatenate lines together or remove line breaks. The extracted code must be properly formatted and runnable.
|
|
25
|
+
|
|
26
|
+
% IMPORTANT: Output ONLY the JSON object. Do not add any trailing whitespace or newlines after the closing brace.
|
|
@@ -20,4 +20,10 @@
|
|
|
20
20
|
- 'update_program': Boolean indicating whether the program needs to be updated.
|
|
21
21
|
- 'update_code': Boolean indicating whether the code module needs to be updated.
|
|
22
22
|
- 'fixed_program': The entire updated program code or empty String if no update is needed.
|
|
23
|
-
- 'fixed_code': The entire updated code module or empty String if no update is needed.
|
|
23
|
+
- 'fixed_code': The entire updated code module or empty String if no update is needed.
|
|
24
|
+
|
|
25
|
+
% IMPORTANT JSON formatting rules for code strings:
|
|
26
|
+
- Use standard JSON escaping for newlines: a single backslash-n (\n) represents an actual newline
|
|
27
|
+
- Do NOT double-escape newlines. Use \n not \\n for line breaks in code
|
|
28
|
+
- String literals in code that need to print newlines should use \n (which appears as \\n in JSON)
|
|
29
|
+
- Example: for code with two lines "def foo():\n pass", the JSON should be: "def foo():\n pass"
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
% You are an expert Software Engineer. Your goal is to extract the updated prompt from the LLM output.
|
|
1
|
+
% You are an expert Software Engineer. Your goal is to extract the updated prompt from the LLM output in JSON format.
|
|
2
2
|
|
|
3
3
|
% Here is the generated llm_output: <llm_output>{llm_output}</llm_output>
|
|
4
4
|
|
|
5
|
-
% The LLM output contains the modified prompt that will generate the modified code, possibly with some additional commentary or explanation.
|
|
6
|
-
% Your task is to identify and extract ONLY the modified prompt itself, without adding any JSON structure or additional formatting.
|
|
5
|
+
% The LLM output contains the modified prompt that will generate the modified code, possibly with some additional commentary or explanation. Your task is to identify and extract ONLY the modified prompt itself, without adding any additional formatting.
|
|
7
6
|
|
|
8
7
|
% Ensure you:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
1. Remove any "# Modified Prompt" headers or similar text that isn't part of the actual prompt
|
|
9
|
+
2. Preserve all markdown, code blocks, and formatting within the actual prompt
|
|
10
|
+
3. Don't add any explanatory text, JSON wrappers, or your own commentary
|
|
11
|
+
4. Return only the text that constitutes the actual prompt
|
|
13
12
|
|
|
14
|
-
% The "modified_prompt" should be the complete, standalone prompt that could be used directly to generate the modified code.
|
|
13
|
+
% The "modified_prompt" JSON key should be the complete, standalone prompt that could be used directly to generate the modified code.
|
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
% You are an
|
|
2
|
-
|
|
3
|
-
%
|
|
4
|
-
|
|
5
|
-
%
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
% Output
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
% You are an extremely literal parser. The LLM output below follows this structure:
|
|
2
|
+
% <analysis> ... </analysis>
|
|
3
|
+
% <verbatim_prompt_line>
|
|
4
|
+
% <<EXACT SUBSTRING FROM PROMPT_FILE>>
|
|
5
|
+
% </verbatim_prompt_line>
|
|
6
|
+
%
|
|
7
|
+
% Task
|
|
8
|
+
% • Extract the text between <verbatim_prompt_line> and </verbatim_prompt_line> (if present).
|
|
9
|
+
% • Output ONLY JSON with the keys:
|
|
10
|
+
% - "prompt_line": the exact substring between the tags. Do not alter whitespace or characters except for JSON escaping.
|
|
11
|
+
% - "explanation": short confirmation (<=120 characters) that the substring was copied verbatim, or describe why extraction failed.
|
|
12
|
+
% • If the tags are missing or empty, set "prompt_line" to "" and explain the issue.
|
|
13
|
+
% • Do not wrap the JSON in Markdown. No commentary, no additional keys.
|
|
14
|
+
%
|
|
15
|
+
<llm_output>
|
|
16
|
+
{llm_output}
|
|
17
|
+
</llm_output>
|
|
@@ -21,6 +21,12 @@
|
|
|
21
21
|
Step 4. Identify any potential edge cases, error handling issues, or performance concerns that could cause problems in the future.
|
|
22
22
|
Step 5. Check the code for potential bugs that haven't manifested yet.
|
|
23
23
|
Step 6. If any issues are found, explain in detail the root cause of each issue and how it could impact the program's functioning.
|
|
24
|
+
Step 6.5. When analyzing errors involving mocked dependencies:
|
|
25
|
+
- Identify if 'program' uses MagicMock, unittest.mock, or similar mocking
|
|
26
|
+
- Trace the mock configuration to verify it matches expected real API behavior
|
|
27
|
+
- For AttributeError on mock objects: check if mock.return_value or mock.__getitem__.return_value has correct type
|
|
28
|
+
- Flag errors as "Mock Configuration Error" when the mock setup doesn't match real API return types
|
|
29
|
+
- Flag errors as "Production Code Error" only when the API usage is clearly incorrect
|
|
24
30
|
Step 7. Carefully distinguish between:
|
|
25
31
|
a. Incompatibilities (functions called by program but missing from code_module) - these are critical issues
|
|
26
32
|
b. Prompt adherence issues (code doesn't match prompt requirements) - these are important but secondary to compatibility
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
% IMPORTANT: The crash command should fix whatever needs to be fixed to make the program run successfully:
|
|
4
4
|
- If the code module has bugs, fix the code module
|
|
5
|
-
- If the calling program has bugs, fix the calling program
|
|
5
|
+
- If the calling program has bugs, fix the calling program
|
|
6
6
|
- If both have issues that contribute to the crash, fix BOTH
|
|
7
7
|
- The goal is to ensure the program runs without errors after all fixes are applied
|
|
8
|
+
- If you are not able to fix the calling program, or if you cannot access it, you shouldn't guess at fixes to the calling program. Do not add the functionality of the calling program to the code_module.
|
|
9
|
+
- You must ensure that the code_module strictly adheres to the prompt requirements
|
|
8
10
|
|
|
9
|
-
% Here is the program that is running the code_module that crashed and/or has errors: <program>{program}</program>
|
|
11
|
+
% Here is the calling program that is running the code_module that crashed and/or has errors: <program>{program}</program>
|
|
10
12
|
|
|
11
13
|
% Here is the prompt that generated the code_module below: <prompt>{prompt}</prompt>
|
|
12
14
|
|
|
@@ -10,6 +10,14 @@
|
|
|
10
10
|
|
|
11
11
|
% If the verfication program fails to run, the code_under_test and unit_test are unchanged from the previous iteration.
|
|
12
12
|
|
|
13
|
+
% IMPORTANT: The original prompt is the authoritative specification for what the code should do.
|
|
14
|
+
% When analyzing errors:
|
|
15
|
+
% - If the code doesn't match the prompt specification, fix the CODE
|
|
16
|
+
% - If the unit_test expects behavior not specified in the prompt, fix the TEST
|
|
17
|
+
% - Never add functionality to the code that isn't specified in the prompt
|
|
18
|
+
% - Tests should verify prompt-specified behavior, not arbitrary expectations
|
|
19
|
+
|
|
20
|
+
|
|
13
21
|
|
|
14
22
|
<instructions>
|
|
15
23
|
% Follow these steps to solve these errors:
|
|
@@ -21,6 +21,28 @@
|
|
|
21
21
|
5. Prefer making additive changes (adding new functions, improving existing ones) rather than removing functionality, even if that means going beyond the minimal requirements of the prompt.
|
|
22
22
|
6. If your previous fixes resulted in verification failures related to missing functions, ensure those functions are included in your solution.
|
|
23
23
|
|
|
24
|
+
% MOCK VS PRODUCTION CODE GUIDANCE:
|
|
25
|
+
1. IDENTIFY THE TEST FILE: The 'program' file may be a TEST FILE that uses mocks (MagicMock, unittest.mock, patch) to simulate external dependencies.
|
|
26
|
+
- Look for imports: `from unittest.mock import MagicMock, patch`
|
|
27
|
+
- Look for mock setup patterns: `mock_obj.return_value`, `mock_obj.__getitem__.return_value`
|
|
28
|
+
|
|
29
|
+
2. WHEN ERRORS OCCUR IN MOCK INTERACTIONS:
|
|
30
|
+
- FIRST check if the mock setup is incorrect (wrong return_value structure, missing __getitem__ configuration)
|
|
31
|
+
- Mock return types must match the REAL API return types exactly
|
|
32
|
+
- Common mock bugs:
|
|
33
|
+
* `__getitem__.return_value = [item]` when it should be `= item` (for APIs where indexing returns single item)
|
|
34
|
+
* Missing chained mock configuration (e.g., `mock.method().other_method()`)
|
|
35
|
+
|
|
36
|
+
3. PRESERVE PRODUCTION CODE API USAGE:
|
|
37
|
+
- The 'code_module' implements PRODUCTION code that calls real APIs
|
|
38
|
+
- Assume production code uses CORRECT API patterns unless you have documentation proving otherwise
|
|
39
|
+
- Do NOT change production code indexing patterns (like `[0][0]`) without external API documentation
|
|
40
|
+
|
|
41
|
+
4. DIAGNOSIS PRIORITY for "AttributeError" or type mismatch:
|
|
42
|
+
a. First: Check mock.return_value / mock.__getitem__.return_value structure
|
|
43
|
+
b. Second: Check if mock chaining matches expected API call pattern
|
|
44
|
+
c. Third: Only then consider if production code has wrong API usage
|
|
45
|
+
|
|
24
46
|
% Follow these steps to fix the program or code_module:
|
|
25
47
|
Step 1. Analyze and understand each identified issue in the context of the code_module and program.
|
|
26
48
|
Step 2. Analyze how the program uses the code_module to determine all functions that must be preserved.
|
|
@@ -4,7 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
% Here is the code under test: <code_under_test>{code}</code_under_test>
|
|
6
6
|
|
|
7
|
+
% File path information:
|
|
8
|
+
- The code under test module file is located at: <code_under_test_file_path>{source_file_path}</code_under_test_file_path>
|
|
9
|
+
- The example file will be saved at: <test_file_path>{test_file_path}</test_file_path>
|
|
10
|
+
- The module name (without extension) is: <module_name>{module_name}</module_name>
|
|
11
|
+
|
|
7
12
|
% Follow these rules:
|
|
13
|
+
- CRITICAL: You MUST analyze the actual code provided in code_under_test and generate tests for the EXACT functions defined in that code
|
|
14
|
+
- CRITICAL: Import statements must use the ACTUAL module name from the code file path, not generic names. Include the necessary code/path info to import the code under test.
|
|
15
|
+
- CRITICAL: Test the ACTUAL function names, parameters, and behavior shown in the provided code
|
|
8
16
|
- The module name for the code under test will have the same name as the function name
|
|
9
17
|
- The unit test should be in {language}. If Python, use pytest.
|
|
10
18
|
- Use individual test functions for each case to make it easier to identify which specific cases pass or fail.
|
|
@@ -17,10 +25,17 @@
|
|
|
17
25
|
<include>./context/test.prompt</include>
|
|
18
26
|
|
|
19
27
|
<instructions>
|
|
20
|
-
1. Carefully
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
28
|
+
1. FIRST: Carefully analyze the ACTUAL code provided in code_under_test:
|
|
29
|
+
- Identify the EXACT function names defined in the code
|
|
30
|
+
- Identify the EXACT parameters and their types
|
|
31
|
+
- Identify the EXACT return values and behavior
|
|
32
|
+
- Identify any error conditions or edge cases
|
|
33
|
+
2. SECOND: Analyze the prompt that generated the code to understand the intended functionality and edge cases.
|
|
34
|
+
3. THIRD: For each edge case explain whether it is better to do the test using Z3 formal verification or unit tests.
|
|
35
|
+
4. FOURTH: Develop a detailed test plan that will ensure the code under test is correct. This should involve both Z3 formal verification and unit tests.
|
|
36
|
+
5. FIFTH: Write the test file with:
|
|
37
|
+
a) The first part of the test file should be the detailed test plan from step 4 above in comments.
|
|
38
|
+
b) Import statements using the ACTUAL module name from the code file path (e.g., if code is in "my_function.py", use "from my_function import function_name")
|
|
39
|
+
c) Tests for the ACTUAL function names and behavior shown in the provided code
|
|
40
|
+
d) Z3 formal verification tests that are runnable as unit tests.
|
|
26
41
|
</instructions>
|
|
@@ -12,8 +12,4 @@ Here is the coverage report: ```{coverage_report}```
|
|
|
12
12
|
- The module name for the code under test will have the same name as the function name
|
|
13
13
|
- The unit test should be in {language}. If Python, use pytest.
|
|
14
14
|
- Use individual test functions for each case to make it easier to identify which specific cases pass or fail.
|
|
15
|
-
- Use the description of the functionality in the prompt to generate tests with useful tests with good code coverage.
|
|
16
|
-
- Know that the generated test will be in a different directory (`tests`) than the module (in directory `pdd`) it is calling and will need an absolute reference. The module file name will be same as the function name.
|
|
17
|
-
- Created files should be in the `output` directory.
|
|
18
|
-
- Data files (language_format.csv and llm_model.csv) already exist in the PDD_PATH/`data` directory. Do not write over them. It already contains data for popular languages and LLM models and can be used for tests.
|
|
19
|
-
- The PDD_PATH environment variable is already set.
|
|
15
|
+
- Use the description of the functionality in the prompt to generate tests with useful tests with good code coverage.
|